yuyi 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.new +1 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +3 -0
- data/README.md +1 -2
- data/lib/yuyi/cli.rb +5 -4
- data/lib/yuyi/core.rb +1 -0
- data/lib/yuyi/dsl.rb +29 -16
- data/lib/yuyi/menu.rb +22 -17
- data/lib/yuyi/roll.rb +6 -5
- data/lib/yuyi/ui.rb +17 -24
- data/spec/lib/yuyi/dsl_spec.rb +0 -10
- data/spec/spec_helper.rb +4 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f54fc12263a3eb78bf1b72db5bc3d08ff8509306
|
4
|
+
data.tar.gz: 43ba00e4b501473bece5e67be9e5d5d33000d845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de8c5bf7eb451d5ea95428f38aef109b6be9036c07f185e710ccb52d5fbbfad4b329950ccf767a3655b1d88f4a6af56cf129b997f0f59f4192d9bb509f89221c
|
7
|
+
data.tar.gz: a70065a9218a8a53ac88d66c5d85a70d60b09eb01c7f16466392ba89e903d9141621da10ef904450b5578546c66a67aa773127ab7449023523b90ba4d1d05139
|
data/.new
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -56,6 +56,7 @@ GEM
|
|
56
56
|
rspec-mocks (3.0.2)
|
57
57
|
rspec-support (~> 3.0.0)
|
58
58
|
rspec-support (3.0.2)
|
59
|
+
ruby-progressbar (1.5.1)
|
59
60
|
semantic (1.3.0)
|
60
61
|
slop (3.5.0)
|
61
62
|
terminal-notifier-guard (1.5.3)
|
@@ -66,10 +67,12 @@ PLATFORMS
|
|
66
67
|
ruby
|
67
68
|
|
68
69
|
DEPENDENCIES
|
70
|
+
colorize
|
69
71
|
guard
|
70
72
|
guard-rspec
|
71
73
|
new
|
72
74
|
rake
|
73
75
|
rspec
|
76
|
+
ruby-progressbar
|
74
77
|
terminal-notifier-guard
|
75
78
|
thor
|
data/README.md
CHANGED
@@ -124,11 +124,10 @@ end
|
|
124
124
|
```
|
125
125
|
|
126
126
|
### TODO
|
127
|
-
* progressbar
|
128
127
|
* vagrant plugins
|
129
128
|
* Enforce required options
|
130
129
|
* New roll generator (use new!)
|
131
|
-
* show roll options on
|
130
|
+
* show roll options on list
|
132
131
|
* installation summary
|
133
132
|
* DOCS!
|
134
133
|
|
data/lib/yuyi/cli.rb
CHANGED
@@ -30,13 +30,14 @@ class Yuyi::Cli < Thor
|
|
30
30
|
end
|
31
31
|
|
32
32
|
desc 'start', 'Run Yuyi'
|
33
|
-
option :verbose, :aliases => '-v', :type => :boolean, :desc => 'Run in verbose mode'
|
34
|
-
option :upgrade, :aliases => '-u', :type => :boolean, :desc => 'Check for upgrades for rolls on the menu that are already installed'
|
33
|
+
option :verbose, :default => false, :aliases => '-v', :type => :boolean, :desc => 'Run in verbose mode'
|
34
|
+
option :upgrade, :default => false, :aliases => '-u', :type => :boolean, :desc => 'Check for upgrades for rolls on the menu that are already installed'
|
35
35
|
option :menu, :aliases => '-m', :desc => 'Path to your menu file'
|
36
36
|
def start
|
37
|
+
puts options.inspect
|
37
38
|
# enable verbose mode if flag is passed
|
38
|
-
Yuyi.verbose =
|
39
|
-
Yuyi.upgrade =
|
39
|
+
Yuyi.verbose = options[:verbose]
|
40
|
+
Yuyi.upgrade = options[:upgrade]
|
40
41
|
Yuyi.menu_path = options[:menu]
|
41
42
|
|
42
43
|
Yuyi.start
|
data/lib/yuyi/core.rb
CHANGED
data/lib/yuyi/dsl.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'colorize'
|
1
2
|
require 'open3'
|
2
3
|
require 'readline'
|
3
4
|
require 'yaml'
|
@@ -9,12 +10,14 @@ module Yuyi::Dsl
|
|
9
10
|
attr_accessor :verbose, :upgrade, :menu_path
|
10
11
|
|
11
12
|
# Replacement for `puts` that accepts various stylistic arguments
|
12
|
-
# type:
|
13
|
-
# color:
|
14
|
-
# justify:
|
15
|
-
# padding:
|
16
|
-
# indent:
|
17
|
-
# newline:
|
13
|
+
# type: => [symbol] Preset colors for [:fail, :success, :warn]
|
14
|
+
# color: => [integer] See docs for #colorize for color codes
|
15
|
+
# justify: => [center|ljust|rjust] The type of justification to use
|
16
|
+
# padding: => [integer] The maximum string size to justify text in
|
17
|
+
# indent: => [integer] The maximum string size to justify text in
|
18
|
+
# newline: => [boolean] True if you want a newline after the output
|
19
|
+
# progressbar: => [boolean] True if you are adding a title to the progresbar
|
20
|
+
# overwrite: => [boolean] True if you want to overwrite the previous line
|
18
21
|
#
|
19
22
|
def say text = '', args = {}
|
20
23
|
# defaults
|
@@ -31,33 +34,43 @@ module Yuyi::Dsl
|
|
31
34
|
# process last due to the addition of special color codes
|
32
35
|
text = case args[:type]
|
33
36
|
when :fail
|
34
|
-
|
37
|
+
text.colorize :red
|
35
38
|
when :success
|
36
|
-
|
39
|
+
text.colorize :green
|
37
40
|
when :warn
|
38
|
-
|
41
|
+
text.colorize :yellow
|
39
42
|
else
|
40
|
-
|
43
|
+
text
|
44
|
+
end
|
45
|
+
|
46
|
+
if args[:color]
|
47
|
+
text = text.colorize(args[:color])
|
41
48
|
end
|
42
49
|
|
43
50
|
if args[:indent]
|
44
51
|
text = (' ' * args[:indent]) + text
|
45
52
|
end
|
46
53
|
|
47
|
-
if args[:
|
48
|
-
STDOUT.
|
49
|
-
|
54
|
+
if args[:overwrite]
|
55
|
+
STDOUT.flush
|
56
|
+
text = text + "\r"
|
57
|
+
end
|
58
|
+
|
59
|
+
if args[:progressbar] && Yuyi.verbose != true && Yuyi::Menu.menu && Yuyi::Menu.menu.progressbar
|
60
|
+
Yuyi::Menu.menu.progressbar.log text
|
61
|
+
elsif !args[:newline] || args[:overwrite]
|
50
62
|
STDOUT.print text
|
63
|
+
else
|
64
|
+
STDOUT.puts text
|
51
65
|
end
|
52
66
|
end
|
53
67
|
|
54
68
|
# Accepts the same arguments as #say
|
55
69
|
#
|
56
70
|
def ask question, options = {}, &block
|
57
|
-
prompt = '>>> '
|
71
|
+
prompt = '>>> '.colorize(:green)
|
58
72
|
options = {
|
59
73
|
:readline => false,
|
60
|
-
:color => 1
|
61
74
|
}.merge(options)
|
62
75
|
|
63
76
|
say question, options
|
@@ -65,7 +78,7 @@ module Yuyi::Dsl
|
|
65
78
|
output = if options[:readline]
|
66
79
|
Readline.readline(prompt).chomp('/')
|
67
80
|
else
|
68
|
-
say prompt, :
|
81
|
+
say prompt, :newline => false
|
69
82
|
STDIN.gets
|
70
83
|
end.rstrip
|
71
84
|
|
data/lib/yuyi/menu.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'readline'
|
2
|
+
require 'ruby-progressbar'
|
2
3
|
|
3
4
|
class Yuyi::Menu
|
5
|
+
attr_accessor :progressbar
|
6
|
+
|
4
7
|
# Stores a single menu instance on the class
|
5
8
|
# If a new menu is initialized, it will become the only menu accessible through Yuyi::Menu.menu
|
6
9
|
#
|
@@ -151,7 +154,7 @@ private
|
|
151
154
|
def get_menu_path
|
152
155
|
until @yaml
|
153
156
|
Yuyi.say 'Navigate to a menu file...', :type => :success
|
154
|
-
Yuyi.ask "...or just press enter to load `#{Yuyi::DEFAULT_MENU}`", :readline => true
|
157
|
+
Yuyi.ask "...or just press enter to load `#{Yuyi::DEFAULT_MENU}`", :readline => true do |user_path|
|
155
158
|
menu_path = user_path.empty? ? Yuyi::DEFAULT_MENU : user_path
|
156
159
|
load_from_file menu_path
|
157
160
|
end
|
@@ -209,47 +212,49 @@ private
|
|
209
212
|
def order
|
210
213
|
header_length = 80
|
211
214
|
all_rolls = sorted_rolls
|
212
|
-
|
215
|
+
self.progressbar = ProgressBar.create(:progress_mark => '='.colorize(:green), :length => header_length, :total => all_rolls.length)
|
213
216
|
|
214
217
|
# pre installs
|
215
218
|
#
|
216
|
-
Yuyi.say '=' * header_length, :color =>
|
217
|
-
Yuyi.say 'APPETIZERS', :
|
218
|
-
Yuyi.say 'Pre Install', :justify => :center, :padding => header_length
|
219
|
-
Yuyi.say
|
219
|
+
# Yuyi.say '=' * header_length, :color => :green
|
220
|
+
Yuyi.say 'APPETIZERS', :justify => :center, :padding => header_length
|
220
221
|
|
222
|
+
self.progressbar.reset
|
221
223
|
all_rolls.each do |file_name|
|
222
224
|
@rolls[file_name].appetizers
|
225
|
+
self.progressbar.increment
|
223
226
|
end
|
227
|
+
Yuyi.say
|
224
228
|
|
225
229
|
|
226
230
|
# main installs
|
227
231
|
#
|
228
|
-
Yuyi.say '=' * header_length, :color =>
|
229
|
-
Yuyi.say 'ENTREES', :
|
230
|
-
Yuyi.say 'Main Install', :justify => :center, :padding => header_length
|
231
|
-
Yuyi.say
|
232
|
+
# Yuyi.say '=' * header_length, :color => :green
|
233
|
+
Yuyi.say 'ENTREES', :justify => :center, :padding => header_length
|
232
234
|
|
235
|
+
self.progressbar.reset
|
233
236
|
all_rolls.each do |file_name|
|
234
237
|
@rolls[file_name].entree
|
238
|
+
self.progressbar.increment
|
235
239
|
end
|
240
|
+
Yuyi.say
|
236
241
|
|
237
242
|
|
238
243
|
# post installs
|
239
244
|
#
|
240
|
-
Yuyi.say '=' * header_length, :color =>
|
241
|
-
Yuyi.say 'DESSERT', :
|
242
|
-
Yuyi.say 'Post Install', :justify => :center, :padding => header_length
|
243
|
-
Yuyi.say
|
245
|
+
# Yuyi.say '=' * header_length, :color => :green
|
246
|
+
Yuyi.say 'DESSERT', :justify => :center, :padding => header_length
|
244
247
|
|
248
|
+
self.progressbar.reset
|
245
249
|
all_rolls.each do |file_name|
|
246
250
|
@rolls[file_name].dessert
|
251
|
+
self.progressbar.increment
|
247
252
|
end
|
253
|
+
Yuyi.say
|
248
254
|
|
249
255
|
|
250
|
-
Yuyi.say '
|
251
|
-
Yuyi.say '
|
252
|
-
Yuyi.say '=' * header_length, :color => 36
|
256
|
+
Yuyi.say 'YUYI COMPLETED', :color => :light_blue, :justify => :center, :padding => header_length
|
257
|
+
Yuyi.say '=' * header_length, :color => :light_blue
|
253
258
|
Yuyi.say
|
254
259
|
end
|
255
260
|
|
data/lib/yuyi/roll.rb
CHANGED
@@ -47,7 +47,8 @@ class Yuyi::Roll
|
|
47
47
|
|
48
48
|
# set option definitions
|
49
49
|
def self.options option_defs = {}
|
50
|
-
@option_defs
|
50
|
+
@option_defs ||= {}
|
51
|
+
@option_defs.merge! option_defs
|
51
52
|
end
|
52
53
|
|
53
54
|
|
@@ -89,14 +90,14 @@ class Yuyi::Roll
|
|
89
90
|
def order
|
90
91
|
if installed?
|
91
92
|
if options[:uninstall]
|
92
|
-
|
93
|
+
say "🍣\s Uninstalling #{title}...", :color => :red, :progressbar => true, :overwrite => true
|
93
94
|
uninstall
|
94
95
|
elsif Yuyi.upgrade
|
95
|
-
|
96
|
+
say "🍣\s Upgrading #{title}", :color => :yellow, :progressbar => true, :overwrite => true
|
96
97
|
upgrade
|
97
98
|
end
|
98
99
|
else
|
99
|
-
|
100
|
+
say "🍣\s Installing #{title}...", :color => :green, :progressbar => true, :overwrite => true
|
100
101
|
install
|
101
102
|
end
|
102
103
|
end
|
@@ -147,7 +148,7 @@ class Yuyi::Roll
|
|
147
148
|
|
148
149
|
def installed?
|
149
150
|
if Yuyi.verbose
|
150
|
-
say "INSTALLED?: #{self.title}", :color =>
|
151
|
+
say "INSTALLED?: #{self.title}", :color => :yellow
|
151
152
|
end
|
152
153
|
|
153
154
|
begin
|
data/lib/yuyi/ui.rb
CHANGED
@@ -2,18 +2,18 @@ module Yuyi::Ui
|
|
2
2
|
def header
|
3
3
|
line_length = 50
|
4
4
|
say
|
5
|
-
say '-' * line_length, :color =>
|
5
|
+
say '-' * line_length, :color => :light_blue
|
6
6
|
say
|
7
|
-
say '____ ____ __ __ ____ ____ __ ',
|
8
|
-
say '\ \ / / | | | | \ \ / / | | ',
|
9
|
-
say ' \ \/ / | | | | \ \/ / | | ',
|
10
|
-
say ' \_ _/ | | | | \_ _/ | | ',
|
11
|
-
say ' | | | `--\' | | | | | ', :
|
12
|
-
say ' |__| \______/ |__| |__| ',
|
7
|
+
say '____ ____ __ __ ____ ____ __ ', :justify => :center, :padding => line_length, :color => :red
|
8
|
+
say '\ \ / / | | | | \ \ / / | | ', :justify => :center, :padding => line_length, :color => :light_white
|
9
|
+
say ' \ \/ / | | | | \ \/ / | | ', :justify => :center, :padding => line_length, :color => :light_blue
|
10
|
+
say ' \_ _/ | | | | \_ _/ | | ', :justify => :center, :padding => line_length, :color => :red
|
11
|
+
say ' | | | `--\' | | | | | ', :justify => :center, :padding => line_length, :color => :light_white
|
12
|
+
say ' |__| \______/ |__| |__| ', :justify => :center, :padding => line_length, :color => :light_blue
|
13
13
|
say
|
14
14
|
say "VERSION #{Yuyi::VERSION}", :justify => :center, :padding => line_length
|
15
15
|
say
|
16
|
-
say '-' * line_length, :color =>
|
16
|
+
say '-' * line_length, :color => :light_blue
|
17
17
|
say
|
18
18
|
end
|
19
19
|
|
@@ -42,6 +42,7 @@ module Yuyi::Ui
|
|
42
42
|
say 'Yuyi does not need your admin password, but some installations do.', :type => :warn
|
43
43
|
say 'Yuyi will prompt you for a password and attempt to keep your admin timestamp alive.', :type => :warn
|
44
44
|
say 'You may be asked to enter your password several times.', :type => :warn
|
45
|
+
say
|
45
46
|
|
46
47
|
# keep the sudo timestamp fresh just in case
|
47
48
|
`sudo -v`
|
@@ -59,23 +60,24 @@ module Yuyi::Ui
|
|
59
60
|
indent = 2
|
60
61
|
longest_option = roll.options.keys.map(&:to_s).max_by(&:length).length + indent
|
61
62
|
|
62
|
-
say "
|
63
|
+
say "#{roll.title} options", :color => :green
|
63
64
|
|
64
65
|
roll.option_defs.each do |k, v|
|
65
|
-
option_color = v[:required] ?
|
66
|
+
option_color = v[:required] ? :red : :default
|
66
67
|
|
68
|
+
# show option and description
|
67
69
|
say "#{k.to_s.rjust(longest_option)}: ", :color => option_color, :newline => false
|
68
70
|
say v[:description]
|
69
|
-
|
71
|
+
|
72
|
+
# show default
|
70
73
|
if v[:default]
|
71
|
-
say 'default: ', :
|
74
|
+
say 'default: ', :indent => (longest_option + indent), :newline => false, :color => :yellow
|
72
75
|
say v[:default]
|
73
76
|
end
|
74
77
|
end
|
75
78
|
|
76
79
|
if examples
|
77
80
|
examples_hash = {}
|
78
|
-
example_indent = longest_option + indent
|
79
81
|
options = roll.options.dup
|
80
82
|
|
81
83
|
# merge examples from roll source in
|
@@ -88,17 +90,8 @@ module Yuyi::Ui
|
|
88
90
|
examples_hash[roll.file_name.to_s] = options
|
89
91
|
|
90
92
|
say
|
91
|
-
say 'Example', :color =>
|
92
|
-
say examples_hash.deep_stringify_keys!.to_yaml.sub('---', '').gsub(/\n(\s*)/, "\n\\1#{' ' *
|
93
|
+
say 'Example', :color => :green, :indent => indent, :newline => false
|
94
|
+
say examples_hash.deep_stringify_keys!.to_yaml.sub('---', '').gsub(/\n(\s*)/, "\n\\1#{' ' * (indent + indent)}")
|
93
95
|
end
|
94
96
|
end
|
95
|
-
|
96
|
-
# Output text with a certain color (or style)
|
97
|
-
# Reference for color codes
|
98
|
-
# https://github.com/flori/term-ansicolor/blob/master/lib/term/ansicolor.rb
|
99
|
-
#
|
100
|
-
def colorize text, color_code
|
101
|
-
return text unless color_code
|
102
|
-
"\e[#{color_code}m#{text}\e[0m"
|
103
|
-
end
|
104
97
|
end
|
data/spec/lib/yuyi/dsl_spec.rb
CHANGED
@@ -14,16 +14,6 @@ describe Yuyi::Dsl do
|
|
14
14
|
allow(STDOUT).to receive(:puts).and_call_original
|
15
15
|
end
|
16
16
|
|
17
|
-
it 'should output the correct type' do
|
18
|
-
expect(STDOUT).to receive(:puts).with("\e[31mfoo type\e[0m")
|
19
|
-
DslTest.say 'foo type', :type => :fail
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should output the correct color' do
|
23
|
-
expect(STDOUT).to receive(:puts).with("\e[123mfoo color\e[0m")
|
24
|
-
DslTest.say 'foo color', :color => 123
|
25
|
-
end
|
26
|
-
|
27
17
|
it 'should output the correct justification & padding' do
|
28
18
|
expect(STDOUT).to receive(:puts).with(' foo justify padding ')
|
29
19
|
DslTest.say 'foo justify padding', :justify => :center, :padding => 22
|
data/spec/spec_helper.rb
CHANGED
@@ -17,10 +17,13 @@ RSpec.configure do |config|
|
|
17
17
|
c.syntax = :expect
|
18
18
|
end
|
19
19
|
|
20
|
-
config.order =
|
20
|
+
config.order = :random
|
21
21
|
|
22
22
|
config.before do
|
23
23
|
allow(Yuyi).to receive(:say)
|
24
|
+
allow(ProgressBar).to receive(:create)
|
25
|
+
allow_any_instance_of(Yuyi::Menu).to receive_message_chain('progressbar.reset')
|
26
|
+
allow_any_instance_of(Yuyi::Menu).to receive_message_chain('progressbar.increment')
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yuyi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
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-07-
|
11
|
+
date: 2014-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-progressbar
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: thor
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|