yuyi 1.0.2 → 1.0.3
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 +10 -5
- data/lib/yuyi/menu.rb +7 -1
- data/lib/yuyi/roll.rb +24 -4
- data/spec/lib/yuyi/cli_spec.rb +21 -8
- data/spec/lib/yuyi/menu_spec.rb +21 -4
- 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: 8667df310a7caf00f8607e5087c452a1ec32047b
|
4
|
+
data.tar.gz: e9e2e237dcb9a5fe15f0c6b5395841d78f18b2cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d085644d59271a419c13216437c879667d86f3701a13724e1aca6ea7231f84572881529a045758755be8be84190b6c3313638ab2e3ec3c9331b376c858322276
|
7
|
+
data.tar.gz: 904a13f14634ba63338104d83ff881f10f76725c59f50d0f24191bbd5df2f7a2fc71428bfbd707c97fefb0bd39a68e99ec441302a908680d4340e63216828dd7
|
data/.new
CHANGED
data/lib/yuyi/cli.rb
CHANGED
@@ -23,6 +23,11 @@ module Yuyi::Cli
|
|
23
23
|
# get the first argument as the command
|
24
24
|
command, *rest = *args
|
25
25
|
|
26
|
+
if command && !command.include?('-')
|
27
|
+
@path = command
|
28
|
+
command, *rest = *rest
|
29
|
+
end
|
30
|
+
|
26
31
|
# Call options method if valid argument is passed
|
27
32
|
# This checks for the full name or the first letter, proceeded by '--' or '-' respectively
|
28
33
|
CLI_OPTIONS.keys.each do |option|
|
@@ -198,18 +203,16 @@ private
|
|
198
203
|
# Ask the user for a menu file to load
|
199
204
|
#
|
200
205
|
def get_menu
|
201
|
-
|
202
|
-
|
203
|
-
until menu
|
206
|
+
until @path
|
204
207
|
say 'Navigate to a menu file...', :type => :success
|
205
|
-
|
208
|
+
@path = ask "...or just press enter to load `#{Yuyi::DEFAULT_MENU}`", :readline => true, :color => 36 do |path|
|
206
209
|
path = path.empty? ? Yuyi::DEFAULT_MENU : path
|
207
210
|
|
208
211
|
if Yuyi::Menu.load_from_file path
|
209
212
|
say 'Downloading Sources... Please Wait', :type => :warn
|
210
213
|
say
|
211
214
|
|
212
|
-
|
215
|
+
path
|
213
216
|
else
|
214
217
|
say 'Invalid Path... Please check the location of your menu file', :type => :fail
|
215
218
|
say
|
@@ -218,6 +221,8 @@ private
|
|
218
221
|
end
|
219
222
|
end
|
220
223
|
end
|
224
|
+
|
225
|
+
Yuyi::Menu.new @path
|
221
226
|
end
|
222
227
|
|
223
228
|
# Ask to check for upgrades
|
data/lib/yuyi/menu.rb
CHANGED
@@ -43,8 +43,14 @@ class Yuyi::Menu
|
|
43
43
|
# defaults to previously stored @path value
|
44
44
|
#
|
45
45
|
def self.load_from_file path = path
|
46
|
+
menu = begin
|
47
|
+
File.open(File.expand_path(path))
|
48
|
+
rescue
|
49
|
+
Yuyi.run "curl -sS #{path}"
|
50
|
+
end
|
51
|
+
|
46
52
|
@object = begin
|
47
|
-
YAML.load(
|
53
|
+
YAML.load(menu).deep_symbolize_keys!
|
48
54
|
rescue
|
49
55
|
nil
|
50
56
|
end
|
data/lib/yuyi/roll.rb
CHANGED
@@ -178,7 +178,12 @@ private
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def install
|
181
|
-
|
181
|
+
begin
|
182
|
+
instance_eval(&self.class.install)
|
183
|
+
rescue
|
184
|
+
say "The #{self.title} roll does not have `install` defined", :type => :fail
|
185
|
+
exit
|
186
|
+
end
|
182
187
|
end
|
183
188
|
|
184
189
|
def post_install
|
@@ -187,15 +192,30 @@ private
|
|
187
192
|
end
|
188
193
|
|
189
194
|
def uninstall
|
190
|
-
|
195
|
+
begin
|
196
|
+
instance_eval(&self.class.uninstall)
|
197
|
+
rescue
|
198
|
+
say "The #{self.title} roll does not have `uninstall` defined", :type => :fail
|
199
|
+
exit
|
200
|
+
end
|
191
201
|
end
|
192
202
|
|
193
203
|
def upgrade
|
194
|
-
|
204
|
+
begin
|
205
|
+
instance_eval(&self.class.upgrade)
|
206
|
+
rescue
|
207
|
+
say "The #{self.title} roll does not have `upgrade` defined", :type => :fail
|
208
|
+
exit
|
209
|
+
end
|
195
210
|
end
|
196
211
|
|
197
212
|
def installed?
|
198
|
-
|
213
|
+
begin
|
214
|
+
!!instance_eval(&self.class.installed?)
|
215
|
+
rescue
|
216
|
+
say "The #{self.title} roll does not have `installed?` defined", :type => :fail
|
217
|
+
exit
|
218
|
+
end
|
199
219
|
end
|
200
220
|
|
201
221
|
# Helpers for Yuyi Cli methods
|
data/spec/lib/yuyi/cli_spec.rb
CHANGED
@@ -6,6 +6,7 @@ describe Yuyi::Cli do
|
|
6
6
|
before do
|
7
7
|
class CliTest; extend Yuyi::Cli; end
|
8
8
|
allow(CliTest).to receive(:say)
|
9
|
+
CliTest.send(:instance_variable_set, :'@path', nil)
|
9
10
|
end
|
10
11
|
|
11
12
|
describe 'CLI_OPTIONS' do
|
@@ -31,7 +32,7 @@ describe Yuyi::Cli do
|
|
31
32
|
context 'with an invalid argument' do
|
32
33
|
before do
|
33
34
|
allow(CliTest).to receive :help
|
34
|
-
CliTest.init 'foo'
|
35
|
+
CliTest.init '-foo'
|
35
36
|
end
|
36
37
|
|
37
38
|
it 'should call the help method' do
|
@@ -54,6 +55,17 @@ describe Yuyi::Cli do
|
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
58
|
+
|
59
|
+
context 'with a menu path' do
|
60
|
+
before do
|
61
|
+
allow(CliTest).to receive :start
|
62
|
+
CliTest.init 'foo_path'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should set the path' do
|
66
|
+
expect(CliTest.instance_var(:path)).to eq 'foo_path'
|
67
|
+
end
|
68
|
+
end
|
57
69
|
end
|
58
70
|
|
59
71
|
describe '#say' do
|
@@ -188,7 +200,8 @@ describe Yuyi::Cli do
|
|
188
200
|
describe '#get_menu' do
|
189
201
|
before do
|
190
202
|
stub_const 'Yuyi::DEFAULT_MENU', 'spec/fixtures/menu.yaml'
|
191
|
-
allow(Yuyi::Menu).to receive(:
|
203
|
+
allow(Yuyi::Menu).to receive(:new)
|
204
|
+
allow(Yuyi::Menu).to receive(:load_from_file)
|
192
205
|
end
|
193
206
|
|
194
207
|
after do
|
@@ -201,33 +214,33 @@ describe Yuyi::Cli do
|
|
201
214
|
context 'when no input is given' do
|
202
215
|
before do
|
203
216
|
allow(Readline).to receive(:readline).and_return('')
|
204
|
-
allow(Yuyi::Menu).to receive(:
|
217
|
+
allow(Yuyi::Menu).to receive(:load_from_file).and_return(true)
|
205
218
|
end
|
206
219
|
|
207
220
|
it 'should load the default menu' do
|
208
|
-
expect(Yuyi::Menu).to receive(:
|
221
|
+
expect(Yuyi::Menu).to receive(:load_from_file).with('spec/fixtures/menu.yaml')
|
209
222
|
end
|
210
223
|
end
|
211
224
|
|
212
225
|
context 'when an invalid path is given' do
|
213
226
|
before do
|
214
227
|
allow(Readline).to receive(:readline).and_return('foo', 'bar', '')
|
215
|
-
allow(Yuyi::Menu).to receive(:
|
228
|
+
allow(Yuyi::Menu).to receive(:load_from_file).and_return(false, false, true)
|
216
229
|
end
|
217
230
|
|
218
231
|
it 'should request input again' do
|
219
|
-
expect(Yuyi::Menu).to receive(:
|
232
|
+
expect(Yuyi::Menu).to receive(:load_from_file).exactly(3).times
|
220
233
|
end
|
221
234
|
end
|
222
235
|
|
223
236
|
context 'when a custom path is given' do
|
224
237
|
before do
|
225
238
|
allow(Readline).to receive(:readline).and_return('spec/fixtures/menu.yaml')
|
226
|
-
allow(Yuyi::Menu).to receive(:
|
239
|
+
allow(Yuyi::Menu).to receive(:load_from_file).and_return(true)
|
227
240
|
end
|
228
241
|
|
229
242
|
it 'should load the menu' do
|
230
|
-
expect(Yuyi::Menu).to receive(:
|
243
|
+
expect(Yuyi::Menu).to receive(:load_from_file).with('spec/fixtures/menu.yaml')
|
231
244
|
end
|
232
245
|
end
|
233
246
|
end
|
data/spec/lib/yuyi/menu_spec.rb
CHANGED
@@ -6,12 +6,29 @@ describe Yuyi::Menu do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
describe '.load_from_file' do
|
9
|
-
|
10
|
-
|
9
|
+
context 'with a local file' do
|
10
|
+
before do
|
11
|
+
Yuyi::Menu.load_from_file 'spec/fixtures/menu2.yaml'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should update the menu object' do
|
15
|
+
expect(@menu.object[:rolls][:foo_roll]).to eq({ :bar => 'foo' })
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
|
-
|
14
|
-
|
19
|
+
context 'with a remote file' do
|
20
|
+
before do
|
21
|
+
allow(Yuyi).to receive(:run).and_return({ :foo => 'bar' }.to_yaml)
|
22
|
+
Yuyi::Menu.load_from_file 'file://menu.yaml'
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
allow(Yuyi).to receive(:run).and_call_original
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should update the menu object' do
|
30
|
+
expect(@menu.object[:foo]).to eq 'bar'
|
31
|
+
end
|
15
32
|
end
|
16
33
|
end
|
17
34
|
|
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.3
|
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-06-
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|