{"id":21203409,"url":"https://github.com/dux/clean-annotations","last_synced_at":"2025-03-14T22:42:50.463Z","repository":{"id":62555725,"uuid":"226884806","full_name":"dux/clean-annotations","owner":"dux","description":"Define annotatable attribute names, assign them to methods or classes, add callbacks to non-Rails classes. Void of dependencies.","archived":false,"fork":false,"pushed_at":"2021-09-09T07:40:04.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-26T20:20:33.841Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-09T14:00:07.000Z","updated_at":"2022-08-01T12:27:15.000Z","dependencies_parsed_at":"2022-11-03T05:45:23.144Z","dependency_job_id":null,"html_url":"https://github.com/dux/clean-annotations","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/dux%2Fclean-annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dux%2Fclean-annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dux%2Fclean-annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dux%2Fclean-annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dux","download_url":"https://codeload.github.com/dux/clean-annotations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243658152,"owners_count":20326464,"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-20T20:23:50.240Z","updated_at":"2025-03-14T22:42:49.551Z","avatar_url":"https://github.com/dux.png","language":"Ruby","readme":"# Clean annotations - annotate ruby methods and classes\n\nDefine annotatable attribute names and assign them to methods or classes, add callbacks to non-Rails classes. Void of dependencies.\n\n# INFO\n\nDeprecated and split in 3 libs, please use \n\n* https://github.com/dux/class-cattr - Class attributes\n* https://github.com/dux/class-mattr - Class method attributes\n* https://github.com/dux/class-callbacks - Class callbacks\n\n## Installation and usage\n\nto install\n\n`gem install clean-annotations`\n\nor in Gemfile\n\n`gem 'clean-annotations'`\n\nand to use\n\n`require 'clean-annotations'`\n\n### Dependency\n\nNone\n\n## Class attributes\n\n```\nclass A\n  class_attribute :layout, 'default'\n  class_attribute(:time) { Time.now }\nend\n\nclass B \u003c A\n  layout 'main'\nend\n\nclass C \u003c B\n  time '11:55'\nend\n\nfor func in [:layout, :time]\n  for klass in [A, B, C]\n    puts \"\u003e %s = %s\" % [\"#{klass}.#{func}\".ljust(8), klass.send(func)]\n  end\nend\n\n# A.layout = default\n# B.layout = main\n# C.layout = main\n# A.time   = 2019-10-28 18:07:33 +0100\n# B.time   = 2019-10-28 18:07:33 +0100\n# C.time   = 11:55\n```\n\n## Class Callbacks\n\n```\nclass Foo\n  define_callback :before\n\n  before do\n  end\n\n  before :method_name\nend\n\n# instance = new\n# instance.run_callback :before\n# instance.run_callback :before, @arg\n```\n\n## Method attributes\n\n```\nclass Foo\n  method_attr :name\n  method_attr :param do |field, type=String, opts={}|\n    opts[:name] = field\n    opts[:type] ||= String\n    opts\n  end\nend\n\nclass Foo\n  name \"Test method desc 1\"\n  name \"Test method desc 2\"\n  param :email, :email\n  def test\n    # ...\n  end\nend\n\n# Foo.method_attr\n# {\n#   test: {\n#     name: [\n#       [\"Test method desc 1\"],\n#       [\"Test method desc 2\"]\n#     ],\n#     param: [\n#       {\n#         name: :email,\n#         type: String\n#       }\n#     ]\n#   }\n# }\n```\n\n## Rescue from\n\nStandard Rails like `rescue_from`. You capture errors by executing in `resolve_rescue_from`\n\n```ruby\nclass RescueParent\n  include RescueFromError\n\n  rescue_from :all do\n    # ...\n  end\n\n  rescue_from NoMethodError do\n    # ...\n  end\nend\n\nclass RescueTest\n  def some_method\n    resolve_rescue_from do\n      triger_no_method_error\n    end\n  end\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bundle install` to install dependencies. Then, run `rspec` to run the tests.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/solnic/clean-annotations.\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the\n[Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdux%2Fclean-annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdux%2Fclean-annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdux%2Fclean-annotations/lists"}