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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb571b317a86bb694b31fe6855625a4ba1c09b60
4
- data.tar.gz: 1ed0d7f6e2b6f00408cb822c9646cafa7a380289
3
+ metadata.gz: 451aa0a9196e26ac26df53e01c3612d5235aa515
4
+ data.tar.gz: 6d98daa29a5b3341ed2c37346b6a967a2181913e
5
5
  SHA512:
6
- metadata.gz: 779901e1f14d001f9b8bb86ad71ff0220a0e828314a56f203dd111f41ff73cf87bd49a904114fc218863749ccfa6519a8b811bfeb74147f0ceb60ec09b33ee21
7
- data.tar.gz: 7d38b65431ad13a11ce86ab25bdb973e6d7549bd2ecfc6e99a026235dc35b5e3b59544a0593e0adf497035f6baa64dee630f4a81486f2289e575401e6265c30b
6
+ metadata.gz: a8b0c47ffdcbb48f64ded9aef1a970133238bb26e887d7030b7fafeb59fe4e080c59fef1cc4666d1a1b05227b85468c6f7332e6c75ed61cb467cc7af9bad2c00
7
+ data.tar.gz: 5092720e34d3975d2584b8f9e0de705ab813211b2f648e8837d4e58b44c5085a6497f07d8b9c92ef88b168dd214014fa07fcfd9c1c26f7c1729fabb597d14472
@@ -1,3 +1,9 @@
1
+ # v0.1.0 2014-05-23
2
+
3
+ ## first (announced) public release
4
+
5
+ - Adds a more direct an simple main usage example
6
+
1
7
  # v0.0.3 2014-05-13
2
8
 
3
9
  ## first public release :heartpulse:
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 a `Hashing` module, with a `.hasherize` method like this:
37
+ Given the following class:
38
38
 
39
39
  ```ruby
40
- module Hashing
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
- optioning = Optioning.new values_and_options
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 a `class` `Client` extending the `Hashing` and invoking the `.hasherize`
55
- method like in this example:
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
- require "./hashing"
59
- class Client
60
- extend Hashing
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
- hasherize :some_ivar, to_hash: ->(){}, store: "NO!", persist: "I will persist!"
63
- end
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 following output will be generated:
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/client_maroto.rb:5:in `<class:Client>'.
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/client_maroto.rb:5:in `<class:Client>'.
93
+ Called from examples/file.rb:15:in `export'.
74
94
  ********************************************************************************
75
- #<Proc:0x007fd6f42749a8@examples/client_maroto.rb:5 (lambda)>
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
- The warning messages will be written in the `$stderr`. Done! :smiley:
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
- ### Ignoring unrecongnized options
256
+ ### Unrecongnized options
235
257
 
236
- If you need, you could fitler the options to mantain just the recognized ones
237
- available. To configure the options that matters to your program, use the method
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 and will be ignored.
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'`)
@@ -0,0 +1,3 @@
1
+ # Roadmap
2
+
3
+ * [ ] thread safety
@@ -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
@@ -1,3 +1,3 @@
1
1
  class Optioning
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
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.3
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-14 00:00:00.000000000 Z
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/client_maroto.rb
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
@@ -1,6 +0,0 @@
1
- require_relative "./module_maroto"
2
- class Client
3
- extend Maroto
4
-
5
- hasherize :some_ivar, to_hash: ->(){}, store: "NO!", persist: "I will persist!"
6
- end
@@ -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