yuyi 1.1.5 → 1.1.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/.new +1 -1
- data/README.md +0 -2
- data/lib/yuyi.rb +0 -1
- data/lib/yuyi/cli.rb +0 -1
- data/lib/yuyi/core.rb +1 -0
- data/lib/yuyi/ui.rb +42 -8
- data/spec/lib/yuyi/ui_spec.rb +41 -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: 06030895fc322074fd3a878a5c80a08e97ea21fb
|
4
|
+
data.tar.gz: f624d1502202e155b7e74a0d10c182becf545358
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72f7379391f73129aa928213e424c8107d55d3dab92a814af6ea19ab82af6e6f8f011876bfa55346deb09ed6a60dd6e9d57565bdb34e85f218cb0b562849c5f
|
7
|
+
data.tar.gz: 633457f35ad9e340b744c5bc18fc72484ad41e9f8f44eed06c26cc65860771b5c54bd1beda93231f73c77b26a753054c7b5b9880cf3f510e6bca7081aa36619b
|
data/.new
CHANGED
data/README.md
CHANGED
data/lib/yuyi.rb
CHANGED
data/lib/yuyi/cli.rb
CHANGED
@@ -34,7 +34,6 @@ class Yuyi::Cli < Thor
|
|
34
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
|
38
37
|
# enable verbose mode if flag is passed
|
39
38
|
Yuyi.verbose = options[:verbose]
|
40
39
|
Yuyi.upgrade = options[:upgrade]
|
data/lib/yuyi/core.rb
CHANGED
data/lib/yuyi/ui.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Yuyi::Ui
|
2
|
+
@@required = {}
|
3
|
+
|
2
4
|
def header
|
3
5
|
line_length = 50
|
4
6
|
say
|
@@ -21,8 +23,7 @@ module Yuyi::Ui
|
|
21
23
|
#
|
22
24
|
def confirm_options
|
23
25
|
confirm = false
|
24
|
-
Yuyi::Menu.rolls.each do |
|
25
|
-
|
26
|
+
Yuyi::Menu.rolls.values.each do |roll|
|
26
27
|
unless roll.class.options.empty?
|
27
28
|
present_options roll
|
28
29
|
confirm = true
|
@@ -30,10 +31,35 @@ module Yuyi::Ui
|
|
30
31
|
end
|
31
32
|
|
32
33
|
if confirm
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
required_options_satisfied = false
|
35
|
+
|
36
|
+
until required_options_satisfied
|
37
|
+
say 'Your menu is being loaded from: ', :type => :warn, :newline => false
|
38
|
+
say Yuyi::Menu.menu_path
|
39
|
+
ask 'Make any neccessary changes to it, then press enter to continue.', :type => :warn do
|
40
|
+
Yuyi::Menu.load_from_file
|
41
|
+
end
|
42
|
+
|
43
|
+
# check that required options are satisfied
|
44
|
+
catch :required_options_satisfied do
|
45
|
+
@@required.each do |roll, required_options|
|
46
|
+
required_options.each do |required_option|
|
47
|
+
if Yuyi::Menu.options(roll)[required_option]
|
48
|
+
next
|
49
|
+
else
|
50
|
+
say 'Required option ', :type => :fail, :newline => false
|
51
|
+
say required_option, :newline => false
|
52
|
+
say ' for ', :type => :fail, :newline => false
|
53
|
+
say roll, :newline => false
|
54
|
+
say ' is not set', :type => :fail
|
55
|
+
say
|
56
|
+
throw :required_options_satisfied
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
required_options_satisfied = true
|
62
|
+
end
|
37
63
|
end
|
38
64
|
end
|
39
65
|
end
|
@@ -63,14 +89,22 @@ module Yuyi::Ui
|
|
63
89
|
say "#{roll.title} options", :color => :green
|
64
90
|
|
65
91
|
roll.option_defs.each do |k, v|
|
66
|
-
|
92
|
+
if v[:required]
|
93
|
+
# add to required list
|
94
|
+
@@required[roll.file_name] ||= []
|
95
|
+
@@required[roll.file_name] << k
|
96
|
+
|
97
|
+
option_color = :red
|
98
|
+
else
|
99
|
+
option_color = :default
|
100
|
+
end
|
67
101
|
|
68
102
|
# show option and description
|
69
103
|
say "#{k.to_s.rjust(longest_option)}: ", :color => option_color, :newline => false
|
70
104
|
say v[:description]
|
71
105
|
|
72
106
|
# show default
|
73
|
-
if v[:default]
|
107
|
+
if v[:default] && (!v[:default].respond_to?(:empty?) || (v[:default].respond_to?(:empty?) && !v[:default].empty?))
|
74
108
|
say 'default: ', :indent => (longest_option + indent), :newline => false, :color => :yellow
|
75
109
|
say v[:default]
|
76
110
|
end
|
data/spec/lib/yuyi/ui_spec.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Yuyi::Ui do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
before do
|
5
|
+
class UiTest; extend Yuyi::Ui; end
|
6
|
+
Yuyi::Ui.class_var :required, {}
|
7
|
+
end
|
7
8
|
|
9
|
+
describe '.present_options' do
|
10
|
+
before do
|
8
11
|
@output = ''
|
9
12
|
allow(UiTest).to receive :say do |o, p|
|
10
13
|
@output << (o || '')
|
@@ -19,6 +22,9 @@ describe Yuyi::Ui do
|
|
19
22
|
:description => 'foo description',
|
20
23
|
:example => '1.0',
|
21
24
|
:default => '2.0'
|
25
|
+
},
|
26
|
+
:option_required_foo => {
|
27
|
+
:required => true
|
22
28
|
}
|
23
29
|
})
|
24
30
|
|
@@ -32,5 +38,37 @@ describe Yuyi::Ui do
|
|
32
38
|
expect(@output).to include '1.0'
|
33
39
|
expect(@output).to include '2.0'
|
34
40
|
end
|
41
|
+
|
42
|
+
it 'should add to the required object' do
|
43
|
+
expect(Yuyi::Ui.class_var(:required)).to eq({ :present_options_roll => [:option_required_foo] })
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.confirm_options' do
|
48
|
+
before do
|
49
|
+
Yuyi::Ui.class_var :required, { :confirm_options_roll => [:option_foo]}
|
50
|
+
|
51
|
+
allow(UiTest).to receive(:present_options)
|
52
|
+
allow(UiTest).to receive(:say)
|
53
|
+
allow(UiTest).to receive(:ask)
|
54
|
+
|
55
|
+
class ConfirmOptionsRoll; end
|
56
|
+
@confirm_options_roll = ConfirmOptionsRoll.new
|
57
|
+
allow(ConfirmOptionsRoll).to receive(:options).and_return({ :option_foo => {}})
|
58
|
+
|
59
|
+
allow(Yuyi::Menu).to receive(:rolls).and_return({ :confirm_options_roll => @confirm_options_roll })
|
60
|
+
allow(Yuyi::Menu).to receive(:menu_path)
|
61
|
+
allow(Yuyi::Menu).to receive(:options).and_return({ :option_foo => nil }, { :option_foo => 'bar' })
|
62
|
+
|
63
|
+
UiTest.send :confirm_options
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should call present_options if there are rolls with options' do
|
67
|
+
expect(UiTest).to have_received(:present_options).with(@confirm_options_roll)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should ask to reload the menu if required options arent satisfied' do
|
71
|
+
expect(UiTest).to have_received(:ask).twice
|
72
|
+
end
|
35
73
|
end
|
36
74
|
end
|
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.1.
|
4
|
+
version: 1.1.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-07-
|
11
|
+
date: 2014-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|