optioning 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +52 -27
- data/ROADMAP.md +3 -0
- data/examples/file.rb +38 -0
- data/lib/optioning/version.rb +1 -1
- metadata +4 -4
- data/examples/client_maroto.rb +0 -6
- data/examples/module_maroto.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 451aa0a9196e26ac26df53e01c3612d5235aa515
|
4
|
+
data.tar.gz: 6d98daa29a5b3341ed2c37346b6a967a2181913e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8b0c47ffdcbb48f64ded9aef1a970133238bb26e887d7030b7fafeb59fe4e080c59fef1cc4666d1a1b05227b85468c6f7332e6c75ed61cb467cc7af9bad2c00
|
7
|
+
data.tar.gz: 5092720e34d3975d2584b8f9e0de705ab813211b2f648e8837d4e58b44c5085a6497f07d8b9c92ef88b168dd214014fa07fcfd9c1c26f7c1729fabb597d14472
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -34,49 +34,71 @@ Or install it yourself as:
|
|
34
34
|
|
35
35
|
### An "end to end" example
|
36
36
|
|
37
|
-
Given
|
37
|
+
Given the following class:
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
|
40
|
+
require 'optioning'
|
41
|
+
|
42
|
+
class FileExample
|
43
|
+
def initialize(path, commit, content)
|
44
|
+
@content = content
|
45
|
+
@path, @commit = path, commit
|
46
|
+
end
|
47
|
+
|
48
|
+
def export
|
49
|
+
hasherize :path, :commit,
|
50
|
+
to_hash: ->(){},
|
51
|
+
store: "NO!",
|
52
|
+
persist: "I will persist!"
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
41
57
|
def hasherize(*values_and_options)
|
42
|
-
|
43
|
-
optioning.deprecate :to_hash, :to, "v2.0.0"
|
44
|
-
optioning.recognize :persist
|
45
|
-
optioning.process caller
|
46
|
-
|
47
|
-
puts "*" * 80
|
48
|
-
puts optioning.on :to
|
49
|
-
puts optioning.on :persist
|
58
|
+
# ...
|
50
59
|
end
|
51
60
|
end
|
52
61
|
```
|
53
62
|
|
54
|
-
And
|
55
|
-
|
63
|
+
And the following implementation of the private method `#hasherize`, which uses
|
64
|
+
`Optioning` to retrieve the arguments and options passed to it:
|
56
65
|
|
57
66
|
```ruby
|
58
|
-
|
59
|
-
|
60
|
-
|
67
|
+
optioning = Optioning.new values_and_options
|
68
|
+
optioning.deprecate :to_hash, :to, "v2.0.0"
|
69
|
+
optioning.recognize :persist
|
70
|
+
optioning.process caller
|
71
|
+
|
72
|
+
puts "\n#{'*'* 80}"
|
73
|
+
puts "I should export the follow ivars: #{optioning.values}"
|
74
|
+
puts optioning.on :to
|
75
|
+
puts optioning.on :persist
|
76
|
+
puts optioning.on :store
|
77
|
+
```
|
61
78
|
|
62
|
-
|
63
|
-
|
79
|
+
If you call the `#export` method in an instance of `FileExample` like this:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
file = FileExample.new('/some/file.rb', 'cfe9aacbc02528b', '#omg! such file!')
|
83
|
+
file.export
|
64
84
|
```
|
65
85
|
|
66
|
-
The
|
86
|
+
The result will be:
|
67
87
|
|
68
88
|
```
|
69
89
|
NOTE: option `:to_hash` is deprecated; use `:to` instead. It will be removed on or after version v2.0.0.
|
70
|
-
Called from examples/
|
90
|
+
Called from examples/file.rb:15:in `export'.
|
71
91
|
NOTE: unrecognized option `:store` used.
|
72
92
|
You should use only the following: `:to`, `:persist`
|
73
|
-
Called from examples/
|
93
|
+
Called from examples/file.rb:15:in `export'.
|
74
94
|
********************************************************************************
|
75
|
-
|
95
|
+
I should export the follow ivars: [:path, :commit]
|
96
|
+
#<Proc:0x007fa9658631a0@examples/file.rb:16 (lambda)>
|
76
97
|
I will persist!
|
98
|
+
NO!
|
77
99
|
```
|
78
100
|
|
79
|
-
|
101
|
+
To play with this example go to the file `examples\file.rb` in this project.
|
80
102
|
|
81
103
|
### A more step by step example
|
82
104
|
|
@@ -231,11 +253,10 @@ warning will be exhibited.
|
|
231
253
|
* [ ] maybe we should allow a deprecation strategy? To choose between warning
|
232
254
|
or exception when a deprecated options is called?
|
233
255
|
|
234
|
-
###
|
256
|
+
### Unrecongnized options
|
235
257
|
|
236
|
-
|
237
|
-
|
238
|
-
`#recognize`. And to warn the user in case a unrecognized option is used, call
|
258
|
+
To configure the options that matters to your program, use the method
|
259
|
+
`#recognize`. And to warn the user in case an unrecognized option is used, call
|
239
260
|
the `#unrecognized_warn` method:
|
240
261
|
|
241
262
|
```ruby
|
@@ -249,7 +270,7 @@ end
|
|
249
270
|
```
|
250
271
|
|
251
272
|
Now, if a user pass an option different than the `:from` one, a warning will
|
252
|
-
inform that the option is not recognized
|
273
|
+
inform that the option is not recognized.
|
253
274
|
|
254
275
|
#### Do I Need to register deprecated options as recognized?
|
255
276
|
|
@@ -312,6 +333,10 @@ end
|
|
312
333
|
|
313
334
|
## Contributing
|
314
335
|
|
336
|
+
This is a rapid "scratch your own itch" kind of project. It will make me really happy if it can be used used in your software anyhow. If you need something different than what is in it, or can solve us some bugs or add documentation, it will be very well received!
|
337
|
+
|
338
|
+
Here is how you can help this gem:
|
339
|
+
|
315
340
|
1. Fork it ( http://github.com/ricardovaleriano/optioning/fork )
|
316
341
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
317
342
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
data/ROADMAP.md
ADDED
data/examples/file.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
begin
|
2
|
+
require "optioning"
|
3
|
+
rescue LoadError
|
4
|
+
$:.unshift File.expand_path "../../lib", __FILE__
|
5
|
+
require "optioning"
|
6
|
+
end
|
7
|
+
|
8
|
+
class FileExample
|
9
|
+
def initialize(path, commit, content)
|
10
|
+
@content = content
|
11
|
+
@path, @commit = path, commit
|
12
|
+
end
|
13
|
+
|
14
|
+
def export
|
15
|
+
hasherize :path, :commit,
|
16
|
+
to_hash: ->(){},
|
17
|
+
store: "NO!",
|
18
|
+
persist: "I will persist!"
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def hasherize(*values_and_options)
|
24
|
+
optioning = Optioning.new values_and_options
|
25
|
+
optioning.deprecate :to_hash, :to, "v2.0.0"
|
26
|
+
optioning.recognize :persist
|
27
|
+
optioning.process caller
|
28
|
+
|
29
|
+
puts "\n#{'*'* 80}"
|
30
|
+
puts "I should export the follow ivars: #{optioning.values}"
|
31
|
+
puts optioning.on :to
|
32
|
+
puts optioning.on :persist
|
33
|
+
puts optioning.on :store
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
file = FileExample.new('/some/file.rb', 'cfe9aacbc02528b', '#omg! such file!')
|
38
|
+
file.export
|
data/lib/optioning/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Valeriano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,9 +67,9 @@ files:
|
|
67
67
|
- Gemfile
|
68
68
|
- LICENSE.txt
|
69
69
|
- README.md
|
70
|
+
- ROADMAP.md
|
70
71
|
- Rakefile
|
71
|
-
- examples/
|
72
|
-
- examples/module_maroto.rb
|
72
|
+
- examples/file.rb
|
73
73
|
- lib/deprecation.rb
|
74
74
|
- lib/optioning.rb
|
75
75
|
- lib/optioning/version.rb
|
data/examples/client_maroto.rb
DELETED
data/examples/module_maroto.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require "optioning"
|
3
|
-
rescue LoadError => e
|
4
|
-
$:.unshift File.expand_path "../../lib", __FILE__
|
5
|
-
require "optioning"
|
6
|
-
end
|
7
|
-
|
8
|
-
module Maroto
|
9
|
-
def hasherize(*values_and_options)
|
10
|
-
optioning = Optioning.new values_and_options
|
11
|
-
optioning.deprecate :to_hash, :to, "v2.0.0"
|
12
|
-
optioning.recognize :persist
|
13
|
-
optioning.process caller
|
14
|
-
|
15
|
-
puts "\n"
|
16
|
-
puts "*" * 80
|
17
|
-
puts optioning.on :to
|
18
|
-
puts optioning.on :persist
|
19
|
-
end
|
20
|
-
end
|