registrable 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +46 -0
- data/.yardopts +4 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +3 -0
- data/Guardfile +24 -0
- data/LICENSE.txt +21 -0
- data/README.md +88 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/bin/console +14 -0
- data/bin/guard +18 -0
- data/bin/rake +18 -0
- data/bin/rspec +18 -0
- data/bin/setup +8 -0
- data/examples/plugin.rb +21 -0
- data/examples/role.rb +35 -0
- data/lib/registrable/version.rb +7 -0
- data/lib/registrable.rb +51 -0
- data/registrable.gemspec +35 -0
- data/templates/README.md.erb +42 -0
- metadata +206 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c29679b74ce08b4f0ec4d4209b8237640d41d4fd
|
4
|
+
data.tar.gz: 76d0958c355a06fe83b375441a9fe775b96ec172
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8680da778b1c30dcc46387b386294970b42121ffcc0d5b9bfdd876883b1a99efc2c359fd26eedbf2468bffb4184eee7ab334b8e86394e5b269b6503af218647c
|
7
|
+
data.tar.gz: 19e9d6df57708f87593a60cce771f75f60b4686246194a9993a812e51cb8396c0c1acbe8ae7c4c90175bb30712201e8840ed5e0af62eb144174f1801aa66f88b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
AllCops:
|
2
|
+
DefaultFormatter: fuubar
|
3
|
+
DisplayCopNames: true
|
4
|
+
DisplayStyleGuide: true
|
5
|
+
Exclude:
|
6
|
+
- "examples/**/*.rb"
|
7
|
+
|
8
|
+
Metrics/LineLength:
|
9
|
+
Max: 120
|
10
|
+
Exclude:
|
11
|
+
- "*.gemspec"
|
12
|
+
|
13
|
+
Style/Documentation:
|
14
|
+
Exclude:
|
15
|
+
- "lib/**/version.rb"
|
16
|
+
- "spec/**/*.rb"
|
17
|
+
- "Rakefile"
|
18
|
+
|
19
|
+
Metrics/BlockLength:
|
20
|
+
Exclude:
|
21
|
+
- "spec/**/*_spec.rb"
|
22
|
+
|
23
|
+
Style/EmptyLinesAroundBlockBody:
|
24
|
+
EnforcedStyle: no_empty_lines
|
25
|
+
# SupportedStyles:
|
26
|
+
# - empty_lines
|
27
|
+
# - no_empty_lines
|
28
|
+
|
29
|
+
Style/EmptyLinesAroundClassBody:
|
30
|
+
EnforcedStyle: empty_lines_except_namespace
|
31
|
+
# SupportedStyles:
|
32
|
+
# - empty_lines
|
33
|
+
# - empty_lines_except_namespace
|
34
|
+
# - empty_lines_special
|
35
|
+
# - no_empty_lines
|
36
|
+
|
37
|
+
Style/EmptyLinesAroundModuleBody:
|
38
|
+
EnforcedStyle: empty_lines_except_namespace
|
39
|
+
# SupportedStyles:
|
40
|
+
# - empty_lines
|
41
|
+
# - empty_lines_except_namespace
|
42
|
+
# - empty_lines_special
|
43
|
+
# - no_empty_lines
|
44
|
+
|
45
|
+
Lint/UnusedMethodArgument:
|
46
|
+
Enabled: false
|
data/.yardopts
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ryanscottlewis@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
guard :rspec, cmd: 'bin/rspec' do
|
2
|
+
require 'guard/rspec/dsl'
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# RSpec files
|
6
|
+
rspec = dsl.rspec
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_files)
|
10
|
+
|
11
|
+
# Ruby files
|
12
|
+
watch(%r{lib/(.+)\.rb$}) { |match| "spec/unit/#{match[1]}_spec.rb" }
|
13
|
+
end
|
14
|
+
|
15
|
+
guard :rubocop, all_on_start: false, cli: '--config .rubocop.yml --auto-correct --format fuubar' do
|
16
|
+
watch(/.+\.rb$/)
|
17
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
18
|
+
end
|
19
|
+
|
20
|
+
guard :yard, server: false do
|
21
|
+
watch(/^(README|LICENSE|CODE_OF_CONDUCT)/)
|
22
|
+
watch(%r{lib\/.+\.rb})
|
23
|
+
watch(/.yardopts/)
|
24
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Ryan Scott Lewis <ryanscottlewis@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Registrable
|
2
|
+
|
3
|
+
## Install
|
4
|
+
|
5
|
+
### Bundler: `gem "registrable"`
|
6
|
+
|
7
|
+
### RubyGems: `gem install registrable`
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```rb
|
12
|
+
require 'registrable'
|
13
|
+
|
14
|
+
class Role
|
15
|
+
def initialize(read, modify)
|
16
|
+
@read, @modify = create, modify
|
17
|
+
end
|
18
|
+
|
19
|
+
def read?
|
20
|
+
@read
|
21
|
+
end
|
22
|
+
|
23
|
+
def modify?
|
24
|
+
@modify
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class User
|
29
|
+
extend Registrable
|
30
|
+
|
31
|
+
def initialize(role)
|
32
|
+
self.role = role
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_reader :role
|
36
|
+
|
37
|
+
def role=(role)
|
38
|
+
role = Role.registry[identifier] || Role.registry[:other] unless role.is_a?(Role)
|
39
|
+
|
40
|
+
@role = role
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Role.register(:other, false, false)
|
45
|
+
Role.register(:user, true, false)
|
46
|
+
Role.register(:admin, true, true)
|
47
|
+
```
|
48
|
+
|
49
|
+
```rb
|
50
|
+
other = User.new(:other)
|
51
|
+
|
52
|
+
p other.role.readable? # => true
|
53
|
+
p other.role.modifiable? # => true
|
54
|
+
|
55
|
+
user = User.new(:user)
|
56
|
+
|
57
|
+
p admin.role.readable? # => true
|
58
|
+
p admin.role.modifiable? # => false
|
59
|
+
|
60
|
+
admin = User.new(:admin)
|
61
|
+
|
62
|
+
p admin.role.readable? # => true
|
63
|
+
p admin.role.modifiable? # => true
|
64
|
+
```
|
65
|
+
|
66
|
+
## Development
|
67
|
+
|
68
|
+
* `bin/setup` to install dependencies
|
69
|
+
* `bin/console` for an interactive prompt
|
70
|
+
* `bin/rake -T` to run view tasks
|
71
|
+
* `bin/rake test` to test
|
72
|
+
* `bin/rake lint` to lint
|
73
|
+
* `bin/rake docs` to generate documentation
|
74
|
+
* `bin/rake install` to install this gem onto your machine
|
75
|
+
* `bin/rake` to test, lint, and generate documentation
|
76
|
+
* To release a new version
|
77
|
+
* `bin/rake version:bump`
|
78
|
+
* `bin/rake release` to create a git tag for the version, push git commits and tags, and push the gem to [rubygems.org](https://rubygems.org).
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/RyanScottLewis/striker.
|
83
|
+
|
84
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
85
|
+
|
86
|
+
## License
|
87
|
+
|
88
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rake/version_task'
|
4
|
+
require 'rubocop/rake_task'
|
5
|
+
require 'yard'
|
6
|
+
require 'erb'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:test)
|
9
|
+
|
10
|
+
Rake::VersionTask.new
|
11
|
+
|
12
|
+
RuboCop::RakeTask.new(:lint)
|
13
|
+
|
14
|
+
YARD::Rake::YardocTask.new(:docs)
|
15
|
+
|
16
|
+
TEMPLATES_PATH = Pathname.new('templates')
|
17
|
+
TEMPLATE_PATHS = FileList[TEMPLATES_PATH.join('**', '*').to_s]
|
18
|
+
README_INPUT = TEMPLATES_PATH.join('README.md.erb')
|
19
|
+
README_OUTPUT = Pathname.new('README.md')
|
20
|
+
|
21
|
+
class RenderContext
|
22
|
+
|
23
|
+
def self.render(input_path, output_path)
|
24
|
+
new(input_path).render(output_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(path)
|
28
|
+
@erb = ERB.new(path.read)
|
29
|
+
end
|
30
|
+
|
31
|
+
def file(path)
|
32
|
+
File.read(path).strip
|
33
|
+
end
|
34
|
+
|
35
|
+
def render(path)
|
36
|
+
contents = @erb.result(binding)
|
37
|
+
|
38
|
+
README_OUTPUT.open('w+') { |file| file.write(contents) }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
file README_OUTPUT => [README_INPUT, TEMPLATE_PATHS] do
|
44
|
+
RenderContext.render(README_INPUT, README_OUTPUT)
|
45
|
+
end
|
46
|
+
|
47
|
+
task default: [:spec, 'lint:auto_correct', :docs, README_OUTPUT]
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'registrable'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/guard
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'guard' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'pathname'
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'bundler/setup'
|
17
|
+
|
18
|
+
load Gem.bin_path('guard', 'guard')
|
data/bin/rake
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'pathname'
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'bundler/setup'
|
17
|
+
|
18
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/rspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require 'pathname'
|
12
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'bundler/setup'
|
17
|
+
|
18
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/bin/setup
ADDED
data/examples/plugin.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'registrable'
|
2
|
+
|
3
|
+
class Plugin
|
4
|
+
|
5
|
+
extend Registrable
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :name
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
unless ENV['RSPEC'] # Not loading this file from tests
|
16
|
+
p Plugin.register(:my_plugin, 'My Plugin') # => #<Plugin:0x0001 @name="My Plugin">
|
17
|
+
p Plugin.registered?(:my_plugin) # => true
|
18
|
+
p Plugin.registry[:my_plugin] # => #<Plugin:0x0001 @name="My Plugin">
|
19
|
+
p Plugin.unregister(:my_plugin) # => #<Plugin:0x0001 @name="My Plugin">
|
20
|
+
p Plugin.registered?(:my_plugin) # => false
|
21
|
+
end
|
data/examples/role.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'registrable'
|
2
|
+
|
3
|
+
class Role
|
4
|
+
extend Registrable
|
5
|
+
|
6
|
+
def initialize(readable, modifiable)
|
7
|
+
@readable, @modifiable = readable, modifiable
|
8
|
+
end
|
9
|
+
|
10
|
+
def readable?
|
11
|
+
@readable
|
12
|
+
end
|
13
|
+
|
14
|
+
def modifiable?
|
15
|
+
@modifiable
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class User
|
20
|
+
def initialize(role)
|
21
|
+
self.role = role
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_reader :role
|
25
|
+
|
26
|
+
def role=(role)
|
27
|
+
role = Role.registry[role] || Role.registry[:other] unless role.is_a?(Role)
|
28
|
+
|
29
|
+
@role = role
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Role.register(:other, false, false)
|
34
|
+
Role.register(:user, true, false)
|
35
|
+
Role.register(:admin, true, true)
|
data/lib/registrable.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'registrable/version'
|
2
|
+
|
3
|
+
# Allow a class to hold a registry of instances
|
4
|
+
module Registrable
|
5
|
+
|
6
|
+
# All registered instances
|
7
|
+
#
|
8
|
+
# @return [Hash]
|
9
|
+
def registry
|
10
|
+
@registry ||= {}.freeze
|
11
|
+
end
|
12
|
+
|
13
|
+
# Register an instance
|
14
|
+
#
|
15
|
+
# @param [Object] identifier
|
16
|
+
# @param [Array] arguments The arguments to pass to #initialize
|
17
|
+
# @param [Proc] block The block to pass to #initialize
|
18
|
+
# @return [Object] The instance
|
19
|
+
def register(identifier, *arguments, &block)
|
20
|
+
@registry = @registry ? registry.dup : {}
|
21
|
+
|
22
|
+
instance = new(*arguments, &block)
|
23
|
+
|
24
|
+
@registry[identifier] = instance
|
25
|
+
@registry.freeze
|
26
|
+
|
27
|
+
instance
|
28
|
+
end
|
29
|
+
|
30
|
+
# Unregister an instance
|
31
|
+
#
|
32
|
+
# @param [Object] identifier
|
33
|
+
# @return [Object] The instance
|
34
|
+
def unregister(identifier)
|
35
|
+
@registry = @registry ? registry.dup : {}
|
36
|
+
|
37
|
+
instance = @registry.delete(identifier)
|
38
|
+
@registry.freeze
|
39
|
+
|
40
|
+
instance
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get whether an instance is registered
|
44
|
+
#
|
45
|
+
# @param [Object] identifier
|
46
|
+
# @return [Boolean]
|
47
|
+
def registered?(identifier)
|
48
|
+
registry.key?(identifier)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/registrable.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'registrable/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'registrable'
|
9
|
+
spec.version = Registrable::VERSION
|
10
|
+
spec.authors = ['Ryan Scott Lewis']
|
11
|
+
spec.email = ['ryanscottlewis@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = "Allows a class to hold a registry of it's instances"
|
14
|
+
spec.description = "Extend in a class to allow it to hold a registry of it's instances"
|
15
|
+
spec.homepage = 'https://github.com/RyanScottLewis/registrable'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
26
|
+
spec.add_development_dependency 'fuubar', '~> 2.2'
|
27
|
+
spec.add_development_dependency 'guard-rubocop', '~> 1.2'
|
28
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
29
|
+
spec.add_development_dependency 'guard-yard', '~> 2.2'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 0.48'
|
33
|
+
spec.add_development_dependency 'version', '~> 1.0'
|
34
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
35
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Registrable
|
2
|
+
|
3
|
+
## Install
|
4
|
+
|
5
|
+
### Bundler: `gem "registrable"`
|
6
|
+
|
7
|
+
### RubyGems: `gem install registrable`
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```rb
|
12
|
+
<%= file('examples/role.rb') %>
|
13
|
+
```
|
14
|
+
|
15
|
+
```rb
|
16
|
+
admin = User.new(:admin)
|
17
|
+
p admin.role.modify? unless ENV["RSPEC"] # => true
|
18
|
+
```
|
19
|
+
|
20
|
+
## Development
|
21
|
+
|
22
|
+
* `bin/setup` to install dependencies
|
23
|
+
* `bin/console` for an interactive prompt
|
24
|
+
* `bin/rake -T` to run view tasks
|
25
|
+
* `bin/rake test` to test
|
26
|
+
* `bin/rake lint` to lint
|
27
|
+
* `bin/rake docs` to generate documentation
|
28
|
+
* `bin/rake install` to install this gem onto your machine
|
29
|
+
* `bin/rake` to test, lint, and generate documentation
|
30
|
+
* To release a new version
|
31
|
+
* `bin/rake version:bump`
|
32
|
+
* `bin/rake release` to create a git tag for the version, push git commits and tags, and push the gem to [rubygems.org](https://rubygems.org).
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/RyanScottLewis/striker.
|
37
|
+
|
38
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
metadata
ADDED
@@ -0,0 +1,206 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: registrable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Scott Lewis
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fuubar
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard-rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.48'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.48'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: version
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: yard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.9'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.9'
|
153
|
+
description: Extend in a class to allow it to hold a registry of it's instances
|
154
|
+
email:
|
155
|
+
- ryanscottlewis@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- ".rspec"
|
162
|
+
- ".rubocop.yml"
|
163
|
+
- ".yardopts"
|
164
|
+
- CODE_OF_CONDUCT.md
|
165
|
+
- Gemfile
|
166
|
+
- Guardfile
|
167
|
+
- LICENSE.txt
|
168
|
+
- README.md
|
169
|
+
- Rakefile
|
170
|
+
- VERSION
|
171
|
+
- bin/console
|
172
|
+
- bin/guard
|
173
|
+
- bin/rake
|
174
|
+
- bin/rspec
|
175
|
+
- bin/setup
|
176
|
+
- examples/plugin.rb
|
177
|
+
- examples/role.rb
|
178
|
+
- lib/registrable.rb
|
179
|
+
- lib/registrable/version.rb
|
180
|
+
- registrable.gemspec
|
181
|
+
- templates/README.md.erb
|
182
|
+
homepage: https://github.com/RyanScottLewis/registrable
|
183
|
+
licenses:
|
184
|
+
- MIT
|
185
|
+
metadata: {}
|
186
|
+
post_install_message:
|
187
|
+
rdoc_options: []
|
188
|
+
require_paths:
|
189
|
+
- lib
|
190
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - ">="
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
requirements: []
|
201
|
+
rubyforge_project:
|
202
|
+
rubygems_version: 2.6.11
|
203
|
+
signing_key:
|
204
|
+
specification_version: 4
|
205
|
+
summary: Allows a class to hold a registry of it's instances
|
206
|
+
test_files: []
|