thor-addons 0.1.3 → 0.1.4

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: fe504337d71eb421b7e686edcaaf999deafb7628
4
- data.tar.gz: 6289a2a15f4d44a9e69680834f8fffc4b9a7c7c3
3
+ metadata.gz: ecbce51975324beec95b2ec8bbd5c4a0d7272beb
4
+ data.tar.gz: 65ff6886d60b046be49187208c4f53b2f1608827
5
5
  SHA512:
6
- metadata.gz: a7c1f13322c537f4302ece4d3b051ba4bd1e6d5edb1e1be3a7f4dd2c6f68a0c02db6073f39e44b519caad44560112ade00fdfdc902a5d60b92a6a8af6a0ef337
7
- data.tar.gz: ba538f94df0b4df7ef4f781eccdb5c89f912a8fd2b4ba2679ee6ebb753e986f21e6b320e07a46c79b53165f68ce18fe0ee3d62f4aca20a047f5fa21d1dea8356
6
+ metadata.gz: cb0497cde13470f94d69ab3b337cfc96aaa0942305992295afcad8ca0a99130668a2f2225b93d92ebe5c6b504bc18299d0d5d4111f7ec1baa056aed7ff633d1f
7
+ data.tar.gz: a7a78ecf49cb710dbdb7629e2f18aebd259ea44af3b57ebb48def44e9886facb0b621266648f99d31753f981c8e4130836a650fd890117e12ad98b0fcea431b3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.1.4 (21/09/2017)
2
+
3
+ BUG FIXES:
4
+
5
+ * Options override #2 ([#4](https://github.com/eredi93/thor-addons/pull/8))
6
+
1
7
  0.1.3 (08/08/2017)
2
8
 
3
9
  BUG FIXES:
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,11 @@
1
+ ### Pull Requests
2
+
3
+ Here are some reasons why a pull request may not be merged:
4
+
5
+ 1. It hasn’t been reviewed.
6
+ 2. It doesn’t include specs for new functionality.
7
+ 3. It doesn’t include documentation for new functionality.
8
+ 4. It changes behavior without changing the relevant documentation, comments, or specs.
9
+ 5. It changes behavior of an existing public API, breaking backward compatibility.
10
+ 6. It breaks the tests on a supported platform.
11
+ 7. It doesn’t merge cleanly (requiring Git rebasing and conflict resolution).
data/README.md CHANGED
@@ -4,3 +4,84 @@
4
4
  [![Gem Version](https://badge.fury.io/rb/thor-addons.svg)](http://badge.fury.io/rb/thor-addons)
5
5
 
6
6
  Extend [Thor](https://github.com/erikhuda/thor) with useful Add-ons
7
+
8
+ ### Installation
9
+
10
+ ```
11
+ gem install thor-addons
12
+ ```
13
+
14
+ ### Usage
15
+
16
+ #### Options
17
+
18
+ The `Options` module allows you to read the CLI options from a configuration file or/and environment variables.
19
+
20
+
21
+ include the Options module to your Thor class.
22
+
23
+ ```
24
+ require 'thor'
25
+ require 'thor_addons'
26
+
27
+ class CLI < Thor
28
+ include ThorAddons::Options
29
+
30
+ class_option :config_file, type: :string, default: "config.yml", desc: "Configuration file for the CLI"
31
+
32
+ method_option :bar, type: :string, default: "biz", desc: "some option"
33
+ desc "foo", "install one of the available apps"
34
+ def foo
35
+ # code
36
+ end
37
+ end
38
+ ```
39
+
40
+ In the example above the `--bar` option will be read from the configuration file `--config-file`
41
+
42
+ ```
43
+ foo:
44
+ bar: "zip"
45
+ ```
46
+
47
+ and via the environment variable `BAR`
48
+
49
+ if you want to disable the configuration file you need to set in your class
50
+
51
+ ```
52
+ def with_config_file?
53
+ false
54
+ end
55
+ ```
56
+
57
+ and for disabling the environment variables
58
+
59
+ ```
60
+ def with_env?
61
+ false
62
+ end
63
+ ```
64
+
65
+ you can also have environment variables aliases, by setting
66
+
67
+ ```
68
+ def envs_aliases
69
+ { "BAR" => "MY_BAR" }
70
+ end
71
+ ```
72
+
73
+ The cli will set bar with the value of `BAR` or `MY_BAR` if `BAR` is not set.
74
+
75
+ This module will set the options in this order: cli options, config file, environment variables
76
+
77
+ ### Contributing
78
+
79
+ If you would like to help, please read the [CONTRIBUTING][] file for suggestions.
80
+
81
+ [contributing]: CONTRIBUTING.md
82
+
83
+ ### License
84
+
85
+ Released under the MIT License. See the [LICENSE][] file for further details.
86
+
87
+ [license]: LICENSE.md
@@ -95,7 +95,7 @@ module ThorAddons
95
95
 
96
96
  def add_defaults(hash)
97
97
  hash.inject({}) do |memo, (k, v)|
98
- memo[k] = v.nil? ? defaults[k] : v
98
+ memo[k] = v.nil? ? defaults[k.to_sym] : v
99
99
 
100
100
  memo
101
101
  end
@@ -103,7 +103,7 @@ module ThorAddons
103
103
 
104
104
  def remove_defaults(hash)
105
105
  hash.inject({}) do |memo, (k, v)|
106
- if defaults[k] == v
106
+ if defaults[k.to_sym] == v
107
107
  memo[k] = nil
108
108
  else
109
109
  memo[k] = v
@@ -1,3 +1,3 @@
1
1
  module ThorAddons
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thor-addons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacopo Scrinzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-08 00:00:00.000000000 Z
11
+ date: 2017-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".travis.yml"
78
78
  - CHANGELOG.md
79
+ - CONTRIBUTING.md
79
80
  - Dockerfile
80
81
  - Gemfile
81
82
  - README.md