enumerated_constants 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/enumerated_constants.gemspec +1 -3
- data/lib/enumerated_constants.rb +21 -26
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41eefc3bab200e4812f343a2000fdd0037b5946d
|
4
|
+
data.tar.gz: db4506a7ab410cf7c504443b9b67ed3639dcbcf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07b2161d15ed11749f517c90e96c529ffe756a60c3a34f7c6f26af15ecb82eef425988bbf01240fa22581c13b6665ea09f0a4def218fb760923b314925d1883d
|
7
|
+
data.tar.gz: 9849cc5863726741643eb56f1a86c37291c9a9742feb374dd3a7cf21775f7e710a31390644ab221ee5de09f808ea7678b6624b6c7a41c5e63aba7d7d2560d00d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -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.
|
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"
|
data/lib/enumerated_constants.rb
CHANGED
@@ -1,33 +1,28 @@
|
|
1
|
-
require '
|
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
|
4
|
+
extend Forwardable
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
12
|
+
def_delegators :all, :each, :include?, :map, :sample, :sort
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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.
|
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
|