cliutils 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +7 -2
- data/README.md +12 -13
- data/lib/cliutils/constants.rb +1 -1
- data/lib/cliutils/{messenging.rb → messaging.rb} +1 -1
- data/lib/cliutils/prefs/pref.rb +2 -2
- data/lib/cliutils/prefs.rb +1 -1
- data/lib/cliutils/pretty_io.rb +2 -2
- data/lib/cliutils.rb +1 -1
- data/test/messenging_test.rb +3 -3
- 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: eb6abdf9f2796a668951e2178193ebfa1110b5bf
|
4
|
+
data.tar.gz: 6216f1699daa43bbd541d5c27037278000455b16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4283a18fa302cd1c59aee7d376da17930555b5362f46fda1fe6cb8853ea62ac417e129afc0ef97776c35cc1073678b37e7f88e862d4c05c74770015a8722d62b
|
7
|
+
data.tar.gz: 807478504596067deb636925a4d04a335abac239f775edd4079ac27efe784dd604412d94b24d564ae28190d35a6ba7b1cb8bf1e856fcc4ac86b43e0225d5e228
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 1.2.8 (2014-04-08)
|
2
|
+
|
3
|
+
* Global name changes
|
4
|
+
* Some cleanup
|
5
|
+
|
1
6
|
# 1.2.7 (2014-04-08)
|
2
7
|
|
3
8
|
* Added more Behaviors
|
@@ -46,7 +51,7 @@
|
|
46
51
|
|
47
52
|
# 1.0.7 (2014-03-30)
|
48
53
|
|
49
|
-
* Modified
|
54
|
+
* Modified Messaging targets to be a Hash for easier lookup/deletion
|
50
55
|
|
51
56
|
# 1.0.6 (2014-03-30)
|
52
57
|
|
@@ -55,7 +60,7 @@
|
|
55
60
|
# 1.0.5 (2014-03-30)
|
56
61
|
|
57
62
|
* Fixed a bug with Configuration singleton
|
58
|
-
* Fixed a bug with
|
63
|
+
* Fixed a bug with Messaging singleton
|
59
64
|
|
60
65
|
# 1.0.4 (2014-03-29)
|
61
66
|
|
data/README.md
CHANGED
@@ -54,19 +54,19 @@ Note that although this README.md is extensive, it may not cover all methods. Ch
|
|
54
54
|
CLIUtils offers:
|
55
55
|
|
56
56
|
* [PrettyIO](#prettyio): nicer-looking CLI messages
|
57
|
-
* [
|
57
|
+
* [Messaging](#messaging): a system to display nicely-formatted messages to one or more tagets
|
58
58
|
* [Configuration](#configuration): a app configuration manager
|
59
59
|
* [Prefs](#prefs): a preferences prompter and manager
|
60
60
|
|
61
61
|
## PrettyIO
|
62
62
|
|
63
|
-
First stop on our journey is better client IO
|
63
|
+
First stop on our journey is better client IO via `PrettyIO`. To activate, simply mix into your project:
|
64
64
|
|
65
65
|
```ruby
|
66
66
|
include CLIUtils::PrettyIO
|
67
67
|
```
|
68
68
|
|
69
|
-
PrettyIO affords you colorized strings:
|
69
|
+
To start, `PrettyIO` affords you colorized strings:
|
70
70
|
|
71
71
|
```ruby
|
72
72
|
puts 'A sample string'.red
|
@@ -92,29 +92,29 @@ puts 'A sample string'.colorize('35;42')
|
|
92
92
|
```
|
93
93
|
![alt text](https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prettyio-gnarly-text.png "Complex Colored Text via PrettyIO")
|
94
94
|
|
95
|
-
Naturally, memorizing the ANSI color scheme is a pain, so PrettyIO gives you a convenient method to look up these color combinations:
|
95
|
+
Naturally, memorizing the ANSI color scheme is a pain, so `PrettyIO` gives you a convenient method to look up these color combinations:
|
96
96
|
|
97
97
|
```ruby
|
98
98
|
color_chart
|
99
99
|
```
|
100
100
|
![alt text](https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prettyio-color-chart.png "PrettyIO Color Chart")
|
101
101
|
|
102
|
-
##
|
102
|
+
## Messaging
|
103
103
|
|
104
|
-
Throughout the life of your application, you will most likely want to send several messages to your user (warnings, errors, info, etc.).
|
104
|
+
Throughout the life of your application, you will most likely want to send several messages to your user (warnings, errors, info, etc.). `Messaging` makes this a snap. It, too, is a mixin:
|
105
105
|
|
106
106
|
```ruby
|
107
|
-
include CLIUtils::
|
107
|
+
include CLIUtils::Messaging
|
108
108
|
```
|
109
109
|
|
110
|
-
Once mixed in, you get access to `messenger`, a type of Logger that uses PrettyIO to send nicely-formatted messages to your user. For example, if you'd like to warn your user:
|
110
|
+
Once mixed in, you get access to `messenger`, a type of Logger that uses `PrettyIO` to send nicely-formatted messages to your user. For example, if you'd like to warn your user:
|
111
111
|
|
112
112
|
```ruby
|
113
113
|
messenger.warn('Hey pal, you need to be careful.')
|
114
114
|
```
|
115
115
|
![alt text](https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/messenger-warn.png "A Warning from Messenger")
|
116
116
|
|
117
|
-
###
|
117
|
+
### Messaging Methods
|
118
118
|
|
119
119
|
`messenger` gives you access to several basic methods:
|
120
120
|
|
@@ -145,7 +145,7 @@ messenger.info_block('Starting up...', 'Done!', multiline = false) { # do stuff
|
|
145
145
|
|
146
146
|
### Message Wrapping
|
147
147
|
|
148
|
-
PrettyIO also gives `messenger` the ability to wrap your messages so that they don't span off into infinity. You can even control what the wrap limit (in characters) is:
|
148
|
+
`PrettyIO` also gives `messenger` the ability to wrap your messages so that they don't span off into infinity. You can even control what the wrap limit (in characters) is:
|
149
149
|
|
150
150
|
```Ruby
|
151
151
|
CLIUtils::PrettyIO.wrap_char_limit = 50
|
@@ -169,11 +169,11 @@ messenger.info("You answered: #{ p }")
|
|
169
169
|
```
|
170
170
|
![alt text](https://raw.githubusercontent.com/bachya/cli-utils/master/res/readme-images/prompting.png "Prompting")
|
171
171
|
|
172
|
-
When you pass a default to `
|
172
|
+
When you pass a default to `messaging.prompt`, hitting `Enter` (i.e., leaving the prompt blank) will return the value of the default.
|
173
173
|
|
174
174
|
### Logging
|
175
175
|
|
176
|
-
Often, it's desirable to log messages as they appear to your user. `
|
176
|
+
Often, it's desirable to log messages as they appear to your user. `messaging` makes this a breeze by allowing you to attach and detach Logger instances at will.
|
177
177
|
|
178
178
|
For instance, let's say you wanted to log a few messages to both your user's STDOUT and to `file.txt`:
|
179
179
|
|
@@ -502,7 +502,6 @@ prefs.ask
|
|
502
502
|
|
503
503
|
```YAML
|
504
504
|
validators:
|
505
|
-
- numeric # Must be a number
|
506
505
|
- alphabetic # Must be made up of letters and spaces
|
507
506
|
- alphanumeric # Must be made up of letters, numbers, and spaces
|
508
507
|
- date # Must be a parsable date (e.g., 2014-04-03)
|
data/lib/cliutils/constants.rb
CHANGED
data/lib/cliutils/prefs/pref.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'cliutils/
|
1
|
+
require 'cliutils/messaging'
|
2
2
|
require 'cliutils/prefs/pref_behavior'
|
3
3
|
require 'cliutils/prefs/pref_validation'
|
4
4
|
|
@@ -6,7 +6,7 @@ module CLIUtils
|
|
6
6
|
# Pref Class
|
7
7
|
# An individual preference
|
8
8
|
class Pref
|
9
|
-
include
|
9
|
+
include Messaging
|
10
10
|
|
11
11
|
# Stores the answer to this Pref.
|
12
12
|
# @return [String, Symbol]
|
data/lib/cliutils/prefs.rb
CHANGED
@@ -5,7 +5,7 @@ module CLIUtils
|
|
5
5
|
# Engine to derive preferences from a YAML file, deliver
|
6
6
|
# those to a user via a prompt, and collect the results.
|
7
7
|
class Prefs
|
8
|
-
include
|
8
|
+
include Messaging
|
9
9
|
# Stores the filepath (if it exists) to the prefs file.
|
10
10
|
# @return [String]
|
11
11
|
attr_reader :config_path
|
data/lib/cliutils/pretty_io.rb
CHANGED
@@ -48,7 +48,7 @@ module CLIUtils
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
# Empty method so that
|
51
|
+
# Empty method so that Messaging doesn't freak
|
52
52
|
# out when passed a debug message.
|
53
53
|
# @return [void]
|
54
54
|
def debug(m); end
|
@@ -93,7 +93,7 @@ module CLIUtils
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
# Empty method so that
|
96
|
+
# Empty method so that Messaging doesn't freak
|
97
97
|
# out when passed a debug message.
|
98
98
|
# @return [void]
|
99
99
|
def log(m); end
|
data/lib/cliutils.rb
CHANGED
data/test/messenging_test.rb
CHANGED
@@ -4,11 +4,11 @@ require 'test/unit'
|
|
4
4
|
require File.join(File.dirname(__FILE__), '..', 'lib/cliutils/ext/string_extensions')
|
5
5
|
require File.join(File.dirname(__FILE__), '..', 'lib/cliutils/pretty_io')
|
6
6
|
require File.join(File.dirname(__FILE__), '..', 'lib/cliutils/logger_delegator')
|
7
|
-
require File.join(File.dirname(__FILE__), '..', 'lib/cliutils/
|
7
|
+
require File.join(File.dirname(__FILE__), '..', 'lib/cliutils/messaging')
|
8
8
|
|
9
9
|
# Tests for the Hash extension methods
|
10
|
-
class
|
11
|
-
include CLIUtils::
|
10
|
+
class TestMessaging < Test::Unit::TestCase
|
11
|
+
include CLIUtils::Messaging
|
12
12
|
|
13
13
|
def setup
|
14
14
|
@file1path = '/tmp/file1.txt'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cliutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Bach
|
@@ -91,7 +91,7 @@ files:
|
|
91
91
|
- lib/cliutils/ext/logger_extensions.rb
|
92
92
|
- lib/cliutils/ext/string_extensions.rb
|
93
93
|
- lib/cliutils/logger_delegator.rb
|
94
|
-
- lib/cliutils/
|
94
|
+
- lib/cliutils/messaging.rb
|
95
95
|
- lib/cliutils/prefs.rb
|
96
96
|
- lib/cliutils/prefs/pref.rb
|
97
97
|
- lib/cliutils/prefs/pref_behavior.rb
|