yuyi 1.0.6 → 1.0.7
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/lib/yuyi/cli.rb +160 -158
- data/lib/yuyi/menu.rb +6 -0
- data/lib/yuyi/roll.rb +4 -0
- 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: 4cdc21ccb1c1827519985b27b4e273ae0a093602
|
4
|
+
data.tar.gz: 015d034b735328c1789cf17e4772e58d2c63884f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8a41477a856a6695051b5a3c14aa639aa1e3d36bd0af84656c06345f4800a39c82114d5b656a3b6df2777bf647605224658509d4a2262924ae32d682b367233
|
7
|
+
data.tar.gz: c2b5e9e6550b51190e73ad6e9edd167c8fb87f5aa24d1c8137f13b69e83bf1f3268badbf3e5fa7aa4040a886a0269e98982319a632bd6d193a58b15fc6ee5e91
|
data/.new
CHANGED
data/lib/yuyi/cli.rb
CHANGED
@@ -172,204 +172,206 @@ module Yuyi::Cli
|
|
172
172
|
run('/usr/bin/sw_vers -productVersion').chomp[/10\.\d+/].to_f
|
173
173
|
end
|
174
174
|
|
175
|
+
def verbose?; @verbose; end
|
176
|
+
|
175
177
|
private
|
176
178
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
179
|
+
def start
|
180
|
+
header
|
181
|
+
get_menu
|
182
|
+
confirm_upgrade
|
183
|
+
confirm_options
|
184
|
+
authenticate
|
185
|
+
Yuyi::Menu.instance.order_rolls
|
186
|
+
end
|
185
187
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
188
|
+
def header
|
189
|
+
line_length = 50
|
190
|
+
say
|
191
|
+
say '-' * line_length, :color => 4
|
192
|
+
say
|
193
|
+
say '____ ____ __ __ ____ ____ __ ', :color => 31, :justify => :center, :padding => line_length
|
194
|
+
say '\ \ / / | | | | \ \ / / | | ', :color => 32, :justify => :center, :padding => line_length
|
195
|
+
say ' \ \/ / | | | | \ \/ / | | ', :color => 33, :justify => :center, :padding => line_length
|
196
|
+
say ' \_ _/ | | | | \_ _/ | | ', :color => 34, :justify => :center, :padding => line_length
|
197
|
+
say ' | | | `--\' | | | | | ', :color => 35, :justify => :center, :padding => line_length
|
198
|
+
say ' |__| \______/ |__| |__| ', :color => 36, :justify => :center, :padding => line_length
|
199
|
+
say
|
200
|
+
say "VERSION #{Yuyi::VERSION}", :justify => :center, :padding => line_length
|
201
|
+
say
|
202
|
+
say '-' * line_length, :color => 4
|
203
|
+
say
|
204
|
+
end
|
203
205
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
206
|
+
# Ask the user for a menu file to load
|
207
|
+
#
|
208
|
+
def get_menu
|
209
|
+
until @path
|
210
|
+
say 'Navigate to a menu file...', :type => :success
|
211
|
+
@path = ask "...or just press enter to load `#{Yuyi::DEFAULT_MENU}`", :readline => true, :color => 36 do |path|
|
212
|
+
path = path.empty? ? Yuyi::DEFAULT_MENU : path
|
213
|
+
|
214
|
+
if Yuyi::Menu.load_from_file path
|
215
|
+
say 'Downloading Sources... Please Wait', :type => :warn
|
216
|
+
say
|
217
|
+
|
218
|
+
path
|
219
|
+
else
|
220
|
+
say 'Invalid Path... Please check the location of your menu file', :type => :fail
|
221
|
+
say
|
222
|
+
|
223
|
+
nil
|
224
|
+
end
|
222
225
|
end
|
223
226
|
end
|
224
|
-
end
|
225
227
|
|
226
|
-
|
227
|
-
|
228
|
+
Yuyi::Menu.new @path
|
229
|
+
end
|
228
230
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
231
|
+
# Ask to check for upgrades
|
232
|
+
#
|
233
|
+
def confirm_upgrade
|
234
|
+
ask 'Do you want to check for upgrades for already installed rolls? (Yn)', :type => :warn do |upgrade|
|
235
|
+
Yuyi::Menu.upgrade? upgrade == 'Y'
|
236
|
+
end
|
234
237
|
end
|
235
|
-
end
|
236
238
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
239
|
+
# If any rolls on the menu have options, confirm the options before continuing
|
240
|
+
#
|
241
|
+
def confirm_options
|
242
|
+
confirm = false
|
243
|
+
Yuyi::Menu.rolls.each do |name, roll|
|
242
244
|
|
243
|
-
|
244
|
-
|
245
|
-
|
245
|
+
unless roll.class.options.empty?
|
246
|
+
present_options roll
|
247
|
+
confirm = true
|
248
|
+
end
|
246
249
|
end
|
247
|
-
end
|
248
250
|
|
249
|
-
|
250
|
-
|
251
|
-
|
251
|
+
if confirm
|
252
|
+
ask 'Hit any key when you have your options set correctly in your menu file', :type => :warn do
|
253
|
+
Yuyi::Menu.load_from_file
|
254
|
+
end
|
252
255
|
end
|
253
256
|
end
|
254
|
-
end
|
255
257
|
|
256
|
-
|
257
|
-
|
258
|
-
|
258
|
+
def authenticate
|
259
|
+
say 'Yuyi does not need your admin password, but some installations force a prompt.', :type => :warn
|
260
|
+
say 'You may be asked to enter your password several times. ', :type => :warn
|
259
261
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
262
|
+
# keep the sudo timestamp fresh
|
263
|
+
Thread::new do
|
264
|
+
loop do
|
265
|
+
sleep 1.minute
|
266
|
+
`sudo -v`
|
267
|
+
end
|
265
268
|
end
|
266
|
-
end
|
267
269
|
|
268
|
-
|
269
|
-
|
270
|
+
say
|
271
|
+
end
|
270
272
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
273
|
+
# Show formatted options
|
274
|
+
#
|
275
|
+
def present_options roll, examples = true
|
276
|
+
indent = 2
|
277
|
+
longest_option = roll.options.keys.map(&:to_s).max_by(&:length).length + indent
|
276
278
|
|
277
|
-
|
279
|
+
say "Available options for #{roll.title}...", :color => 32
|
278
280
|
|
279
|
-
|
280
|
-
|
281
|
+
roll.option_defs.each do |k, v|
|
282
|
+
option_color = v[:required] ? 31 : 36
|
281
283
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
284
|
+
say "#{k.to_s.rjust(longest_option)}: ", :color => option_color, :newline => false
|
285
|
+
say v[:description]
|
286
|
+
say (' ' * (longest_option + indent)), :newline => false
|
287
|
+
if v[:default]
|
288
|
+
say 'default: ', :color => 36, :newline => false
|
289
|
+
say v[:default]
|
290
|
+
end
|
288
291
|
end
|
289
|
-
end
|
290
292
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
293
|
+
if examples
|
294
|
+
examples_hash = {}
|
295
|
+
example_indent = longest_option + indent
|
296
|
+
options = roll.options.dup
|
295
297
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
298
|
+
# merge examples from roll source in
|
299
|
+
options.each do |option, value|
|
300
|
+
if example = roll.option_defs[option][:example]
|
301
|
+
options[option] = example
|
302
|
+
end
|
300
303
|
end
|
301
|
-
end
|
302
304
|
|
303
|
-
|
305
|
+
examples_hash[roll.file_name.to_s] = options
|
304
306
|
|
305
307
|
|
306
|
-
|
307
|
-
|
308
|
-
|
308
|
+
say
|
309
|
+
say 'Example', :color => 33, :indent => example_indent, :newline => false
|
310
|
+
say examples_hash.deep_stringify_keys!.to_yaml.sub('---', '').gsub(/\n(\s*)/, "\n\\1#{' ' * example_indent}")
|
311
|
+
end
|
309
312
|
end
|
310
|
-
end
|
311
313
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
314
|
+
# Output text with a certain color (or style)
|
315
|
+
# Reference for color codes
|
316
|
+
# https://github.com/flori/term-ansicolor/blob/master/lib/term/ansicolor.rb
|
317
|
+
#
|
318
|
+
def colorize text, color_code
|
319
|
+
return text unless color_code
|
320
|
+
"\e[#{color_code}m#{text}\e[0m"
|
321
|
+
end
|
320
322
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
323
|
+
# METHODS FOR FLAGS
|
324
|
+
#
|
325
|
+
def help
|
326
|
+
longest_option = CLI_OPTIONS.keys.map(&:to_s).max.length
|
325
327
|
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
328
|
+
say
|
329
|
+
CLI_OPTIONS.each do |option, description|
|
330
|
+
string = ''
|
331
|
+
string << "-#{option.to_s.chars.first}"
|
332
|
+
string << ', '
|
333
|
+
string << "--#{option.to_s.ljust(longest_option)}"
|
334
|
+
string << ' '
|
335
|
+
string << description
|
336
|
+
say string
|
337
|
+
end
|
338
|
+
say
|
335
339
|
end
|
336
|
-
say
|
337
|
-
end
|
338
|
-
|
339
|
-
# List all available rolls
|
340
|
-
#
|
341
|
-
def list
|
342
|
-
get_menu
|
343
|
-
Yuyi::Menu.set_sources
|
344
340
|
|
345
|
-
#
|
341
|
+
# List all available rolls
|
346
342
|
#
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
343
|
+
def list
|
344
|
+
get_menu
|
345
|
+
Yuyi::Menu.set_sources
|
346
|
+
|
347
|
+
# Collect all rolls from all sources
|
348
|
+
#
|
349
|
+
rolls = []
|
350
|
+
Yuyi::Menu.sources.each do |source|
|
351
|
+
rolls |= source.available_rolls.keys
|
352
|
+
end
|
351
353
|
|
352
|
-
|
353
|
-
|
354
|
+
# alphabatize rolls
|
355
|
+
rolls = rolls.map(&:to_s).sort.map(&:to_sym)
|
354
356
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
357
|
+
say 'Available Rolls', :type => :success
|
358
|
+
say '---------------', :type => :success
|
359
|
+
rolls.each do |roll|
|
360
|
+
say roll.to_s
|
361
|
+
end
|
362
|
+
say
|
359
363
|
end
|
360
|
-
say
|
361
|
-
end
|
362
364
|
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
365
|
+
# Return current version
|
366
|
+
#
|
367
|
+
def version
|
368
|
+
say "#{Yuyi::NAME} #{Yuyi::VERSION}"
|
369
|
+
end
|
368
370
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
371
|
+
# Return current version
|
372
|
+
#
|
373
|
+
def verbose
|
374
|
+
@verbose = true
|
375
|
+
start
|
376
|
+
end
|
375
377
|
end
|
data/lib/yuyi/menu.rb
CHANGED
@@ -138,6 +138,12 @@ class Yuyi::Menu
|
|
138
138
|
all_rolls.each do |file_name|
|
139
139
|
rolls[file_name].dessert
|
140
140
|
end
|
141
|
+
|
142
|
+
|
143
|
+
Yuyi.say '=' * header_length, :color => 36
|
144
|
+
Yuyi.say 'YUYI COMPLETED', :color => 36, :justify => :center, :padding => header_length
|
145
|
+
Yuyi.say '=' * header_length, :color => 36
|
146
|
+
Yuyi.say
|
141
147
|
end
|
142
148
|
|
143
149
|
# Find the best roll in the source to be added
|
data/lib/yuyi/roll.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yuyi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
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-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|