enumerated_constants 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44ab6d4867d93badb655b39ecbca2fd3d3d0bb5a
4
- data.tar.gz: 9483db69633e0b8b065ff632354dbd1da2914b38
3
+ metadata.gz: 41eefc3bab200e4812f343a2000fdd0037b5946d
4
+ data.tar.gz: db4506a7ab410cf7c504443b9b67ed3639dcbcf3
5
5
  SHA512:
6
- metadata.gz: 33f0c13df731bbb3ba064fb3f256fa949426a1f92d2338f6f7be7967b9844d3cb1a21458b33cb1688339cdd88f9fa05863486dfd7d7d00d7914811bc9c64adb1
7
- data.tar.gz: 063bf6d0cfed53bb21ae1f2eb081b77039f99d68d5558c26173673f743f636c416564628e134bb85722d60512da918c88b758a5fa74185625281b2c0f0ac4eaa
6
+ metadata.gz: 07b2161d15ed11749f517c90e96c529ffe756a60c3a34f7c6f26af15ecb82eef425988bbf01240fa22581c13b6665ea09f0a4def218fb760923b314925d1883d
7
+ data.tar.gz: 9849cc5863726741643eb56f1a86c37291c9a9742feb374dd3a7cf21775f7e710a31390644ab221ee5de09f808ea7678b6624b6c7a41c5e63aba7d7d2560d00d
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
+ enumerated_constants-*.gem
1
2
  /Gemfile.lock
data/README.md CHANGED
@@ -31,7 +31,7 @@ class User
31
31
  attr_accessor :role
32
32
 
33
33
  module Role
34
- include EnumeratedConstants
34
+ extend EnumeratedConstants
35
35
 
36
36
  ADMIN = 'admin'.freeze
37
37
  MANAGER = 'manager'.freeze
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "enumerated_constants"
7
- spec.version = "0.1.0"
7
+ spec.version = "0.2.0"
8
8
  spec.authors = ["Tom Collier"]
9
9
  spec.email = ["collier@apartmentlist.com"]
10
10
 
@@ -16,8 +16,6 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency "activesupport"
20
-
21
19
  spec.add_development_dependency "bundler", "~> 1.8"
22
20
  spec.add_development_dependency "rake", "~> 10.0"
23
21
  spec.add_development_dependency "rspec"
@@ -1,33 +1,28 @@
1
- require 'active_support/concern'
2
- require 'active_support/core_ext/module/delegation'
3
- require 'active_support/core_ext/object/inclusion'
1
+ require 'forwardable'
4
2
 
5
3
  module EnumeratedConstants
6
- extend ActiveSupport::Concern
4
+ extend Forwardable
7
5
 
8
- # Methods added to the class upon include
9
- module ClassMethods
10
- def all
11
- @all ||= constants.map(&method(:const_get)).delete_if do |constant|
12
- constant == ClassMethods || constant.is_a?(Array)
13
- end.freeze
14
- end
6
+ def all
7
+ @all ||= constants.map(&method(:const_get)).delete_if do |constant|
8
+ constant.is_a?(Array)
9
+ end.freeze
10
+ end
15
11
 
16
- delegate :each, :include?, :map, :sample, :sort, to: :all
12
+ def_delegators :all, :each, :include?, :map, :sample, :sort
17
13
 
18
- # Return all but the constant name you pass
19
- # @param name [Symbol,String] The name of the constant you don't want
20
- # @return [Array] @all except the value of that constant
21
- def except(*names)
22
- const_names =
23
- names = names.map(&:upcase).map(&:to_sym)
24
- values = names.map do |name|
25
- begin
26
- const_get(name)
27
- rescue NameError
28
- end
29
- end.compact
30
- all - values
31
- end
14
+ # Return all but the constant name you pass
15
+ # @param name [Symbol,String] The name of the constant you don't want
16
+ # @return [Array] @all except the value of that constant
17
+ def except(*names)
18
+ const_names =
19
+ names = names.map(&:upcase).map(&:to_sym)
20
+ values = names.map do |name|
21
+ begin
22
+ const_get(name)
23
+ rescue NameError
24
+ end
25
+ end.compact
26
+ all - values
32
27
  end
33
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerated_constants
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Collier
@@ -10,20 +10,6 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2015-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement