ns-options 1.0.0.rc1 → 1.0.0.rc2
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.
- data/lib/ns-options/proxy.rb +45 -25
- data/lib/ns-options/version.rb +1 -1
- data/ns-options.gemspec +4 -3
- data/test/support/proxy.rb +4 -0
- data/test/unit/proxy_tests.rb +16 -11
- metadata +11 -9
data/lib/ns-options/proxy.rb
CHANGED
@@ -12,37 +12,50 @@ module NsOptions::Proxy
|
|
12
12
|
def self.included(receiver)
|
13
13
|
NsOptions::RootMethods.new(receiver, NAMESPACE).define
|
14
14
|
receiver.class_eval { extend ProxyMethods }
|
15
|
-
receiver.class_eval { include ProxyMethods } if receiver.kind_of?(Class)
|
16
15
|
|
17
16
|
if receiver.kind_of?(Class)
|
18
|
-
receiver.class_eval do
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
18
|
+
receiver.class_eval { include ProxyMethods }
|
19
|
+
receiver.class_eval { extend ClassReceiverExtendMethods }
|
20
|
+
receiver.class_eval { include ClassReceiverIncludeMethods }
|
24
21
|
|
25
|
-
|
26
|
-
def initialize(configs=nil)
|
27
|
-
self.apply(configs || {})
|
28
|
-
end
|
22
|
+
else # Module
|
29
23
|
|
30
|
-
|
31
|
-
def ==(other_proxy_instance)
|
32
|
-
__proxy_options__ == other_proxy_instance.__proxy_options__
|
33
|
-
end
|
24
|
+
receiver.class_eval { extend ModuleReceiverExtendMethods }
|
34
25
|
|
35
|
-
|
36
|
-
|
37
|
-
receiver.class_eval do
|
26
|
+
end
|
27
|
+
end
|
38
28
|
|
39
|
-
|
40
|
-
def self.new(configs=nil)
|
41
|
-
self.apply(configs || {})
|
42
|
-
end
|
29
|
+
module ClassReceiverExtendMethods
|
43
30
|
|
44
|
-
|
31
|
+
# This hook copies the proxy definition to any subclasses
|
32
|
+
def inherited(subclass)
|
33
|
+
subclass.__proxy_options__.build_from(self.__proxy_options__)
|
45
34
|
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
module ClassReceiverIncludeMethods
|
39
|
+
|
40
|
+
# default initializer method
|
41
|
+
def initialize(configs=nil)
|
42
|
+
self.apply(configs || {})
|
43
|
+
end
|
44
|
+
|
45
|
+
# equality method override for class-instance proxies
|
46
|
+
def ==(other_proxy_instance)
|
47
|
+
__proxy_options__ == other_proxy_instance.__proxy_options__
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
module ModuleReceiverExtendMethods
|
53
|
+
|
54
|
+
# default initializer method
|
55
|
+
def new(configs=nil)
|
56
|
+
self.apply(configs || {})
|
57
|
+
end
|
58
|
+
|
46
59
|
end
|
47
60
|
|
48
61
|
module ProxyMethods
|
@@ -61,14 +74,21 @@ module NsOptions::Proxy
|
|
61
74
|
end
|
62
75
|
alias_method :ns, :namespace
|
63
76
|
|
77
|
+
def option_type_class(*args, &block)
|
78
|
+
__proxy_options__.option_type_class(*args, &block)
|
79
|
+
end
|
80
|
+
alias_method :opt_type_class, :option_type_class
|
81
|
+
|
82
|
+
def has_option?(*args, &block); __proxy_options__.has_option?(*args, &block); end
|
83
|
+
def has_namespace?(*args, &block); __proxy_options__.has_namespace?(*args, &block); end
|
84
|
+
def required_set?(*args, &block); __proxy_options__.required_set?(*args, &block); end
|
85
|
+
def valid?(*args, &block); __proxy_options__.valid?(*args, &block); end
|
86
|
+
|
64
87
|
def apply(*args, &block); __proxy_options__.apply(*args, &block); end
|
65
88
|
def to_hash(*args, &block); __proxy_options__.to_hash(*args, &block); end
|
66
89
|
def each(*args, &block); __proxy_options__.each(*args, &block); end
|
67
90
|
def define(*args, &block); __proxy_options__.define(*args, &block); end
|
68
91
|
|
69
|
-
def required_set?(*args, &block); __proxy_options__.required_set?(*args, &block); end
|
70
|
-
def valid?(*args, &block); __proxy_options__.valid?(*args, &block); end
|
71
|
-
|
72
92
|
def inspect(*args, &block)
|
73
93
|
"#<#{self.class}:#{'0x%x' % (self.object_id << 1)}:#{__proxy_options__.__name__} #{__proxy_options__.to_hash.inspect}>"
|
74
94
|
end
|
data/lib/ns-options/version.rb
CHANGED
data/ns-options.gemspec
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
require File.expand_path('../lib/ns-options/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Collin Redding"]
|
6
|
-
gem.email = ["collin.redding@
|
5
|
+
gem.authors = ["Collin Redding", "Kelly Redding"]
|
6
|
+
gem.email = ["collin.redding@me.com", "kelly@kellyredding.com"]
|
7
7
|
gem.description = %q{A DSL for defining, organizing and accessing options.}
|
8
8
|
gem.summary = %q{A DSL for defining, organizing and accessing options.}
|
9
|
+
gem.homepage = "https://github.com/redding/ns-options"
|
9
10
|
|
10
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
11
12
|
gem.files = `git ls-files`.split("\n")
|
@@ -14,5 +15,5 @@ Gem::Specification.new do |gem|
|
|
14
15
|
gem.require_paths = ["lib"]
|
15
16
|
gem.version = NsOptions::VERSION
|
16
17
|
|
17
|
-
gem.add_development_dependency("assert", ["~>0
|
18
|
+
gem.add_development_dependency("assert", ["~>1.0"])
|
18
19
|
end
|
data/test/support/proxy.rb
CHANGED
data/test/unit/proxy_tests.rb
CHANGED
@@ -13,17 +13,22 @@ module NsOptions::Proxy
|
|
13
13
|
end
|
14
14
|
|
15
15
|
should "respond to proxied namespace methods" do
|
16
|
-
assert_respond_to :option,
|
17
|
-
assert_respond_to :opt,
|
18
|
-
assert_respond_to :
|
19
|
-
assert_respond_to :
|
20
|
-
assert_respond_to :
|
21
|
-
assert_respond_to :
|
22
|
-
assert_respond_to :
|
23
|
-
assert_respond_to :
|
24
|
-
assert_respond_to :
|
25
|
-
assert_respond_to :
|
26
|
-
assert_respond_to :
|
16
|
+
assert_respond_to :option, subject
|
17
|
+
assert_respond_to :opt, subject
|
18
|
+
assert_respond_to :option_type_class, subject
|
19
|
+
assert_respond_to :opt_type_class, subject
|
20
|
+
assert_respond_to :namespace, subject
|
21
|
+
assert_respond_to :ns, subject
|
22
|
+
assert_respond_to :apply, subject
|
23
|
+
assert_respond_to :to_hash, subject
|
24
|
+
assert_respond_to :each, subject
|
25
|
+
assert_respond_to :define, subject
|
26
|
+
assert_respond_to :inspect, subject
|
27
|
+
assert_respond_to :has_option?, subject
|
28
|
+
assert_respond_to :has_namespace?, subject
|
29
|
+
assert_respond_to :required_set?, subject
|
30
|
+
assert_respond_to :valid?, subject
|
31
|
+
assert_respond_to :__data__, subject
|
27
32
|
end
|
28
33
|
|
29
34
|
should "create options directly" do
|
metadata
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ns-options
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -
|
4
|
+
hash: -3815139810
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 1.0.0.
|
11
|
+
- 2
|
12
|
+
version: 1.0.0.rc2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Collin Redding
|
16
|
+
- Kelly Redding
|
16
17
|
autorequire:
|
17
18
|
bindir: bin
|
18
19
|
cert_chain: []
|
19
20
|
|
20
|
-
date: 2012-11-
|
21
|
+
date: 2012-11-28 00:00:00 Z
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
24
|
name: assert
|
@@ -26,17 +27,18 @@ dependencies:
|
|
26
27
|
requirements:
|
27
28
|
- - ~>
|
28
29
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
30
|
+
hash: 15
|
30
31
|
segments:
|
32
|
+
- 1
|
31
33
|
- 0
|
32
|
-
|
33
|
-
version: "0.8"
|
34
|
+
version: "1.0"
|
34
35
|
type: :development
|
35
36
|
requirement: *id001
|
36
37
|
prerelease: false
|
37
38
|
description: A DSL for defining, organizing and accessing options.
|
38
39
|
email:
|
39
|
-
- collin.redding@
|
40
|
+
- collin.redding@me.com
|
41
|
+
- kelly@kellyredding.com
|
40
42
|
executables: []
|
41
43
|
|
42
44
|
extensions: []
|
@@ -85,7 +87,7 @@ files:
|
|
85
87
|
- test/unit/proxy_method_tests.rb
|
86
88
|
- test/unit/proxy_tests.rb
|
87
89
|
- test/unit/root_methods_tests.rb
|
88
|
-
homepage:
|
90
|
+
homepage: https://github.com/redding/ns-options
|
89
91
|
licenses: []
|
90
92
|
|
91
93
|
post_install_message:
|