cliutils 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +4 -0
- data/README.md +3 -3
- data/lib/cliutils/constants.rb +1 -1
- data/lib/cliutils/prefs/pref.rb +8 -2
- data/lib/cliutils.rb +1 -0
- data/test/test_files/prefstest.yaml +9 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddb5768ab33a8de3393fe8d19625bb3d1ab87b60
|
4
|
+
data.tar.gz: 28a8ccae4a718c603e65905076aa5504f80cbb25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8740a598f151bca94187d3849a09dad0836329399dcc8a5d0bdadad81bc16e271ac9e4cf19e11f69b413ce2248fb4ab5d95e5e23bf38eb9e043999ab928a9e4
|
7
|
+
data.tar.gz: bfbaeae9fc960d04abc8fe38712fa1ff82fabc7e492b6553ef81091ec24594d19d832c4476bb8cb6e5d4617800ae32074ebd15efea294a6d8b4fc92597068166
|
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -612,7 +612,7 @@ prompts:
|
|
612
612
|
config_section: app_data
|
613
613
|
pre:
|
614
614
|
message: 'I will now open espn.com in your default browser.'
|
615
|
-
action: open_url
|
615
|
+
action: ~/.cliutils_plugins/open_url.rb
|
616
616
|
action_parameters:
|
617
617
|
- url: http://www.espn.com
|
618
618
|
post:
|
@@ -643,10 +643,10 @@ end
|
|
643
643
|
|
644
644
|
Several items to note:
|
645
645
|
|
646
|
-
1. The action class needs to be wrapped in the CLIUtils module.
|
646
|
+
1. The action class needs to be wrapped in the CLIUtils module. In addition to "locking in" the action, this wrapper module gives easier access to PrettyIO, Messaging, etc.
|
647
647
|
2. The class name needs to be the camel-case version of the `action` key in the YAML.
|
648
648
|
3. The class name needs to end with "Action".
|
649
|
-
4. The class needs to inherit from the PrefAction class. This allows
|
649
|
+
4. The class needs to inherit from the PrefAction class. This allows the action to have access to:
|
650
650
|
* `@pref`: the Pref that implemented this action
|
651
651
|
5. The class needs to implement one method: `run(parameters = {})`
|
652
652
|
|
data/lib/cliutils/constants.rb
CHANGED
data/lib/cliutils/prefs/pref.rb
CHANGED
@@ -63,6 +63,8 @@ module CLIUtils
|
|
63
63
|
# @return [void]
|
64
64
|
def initialize(params = {})
|
65
65
|
params.each { |key, value| send("#{ key }=", value) }
|
66
|
+
|
67
|
+
# _load_validators if @validators
|
66
68
|
end
|
67
69
|
|
68
70
|
# Custom equality operator for this class.
|
@@ -84,7 +86,7 @@ module CLIUtils
|
|
84
86
|
# gets evaluated *once*, not every time the
|
85
87
|
# user gets prompted. This prevents multiple
|
86
88
|
# evaluations when bad options are provided.
|
87
|
-
_eval_pre
|
89
|
+
_eval_pre if @pre
|
88
90
|
|
89
91
|
valid_option_chosen = false
|
90
92
|
until valid_option_chosen
|
@@ -92,7 +94,7 @@ module CLIUtils
|
|
92
94
|
if validate(response)
|
93
95
|
valid_option_chosen = true
|
94
96
|
@answer = evaluate_behaviors(response)
|
95
|
-
_eval_post
|
97
|
+
_eval_post if @post
|
96
98
|
else
|
97
99
|
messenger.error(@last_error_message)
|
98
100
|
end
|
@@ -226,5 +228,9 @@ module CLIUtils
|
|
226
228
|
messenger.warn("Skipping undefined Pref Action: #{ path_or_name }")
|
227
229
|
end
|
228
230
|
end
|
231
|
+
|
232
|
+
def _load_validators
|
233
|
+
|
234
|
+
end
|
229
235
|
end
|
230
236
|
end
|
data/lib/cliutils.rb
CHANGED
@@ -11,6 +11,7 @@ require 'cliutils/messaging'
|
|
11
11
|
require 'cliutils/prefs'
|
12
12
|
require 'cliutils/prefs/pref'
|
13
13
|
require 'cliutils/prefs/pref_actions/pref_action'
|
14
|
+
require 'cliutils/prefs/pref_validators/pref_validator'
|
14
15
|
|
15
16
|
# The CLIUtils module, which wraps everything
|
16
17
|
# in this gem.
|
@@ -2,12 +2,13 @@ prompts:
|
|
2
2
|
- prompt_text: What is the top story on espn.com?
|
3
3
|
config_key: top_story
|
4
4
|
config_section: app_data
|
5
|
-
pre:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
post:
|
11
|
-
|
5
|
+
# pre:
|
6
|
+
# message: 'I will now open espn.com in your default browser.'
|
7
|
+
# action: open_url
|
8
|
+
# action_parameters:
|
9
|
+
# - url: http://www.espn.com
|
10
|
+
# post:
|
11
|
+
# message: 'Thanks for inputting!'
|
12
12
|
validators:
|
13
|
-
- non_nil
|
13
|
+
- non_nil
|
14
|
+
- alphabetic
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cliutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Bach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|