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
- Host: GitHub
- URL: https://github.com/nov/attr_required
- Owner: nov
- License: mit
- Created: 2010-12-03T18:54:52.000Z (about 15 years ago)
- Default Branch: main
- Last Pushed: 2025-08-09T01:44:05.000Z (4 months ago)
- Last Synced: 2025-12-01T13:41:53.505Z (11 days ago)
- Language: Ruby
- Homepage:
- Size: 38.1 KB
- Stars: 8
- Watchers: 1
- Forks: 4
- Open Issues: 0
- Releases: 0
-
Metadata Files:
- Readme: README.rdoc
- Funding: .github/FUNDING.yml
- License: LICENSE
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
- Name: Nov Matake
- Login: nov
- Email: nov@matake.jp
- Kind: user
- Description: Working around Ruby, OAuth, OpenID etc.
- Website: https://matake.jp
- Location: Tokyo, Japan
- Twitter: nov
- Company: YAuth.jp LLC
- Icon url: https://avatars.githubusercontent.com/u/27299?u=d02b1d3e03dc134d2d0a42e670eac1be099064e0&v=4
- Repositories: 166
- Last ynced at: 2025-10-29T22:36:11.404Z
- Profile URL: https://github.com/nov
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 | 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:
- dio.jp: 1
- davidcel.is: 1
- paraesthesia.com: 1
- gree.net: 1
- matake.jp: 1
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
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
- Total packages: 2
-
Total downloads:
- rubygems: 150,653,228 total
- Total docker downloads: 1,027,867,156
- Total dependent packages: 14 (may contain duplicates)
- Total dependent repositories: 3,209 (may contain duplicates)
- Total versions: 16
- Total maintainers: 1
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
- rake >= 0 development
- rspec >= 0 development
- simplecov >= 0 development
- actions/checkout v3 composite
- ruby/setup-ruby v1 composite
Score: 24.576408175484342