optioning 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Gemfile +0 -2
- data/lib/optioning/version.rb +1 -1
- data/lib/optioning.rb +7 -3
- data/test/deprecation_test.rb +9 -32
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Nzc3YjdmYjNjOTYwOGZlMDg0MmRkNWM4ODA4OTI5MjczNGM0MWFiMw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 94cb481fb510629a1b80e3045cd30d438e39948a
|
4
|
+
data.tar.gz: 547c8ac83c7adc704f8899c747623df3a8798e2d
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MTk0NjAwMWFkY2U4ZWYxMjM4MzE1NWM3NWQyOGViZDgyYTNmM2E2ODk0OTRi
|
11
|
-
MjM5YjBmNDg0ZjY0YTJlYjlmN2RlMTg4NzU5NDcwYzkwZGRjMjk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NTA3YWY5MGU3MDQ1MjdhY2UyMzI0MmI0ZjI4ZTk3YTNiODdlNTE1OWM4Yzhj
|
14
|
-
Mjg0YzQ2YzQ4ZjBiZGYzYmYxNmUzYTUxN2YxNWVmYjliYTg4NGNhMjhlOWU5
|
15
|
-
NzUzMjZjOTNlNjY1ZTg4YzJlMWE5MTQxNTQxMDE2MWZkZWIyZTk=
|
6
|
+
metadata.gz: 52b86fd8b12200166e1c83993f6000067a81e09be858da34b9ffe01d92565dc2d9855996ab4375206118c6dfa71353b697c1ff802834bc612583206dcafa94a6
|
7
|
+
data.tar.gz: 0e0ea2c55acac9a4f06568d4e20f89afe395c49321d442969e61fcdf334c049d21c36ebb9db52db16e2d74658a7702700926df9b8e1e65b5561d4c4c5415696e
|
data/Gemfile
CHANGED
data/lib/optioning/version.rb
CHANGED
data/lib/optioning.rb
CHANGED
@@ -135,15 +135,19 @@ class Optioning
|
|
135
135
|
@recognized ||= []
|
136
136
|
end
|
137
137
|
|
138
|
+
def options
|
139
|
+
@options ||= []
|
140
|
+
end
|
141
|
+
|
138
142
|
# Cleanup the options trashing up the deprecated options in favor the
|
139
143
|
# replacements.
|
140
144
|
#
|
141
145
|
# @return [Hash] @options already filtered
|
142
146
|
def replace_deprecations
|
143
147
|
deprecations.each do |deprecation|
|
144
|
-
|
148
|
+
options[deprecation.replacement] = options.delete deprecation.option
|
145
149
|
end
|
146
|
-
|
150
|
+
options
|
147
151
|
end
|
148
152
|
|
149
153
|
# All unrecognized options used as parameter to an {Optioning}
|
@@ -178,6 +182,6 @@ class Optioning
|
|
178
182
|
#
|
179
183
|
# @return [Array<Symbol>] deprecated options used in the construction of a {Optioning}
|
180
184
|
def deprecated_but_used
|
181
|
-
deprecations.map(&:option).select { |option|
|
185
|
+
deprecations.map(&:option).select { |option| options.include? option }
|
182
186
|
end
|
183
187
|
end
|
data/test/deprecation_test.rb
CHANGED
@@ -19,14 +19,8 @@ describe Deprecation do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#warn" do
|
22
|
-
|
23
|
-
deprecation = Deprecation.new :to_hash, :to
|
24
|
-
deprecation.warn.must_be :==, "NOTE: option `:to_hash` is deprecated;"+
|
25
|
-
" use `:to` instead. It will be removed in a future version.\n"
|
26
|
-
end
|
27
|
-
|
22
|
+
let(:deprecation) { Deprecation.new :to_hash, :to, "v2.0.0" }
|
28
23
|
it "returns the message to warn about deprecation" do
|
29
|
-
deprecation = Deprecation.new :to_hash, :to, "v2.0.0"
|
30
24
|
deprecation.warn.must_be :==, "NOTE: option `:to_hash` is deprecated;"+
|
31
25
|
" use `:to` instead. It will be removed on or after version v2.0.0.\n"
|
32
26
|
end
|
@@ -38,7 +32,6 @@ describe Deprecation do
|
|
38
32
|
end
|
39
33
|
|
40
34
|
describe "when caller is available" do
|
41
|
-
let(:deprecation) { Deprecation.new :to_hash, :to, "v2.0.0" }
|
42
35
|
before do
|
43
36
|
deprecation.caller = "/x/p/t/o/omg_lol_bbq.rb:42:in `hasherize'"
|
44
37
|
end
|
@@ -64,29 +57,13 @@ describe Deprecation do
|
|
64
57
|
end
|
65
58
|
|
66
59
|
describe "#deprecation_warn" do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
it "constructs a deprecation message accordingly to the arguments" do
|
77
|
-
optioning.deprecation_warn
|
78
|
-
deprecation = Deprecation.new :to_hash, :to, "v2.0.0"
|
79
|
-
$stderr.string.must_be :==, deprecation.warn
|
80
|
-
end
|
81
|
-
|
82
|
-
it "uses the callee information to compose the warning message" do
|
83
|
-
optioning.deprecation_warn [
|
84
|
-
"examples/client_maroto.rb:5:in `<class:Client>'",
|
85
|
-
"examples/client_maroto.rb:2:in `<main>'"]
|
86
|
-
deprecation = Deprecation.new :to_hash, :to, "v2.0.0"
|
87
|
-
deprecation.caller = "examples/client_maroto.rb:5:in `<class:Client>'"
|
88
|
-
$stderr.string.must_be :==, deprecation.warn
|
89
|
-
end
|
90
|
-
end
|
60
|
+
describe "when there are deprecations configured but no used" do
|
61
|
+
it "doesn't break if last options is not an array" do
|
62
|
+
optioning = Optioning.new [:path, :commit]
|
63
|
+
optioning.deprecate :not_used, :omg
|
64
|
+
optioning.deprecation_warn
|
65
|
+
end
|
66
|
+
end# with deprecations configured
|
67
|
+
end# #deprecation_warn
|
91
68
|
end
|
92
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Valeriano
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -89,23 +89,22 @@ require_paths:
|
|
89
89
|
- lib
|
90
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- -
|
92
|
+
- - '>='
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
|
-
- -
|
97
|
+
- - '>='
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.1.
|
102
|
+
rubygems_version: 2.1.11
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
|
-
summary:
|
105
|
+
summary: 'An object oriented way to treat our beloved last parameter: Hash.'
|
106
106
|
test_files:
|
107
107
|
- test/deprecation_test.rb
|
108
108
|
- test/optioning_test.rb
|
109
109
|
- test/test_helper.rb
|
110
110
|
- test/unrecognized_option_test.rb
|
111
|
-
has_rdoc:
|