A summary of data about the Ruby ecosystem.

https://github.com/nov/attr_required

Provide attr_required with presence validation
https://github.com/nov/attr_required

Keywords from Contributors

rack jose json-web-encryption json-web-key json-web-signature json-web-token jwe jwk jws oauth

Last synced: about 9 hours ago
JSON representation

Repository metadata

Provide attr_required with presence validation

README.rdoc

          = attr_required

This gem provide attr_required and attr_optional like attr_accessor.

REQUIRED and OPTIONAL are common terminology in RFCs, and used for protocol parameters.
This gem helps RFC library developers to define which parameters (attributes in Ruby world) are REQUIRED and which are OPTIONAL.
It might be also helpful for other developers.

I've developed this gem to use for rack-oauth2, a Rack-based OAuth 2.0 library.
https://github.com/nov/rack-oauth2

== Installation

  gem install attr_required

== Usage

# Attributes Definitions

  require 'attr_required'
  require 'attr_optional'

  class A
    include AttrRequired, AttrOptional
    attr_required :required_a
    attr_optional :optional_a
  end

  class B < A
    attr_required :required_b
    attr_optional :optional_b
  end

# Class Methods

  A.required_attributes #=> [:required_a]
  B.required_attributes #=> [:required_a, :required_b]
  A.optional_attributes #=> [:optional_a]
  B.optional_attributes #=> [:optional_a, :optional_b]

  A.attr_required?(:required_a) #=> true
  B.attr_optional?(:optional_b) #=> true

# Instance Methods

  @a = A.new
  @b = B.new

  @a.required_attributes #=> [:required_a]
  @b.required_attributes #=> [:required_a, :required_b]
  @a.optional_attributes #=> [:optional_a]
  @b.optional_attributes #=> [:optional_a, :optional_b]

  @a.attr_required?(:required_a) #=> true
  @a.attr_optional?(:optiona_a)  #=> true

  @a.attr_missing? #=> true
  @a.attr_missing  #=> [:required_a]
  @a.attr_missing! #=> raise AttrRequired::AttrMissing
  @a.required_a = "foo"
  @a.attr_missing? #=> false
  @a.attr_missing  #=> []
  @a.attr_missing! #=> do nothing

Check spec/attr_(required|optional).rb for more details.

== Note on Patches/Pull Requests

* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright (c) 2010 nov matake. See LICENSE for details.

        

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 7 days ago

Total Commits: 64
Total Committers: 5
Avg Commits per committer: 12.8
Development Distribution Score (DDS): 0.141

Commits in past year: 2
Committers in past year: 1
Avg Commits per committer in past year: 2.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
nov matake n****v@m****p 55
nov n****e@g****t 6
Travis Illig t****g@p****m 1
David Celis me@d****s 1
Akira Matsuda r****e@d****p 1

Committer domains:


Issue and Pull Request metadata

Last synced: 3 months ago

Total issues: 2
Total pull requests: 4
Average time to close issues: 3 months
Average time to close pull requests: 9 months
Total issue authors: 1
Total pull request authors: 4
Average comments per issue: 2.0
Average comments per pull request: 0.5
Merged pull request: 3
Bot issues: 0
Bot pull requests: 0

Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/nov/attr_required

Top Issue Authors

  • balasankarc (2)

Top Pull Request Authors

  • gururajrkatti (1)
  • tillig (1)
  • davidcelis (1)
  • amatsuda (1)

Top Issue Labels

Top Pull Request Labels


Package metadata

gem.coop: attr_required

attr_required and attr_optional

  • Homepage: https://github.com/nov/attr_required
  • Documentation: http://www.rubydoc.info/gems/attr_required/
  • Licenses: MIT
  • Latest release: 1.0.2 (published almost 2 years ago)
  • Last Synced: 2025-12-10T05:32:33.842Z (2 days ago)
  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 75,334,400 Total
  • Docker Downloads: 513,933,578
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Docker downloads count: 0.109%
    • Average: 0.122%
    • Downloads: 0.378%
  • Maintainers (1)
rubygems.org: attr_required

attr_required and attr_optional

  • Homepage: https://github.com/nov/attr_required
  • Documentation: http://www.rubydoc.info/gems/attr_required/
  • Licenses: MIT
  • Latest release: 1.0.2 (published almost 2 years ago)
  • Last Synced: 2025-12-09T19:04:09.436Z (2 days ago)
  • Versions: 8
  • Dependent Packages: 14
  • Dependent Repositories: 3,209
  • Downloads: 75,318,828 Total
  • Docker Downloads: 513,933,578
  • Rankings:
    • Docker downloads count: 0.234%
    • Downloads: 0.411%
    • Dependent repos count: 0.548%
    • Dependent packages count: 1.364%
    • Average: 6.26%
    • Stargazers count: 17.328%
    • Forks count: 17.673%
  • Maintainers (1)

Dependencies

attr_required.gemspec rubygems
  • rake >= 0 development
  • rspec >= 0 development
  • simplecov >= 0 development
.github/workflows/spec.yml actions
  • actions/checkout v3 composite
  • ruby/setup-ruby v1 composite
Gemfile rubygems

Score: 24.576408175484342