cli_miami 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -4
- data/lib/cli_miami/ask.rb +19 -4
- data/lib/cli_miami/say.rb +14 -36
- data/lib/namespaced.rb +27 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b637c3d16bf3a87fed9823000666decbdb874390
|
4
|
+
data.tar.gz: b4eb682f983cf93a600a5d67bb619d79b9020d21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6ee682fead793ce3a8f29d5f6d91160cd8c408786c3be7b4848da9bd42d3919302ecc7c10c0961133e7f9faec54fd4bdccc41d64295c2e35a5d6f0d2cf8e336
|
7
|
+
data.tar.gz: cbd87e672d63ec1b135bfc007ad4f7e15a8ef273b567695c795f448a16f0b2a69b092fda5c32dd61372745a8be01587362612b62a751aa5b925e04281f70a691
|
data/Gemfile.lock
CHANGED
@@ -7,22 +7,26 @@ GEM
|
|
7
7
|
diff-lcs (1.2.5)
|
8
8
|
ffi (1.9.6)
|
9
9
|
formatador (0.2.5)
|
10
|
-
guard (2.10.
|
10
|
+
guard (2.10.5)
|
11
11
|
formatador (>= 0.2.4)
|
12
12
|
listen (~> 2.7)
|
13
13
|
lumberjack (~> 1.0)
|
14
|
+
nenv (~> 0.1)
|
14
15
|
pry (>= 0.9.12)
|
15
16
|
thor (>= 0.18.1)
|
16
|
-
guard-
|
17
|
+
guard-compat (1.2.0)
|
18
|
+
guard-rspec (4.5.0)
|
17
19
|
guard (~> 2.1)
|
18
|
-
|
20
|
+
guard-compat (~> 1.1)
|
21
|
+
rspec (>= 2.99.0, < 4.0)
|
19
22
|
hitimes (1.2.2)
|
20
|
-
listen (2.8.
|
23
|
+
listen (2.8.4)
|
21
24
|
celluloid (>= 0.15.2)
|
22
25
|
rb-fsevent (>= 0.9.3)
|
23
26
|
rb-inotify (>= 0.9)
|
24
27
|
lumberjack (1.0.9)
|
25
28
|
method_source (0.8.2)
|
29
|
+
nenv (0.1.1)
|
26
30
|
pry (0.10.1)
|
27
31
|
coderay (~> 1.1.0)
|
28
32
|
method_source (~> 0.8.1)
|
data/lib/cli_miami/ask.rb
CHANGED
@@ -11,13 +11,26 @@ class CliMiami::A
|
|
11
11
|
# The same options are accepted
|
12
12
|
#
|
13
13
|
def self.sk question, options = {}, &block
|
14
|
-
|
14
|
+
# set default options
|
15
|
+
@options = {
|
15
16
|
:readline => false,
|
16
|
-
}
|
17
|
+
}
|
17
18
|
|
18
|
-
|
19
|
+
# merge preset options
|
20
|
+
if options.is_a? Symbol
|
21
|
+
@options.merge! CliMiami.presets[options]
|
22
|
+
elsif preset = options.delete(:preset)
|
23
|
+
@options.merge! CliMiami.presets[preset]
|
24
|
+
end
|
19
25
|
|
20
|
-
|
26
|
+
# merge remaining options
|
27
|
+
if options.is_a? Hash
|
28
|
+
@options.merge! options
|
29
|
+
end
|
30
|
+
|
31
|
+
CliMiami::S.ay question, @options
|
32
|
+
|
33
|
+
output = if @options[:readline]
|
21
34
|
Readline.readline(@@prompt).chomp('/')
|
22
35
|
else
|
23
36
|
CliMiami::S.ay @@prompt, :newline => false
|
@@ -27,6 +40,8 @@ class CliMiami::A
|
|
27
40
|
yield output if block
|
28
41
|
end
|
29
42
|
|
43
|
+
private
|
44
|
+
|
30
45
|
def self.prompt; @@prompt; end
|
31
46
|
def self.prompt= prompt
|
32
47
|
@@prompt = prompt
|
data/lib/cli_miami/say.rb
CHANGED
@@ -8,27 +8,13 @@ class String
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class CliMiami::S
|
11
|
-
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
:warn => {
|
19
|
-
:color => :yellow,
|
20
|
-
:style => :bold
|
21
|
-
},
|
22
|
-
:success => {
|
23
|
-
:color => :green,
|
24
|
-
:style => :bold
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
# By preset...
|
29
|
-
# [symbol] Uses defined preset
|
30
|
-
|
31
|
-
# By options...
|
11
|
+
#
|
12
|
+
# @param options [Symbol or Hash] options can be preset symbol, or a hash of options.
|
13
|
+
#
|
14
|
+
# By preset [Symbol[...
|
15
|
+
# [symbol] Uses defined preset name
|
16
|
+
#
|
17
|
+
# By options [Hash]...
|
32
18
|
# color: => [symbol] See README for ansi color codes
|
33
19
|
# bgcolor: => [symbol] See README for ansi color codes
|
34
20
|
# style: => [symbol] See README for ansi style codes
|
@@ -38,7 +24,9 @@ class CliMiami::S
|
|
38
24
|
# newline: => [boolean] True if you want a newline after the output
|
39
25
|
# overwrite: => [boolean] True if you want the next line to overwrite the current line
|
40
26
|
#
|
41
|
-
|
27
|
+
# @return
|
28
|
+
#
|
29
|
+
def self.ay text = '', options = {}
|
42
30
|
# set default options
|
43
31
|
@options = {
|
44
32
|
:style => [],
|
@@ -47,14 +35,14 @@ class CliMiami::S
|
|
47
35
|
|
48
36
|
# merge preset options
|
49
37
|
if options.is_a? Symbol
|
50
|
-
@options.merge!
|
38
|
+
@options.merge! CliMiami.presets[options]
|
51
39
|
elsif preset = options.delete(:preset)
|
52
|
-
@options.merge!
|
40
|
+
@options.merge! CliMiami.presets[preset]
|
53
41
|
end
|
54
42
|
|
55
43
|
# merge remaining options
|
56
44
|
if options.is_a? Hash
|
57
|
-
@options.merge! options
|
45
|
+
@options.merge! options
|
58
46
|
end
|
59
47
|
|
60
48
|
# convert single style into an array for processing
|
@@ -103,16 +91,6 @@ class CliMiami::S
|
|
103
91
|
else
|
104
92
|
$stdout.puts text
|
105
93
|
end
|
106
|
-
|
107
|
-
|
108
|
-
# Returns all presets
|
109
|
-
def self.presets
|
110
|
-
@@presets
|
111
|
-
end
|
112
|
-
|
113
|
-
# Create a new custom preset
|
114
|
-
def self.set_preset type, options
|
115
|
-
raise 'Preset must be a hash of options' unless options.is_a? Hash
|
116
|
-
@@presets[type] = options
|
94
|
+
return 'fun!'
|
117
95
|
end
|
118
96
|
end
|
data/lib/namespaced.rb
CHANGED
@@ -3,4 +3,31 @@
|
|
3
3
|
class CliMiami
|
4
4
|
require 'cli_miami/ask'
|
5
5
|
require 'cli_miami/say'
|
6
|
+
|
7
|
+
# default presets
|
8
|
+
@@presets = {
|
9
|
+
:fail => {
|
10
|
+
:color => :red,
|
11
|
+
:style => :bold
|
12
|
+
},
|
13
|
+
:warn => {
|
14
|
+
:color => :yellow,
|
15
|
+
:style => :bold
|
16
|
+
},
|
17
|
+
:success => {
|
18
|
+
:color => :green,
|
19
|
+
:style => :bold
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
# Returns all presets
|
24
|
+
def self.presets
|
25
|
+
@@presets
|
26
|
+
end
|
27
|
+
|
28
|
+
# Create a new custom preset
|
29
|
+
def self.set_preset type, options
|
30
|
+
raise 'Preset must be a hash of options' unless options.is_a? Hash
|
31
|
+
@@presets[type] = options
|
32
|
+
end
|
6
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cli_miami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brewster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|
@@ -118,8 +118,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.2.2
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: A feature rich alternative for `gets` and `puts` for your cli interface
|
125
125
|
test_files: []
|
126
|
+
has_rdoc:
|