{"id":19680156,"url":"https://github.com/drewolson/block-chainable","last_synced_at":"2026-06-10T06:37:39.337Z","repository":{"id":400971,"uuid":"19278","full_name":"drewolson/block-chainable","owner":"drewolson","description":"easier ruby DSLs with blocks","archived":false,"fork":false,"pushed_at":"2008-12-03T03:11:19.000Z","size":88,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-10T05:23:15.453Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://block-chainable.rubyforge.org","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drewolson.png","metadata":{"files":{"readme":"README.rdoc","changelog":"History.txt","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2008-05-24T00:00:31.000Z","updated_at":"2023-07-25T13:41:01.000Z","dependencies_parsed_at":"2022-07-07T14:41:02.610Z","dependency_job_id":null,"html_url":"https://github.com/drewolson/block-chainable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewolson%2Fblock-chainable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewolson%2Fblock-chainable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewolson%2Fblock-chainable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewolson%2Fblock-chainable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drewolson","download_url":"https://codeload.github.com/drewolson/block-chainable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240989246,"owners_count":19889655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T18:04:13.709Z","updated_at":"2026-06-10T06:37:39.296Z","avatar_url":"https://github.com/drewolson.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= BlockChainable\n\n* http://block-chainable.rubyforge.org\n* source - http://github.com/drewolson/block-chainable/tree/master\n\n== DESCRIPTION:\n\nBlockChainable is a module to aid in the creation of Domain Specific Languages using block structure.\nBy including BlockChainable into your classes, you will be able to instantiate that class using the\nclass name itself, followed by any parameters to be passed to initialize, followed by a block to be\nexecuted within the instantiated class.\n\nBlockChainable also allows methods to search up the chain of classes, meaning that although a block\nis executed in the scope of the instantiated class, any methods not found in the class but found in a\nclass \"up-scope\" will be called successfully on the up-scope class. This chaining of method calls allows\nyou to assert values within the blocks as well as calling any other methods from \"up-scope\" classes.\n\n== FEATURES/PROBLEMS:\n\n* 2 major features\n  * Block instantiation of classes\n  * Method calls will look \"up-scope\" for receivers when called inside BlockChainable blocks\n* 1 minor problem\n  * Stack trace should be simplified on errors within BlockChainable blocks\n\n== SYNOPSIS:\n  # a simple nonsense example showing the ability to call methods in outer block scopes\n \n  # create some simple classes that include BlockChainable\n  require 'block_chainable'\n\n  class Foo\n    include BlockChainable\n  \n    def hi_from_foo\n      puts \"hello from foo\"\n    end\n  end\n  \n  class Bar\n    include BlockChainable\n  \n    def hi_from_bar\n      puts \"hello from bar\"\n    end\n  end\n  \n  class Boo\n    include BlockChainable\n  \n    def hi_from_boo\n      puts \"hello from boo\"\n    end\n  end\n  \n\n  # we can now use the classes in a DSL manner. notice that calls can happen from with blocks to\n  # \"outer-block\" methods.\n  Foo do\n    hi_from_foo\n  \n    Bar do\n      hi_from_bar\n      hi_from_foo\n  \n      Boo do\n        hi_from_boo\n        hi_from_bar\n        hi_from_foo\n      end\n    end\n  end\n\n  # A slighty more complicated example.\n  # a simple dsl for creating classroom rosters and printing them out. code can be found in the\n  # example directory.\n\n  require 'block_chainable'\n  \n  # first, define our roster\n  class Roster\n    include BlockChainable\n    \n    def initialize(subject)\n      @subject = subject\n      @students = []\n    end\n    \n    def add_student_to_roster student\n      @students \u003c\u003c student\n    end\n    \n    def print_roster\n      puts \"Roster for #{@subject}:\"\n      @students.each{|s| puts \"  #{s}\"}\n    end\n  end\n\n  # next, define our student. the only tricky part here is add_to_roster, which calls\n  # the method add_student_to_roster, which is actually defined on the Roster class.\n  # BlockChainable will automatically send this method to the Roster class with the\n  # Student instance as a parameter.\n  class Student\n    include BlockChainable\n  \n    def add_to_roster\n      add_student_to_roster self\n    end\n  \n    def to_s\n      \"#{@last_name}, #{@first_name} - age #{@age}\"\n    end\n  \n    def first_name name\n      @first_name = name\n    end\n  \n    def last_name name\n      @last_name = name\n    end\n  \n    def age years\n      @age = years\n    end\n  end\n\n  # we now have all the pieces we need for creating a simple dsl for building\n  # and printing a class roster\n\n  Roster :Math do\n    Student do\n      first_name \"Drew\"\n      last_name \"Olson\"\n      age 25\n  \n      add_to_roster\n    end\n  \n    Student do\n      first_name \"John\"\n      last_name \"Doe\"\n      age 17\n  \n      add_to_roster\n    end\n  \n    Student do\n      first_name \"Jane\"\n      last_name \"Doe\"\n      age 19\n  \n      add_to_roster\n    end\n  \n    print_roster\n  end\n\n== REQUIREMENTS:\n\n* need\n* rspec\n\n== INSTALL:\n\n* rubyforge - sudo gem install block-chainable\n* github - sudo gem install drewolson-block-chainable --source=http://gems.github.com\n\n== LICENSE:\n\n(The MIT License)\n\nCopyright (c) 2008 Drew Olson\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewolson%2Fblock-chainable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrewolson%2Fblock-chainable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewolson%2Fblock-chainable/lists"}