yuyi 0.0.3 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.new +1 -2
- data/README.md +0 -5
- data/lib/yuyi/cli.rb +6 -3
- data/lib/yuyi/menu.rb +13 -22
- data/lib/yuyi/roll.rb +21 -3
- data/spec/lib/yuyi/cli_spec.rb +5 -0
- data/spec/lib/yuyi/menu_spec.rb +17 -46
- data/spec/lib/yuyi/roll_spec.rb +10 -2
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5841d6388b4ca91994af0c63e27c2510b54debbb
|
4
|
+
data.tar.gz: 0d24a61a7b7904929e3cea3c140ced41f7681747
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd3c048476f8d8a80597d72cd558c6591322fb0a4e3a687b931b5ce79e0c44ce7b62fe076a2d41169e33e152b268f4abed7fc9928fc0b3f7ad63aa9d44b85d18
|
7
|
+
data.tar.gz: 53be4914b13f884f1fa7e61bf95e7b8c468adcf89919a31700a28be6fdceb57d40b244673a3af142b10340fa486eb631d49ec67ea2e34c9a3a39a55e3f94d990
|
data/.new
CHANGED
@@ -8,7 +8,6 @@ tasks:
|
|
8
8
|
gemspec:
|
9
9
|
summary: Automation for installing/uninstalling/updating your machine environment
|
10
10
|
description: Maintain a menu of applications and services to automate the installation
|
11
|
-
of.
|
12
11
|
homepage: https://github.com/brewster1134/Yuyi
|
13
12
|
executables:
|
14
13
|
- yuyi
|
@@ -17,4 +16,4 @@ tasks:
|
|
17
16
|
- spec/**/*.rb
|
18
17
|
project_name: Yuyi
|
19
18
|
type: ruby
|
20
|
-
version: 0.0.
|
19
|
+
version: 0.0.6
|
data/README.md
CHANGED
@@ -107,16 +107,11 @@ end
|
|
107
107
|
```
|
108
108
|
|
109
109
|
### TODO
|
110
|
-
* create yuyi gem with new
|
111
|
-
* setup (post suite install tasks)
|
112
|
-
* write to file checks for existing lines
|
113
110
|
* Enforce required options
|
114
111
|
* New roll generator (use new!)
|
115
112
|
* DOCS!
|
116
113
|
* show roll options on -l
|
117
114
|
* home brew/home brew cask roll to inherit
|
118
115
|
* installation summary
|
119
|
-
* abort install if required options arent set
|
120
|
-
* post install commands
|
121
116
|
|
122
117
|
[.](http://www.comedycentral.com/video-clips/3myds9/upright-citizens-brigade-sushi-chef)
|
data/lib/yuyi/cli.rb
CHANGED
@@ -133,9 +133,12 @@ module Yuyi::Cli
|
|
133
133
|
# Write several lines to to an existing file
|
134
134
|
#
|
135
135
|
def write_to_file file, *text
|
136
|
-
File.open(File.expand_path(file), 'a') do |file|
|
137
|
-
|
138
|
-
|
136
|
+
File.open(File.expand_path(file), 'a+') do |file|
|
137
|
+
full_text = (text * "\n") + "\n"
|
138
|
+
|
139
|
+
unless file.read.include? full_text
|
140
|
+
file.write full_text
|
141
|
+
end
|
139
142
|
end
|
140
143
|
end
|
141
144
|
|
data/lib/yuyi/menu.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
class Yuyi::Menu
|
2
2
|
@rolls = {}
|
3
|
-
@pre_installs = []
|
4
|
-
@post_installs = []
|
5
3
|
|
6
4
|
# DSL Helper methods
|
7
5
|
#
|
@@ -59,22 +57,6 @@ class Yuyi::Menu
|
|
59
57
|
@rolls[file_name] = klass.new
|
60
58
|
end
|
61
59
|
|
62
|
-
def self.add_pre_install block
|
63
|
-
@pre_installs << block
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.add_post_install block
|
67
|
-
@post_installs << block
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.pre_install
|
71
|
-
@pre_installs.each { |b| b.call }
|
72
|
-
end
|
73
|
-
|
74
|
-
def self.post_install
|
75
|
-
@post_installs.each { |b| b.call }
|
76
|
-
end
|
77
|
-
|
78
60
|
# Get/Set upgrade flag
|
79
61
|
#
|
80
62
|
def upgrade? boolean = nil
|
@@ -112,13 +94,22 @@ class Yuyi::Menu
|
|
112
94
|
# Initialize all the rolls in order
|
113
95
|
#
|
114
96
|
def order_rolls
|
115
|
-
|
97
|
+
all_rolls = sorted_rolls
|
116
98
|
|
117
|
-
|
118
|
-
|
99
|
+
# run all preinstalls first
|
100
|
+
all_rolls.each do |file_name|
|
101
|
+
rolls[file_name].appetizers
|
119
102
|
end
|
120
103
|
|
121
|
-
|
104
|
+
# then run all installs
|
105
|
+
all_rolls.each do |file_name|
|
106
|
+
rolls[file_name].entree
|
107
|
+
end
|
108
|
+
|
109
|
+
# then post installs last
|
110
|
+
all_rolls.each do |file_name|
|
111
|
+
rolls[file_name].dessert
|
112
|
+
end
|
122
113
|
end
|
123
114
|
|
124
115
|
# Find the best roll in the source to be added
|
data/lib/yuyi/roll.rb
CHANGED
@@ -13,7 +13,8 @@ class Yuyi::Roll
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.pre_install &block
|
16
|
-
Yuyi::Menu.add_pre_install
|
16
|
+
Yuyi::Menu.add_pre_install self unless @pre_install
|
17
|
+
@pre_install ||= block
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.install &block
|
@@ -21,7 +22,8 @@ class Yuyi::Roll
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def self.post_install &block
|
24
|
-
Yuyi::Menu.add_post_install
|
25
|
+
Yuyi::Menu.add_post_install self unless @post_install
|
26
|
+
@post_install ||= block
|
25
27
|
end
|
26
28
|
|
27
29
|
def self.uninstall &block
|
@@ -85,7 +87,7 @@ class Yuyi::Roll
|
|
85
87
|
|
86
88
|
# Run the roll
|
87
89
|
#
|
88
|
-
def
|
90
|
+
def install
|
89
91
|
if installed?
|
90
92
|
if options[:uninstall]
|
91
93
|
Yuyi.say "🍣\s Uninstalling #{title}...", :color => 33
|
@@ -99,6 +101,14 @@ class Yuyi::Roll
|
|
99
101
|
install
|
100
102
|
end
|
101
103
|
end
|
104
|
+
alias_method :order, :install
|
105
|
+
alias_method :entree, :install
|
106
|
+
|
107
|
+
def pre_install; pre_install; end
|
108
|
+
alias_method :appetizers, :pre_install
|
109
|
+
|
110
|
+
def post_install; post_install; end
|
111
|
+
alias_method :dessert, :pre_install
|
102
112
|
|
103
113
|
private
|
104
114
|
|
@@ -126,10 +136,18 @@ private
|
|
126
136
|
end
|
127
137
|
end
|
128
138
|
|
139
|
+
def pre_install
|
140
|
+
instance_eval(&self.class.pre_install)
|
141
|
+
end
|
142
|
+
|
129
143
|
def install
|
130
144
|
instance_eval(&self.class.install)
|
131
145
|
end
|
132
146
|
|
147
|
+
def post_install
|
148
|
+
instance_eval(&self.class.post_install)
|
149
|
+
end
|
150
|
+
|
133
151
|
def uninstall
|
134
152
|
instance_eval(&self.class.uninstall)
|
135
153
|
end
|
data/spec/lib/yuyi/cli_spec.rb
CHANGED
@@ -136,6 +136,11 @@ describe Yuyi::Cli do
|
|
136
136
|
CliTest.write_to_file 'test', 'arg1', 'arg2'
|
137
137
|
expect(File.open('test').read).to eq "foo\narg1\narg2\n"
|
138
138
|
end
|
139
|
+
|
140
|
+
it 'should not add a line if it already exists' do
|
141
|
+
CliTest.write_to_file 'test', 'foo'
|
142
|
+
expect(File.open('test').read).to eq "foo\n"
|
143
|
+
end
|
139
144
|
end
|
140
145
|
|
141
146
|
describe '#delete_from_file' do
|
data/spec/lib/yuyi/menu_spec.rb
CHANGED
@@ -26,40 +26,6 @@ describe Yuyi::Menu do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe '.pre_install' do
|
30
|
-
before do
|
31
|
-
@pre_install = lambda {}
|
32
|
-
Yuyi::Menu.instance_var :pre_installs, [@pre_install,]
|
33
|
-
allow(@pre_install).to receive(:call)
|
34
|
-
Yuyi::Menu.pre_install
|
35
|
-
end
|
36
|
-
|
37
|
-
after do
|
38
|
-
allow(@pre_install).to receive(:call).and_call_original
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should run pre_installs' do
|
42
|
-
expect(@pre_install).to have_received(:call)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '.post_install' do
|
47
|
-
before do
|
48
|
-
@post_install = lambda {}
|
49
|
-
Yuyi::Menu.instance_var :post_installs, [@post_install,]
|
50
|
-
allow(@post_install).to receive(:call)
|
51
|
-
Yuyi::Menu.post_install
|
52
|
-
end
|
53
|
-
|
54
|
-
after do
|
55
|
-
allow(@post_install).to receive(:call).and_call_original
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should run post_installs' do
|
59
|
-
expect(@post_install).to have_received(:call)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
29
|
describe '#initialize' do
|
64
30
|
it 'should set the path var' do
|
65
31
|
expect(@menu.var(:path)).to eq 'spec/fixtures/menu.yaml'
|
@@ -180,28 +146,33 @@ describe Yuyi::Menu do
|
|
180
146
|
|
181
147
|
describe '#order_rolls' do
|
182
148
|
before do
|
183
|
-
class
|
184
|
-
|
185
|
-
|
186
|
-
allow(
|
187
|
-
allow(
|
188
|
-
allow(
|
189
|
-
allow(
|
149
|
+
class MenuOrderRollsOne; end
|
150
|
+
class MenuOrderRollsTwo; end
|
151
|
+
allow(MenuOrderRollsOne).to receive :appetizers
|
152
|
+
allow(MenuOrderRollsTwo).to receive :appetizers
|
153
|
+
allow(MenuOrderRollsOne).to receive :entree
|
154
|
+
allow(MenuOrderRollsTwo).to receive :entree
|
155
|
+
allow(MenuOrderRollsOne).to receive :dessert
|
156
|
+
allow(MenuOrderRollsTwo).to receive :dessert
|
157
|
+
|
158
|
+
allow(@menu).to receive(:sorted_rolls).and_return([:menu_order_rolls_one, :menu_order_rolls_two])
|
159
|
+
allow(@menu).to receive(:rolls).and_return({ :menu_order_rolls_one => MenuOrderRollsOne, :menu_order_rolls_two => MenuOrderRollsTwo })
|
190
160
|
|
191
161
|
@menu.send :order_rolls
|
192
162
|
end
|
193
163
|
|
194
164
|
after do
|
195
|
-
allow(Yuyi::Menu).to receive(:pre_install).and_call_original
|
196
|
-
allow(Yuyi::Menu).to receive(:post_install).and_call_original
|
197
165
|
allow(@menu).to receive(:sorted_rolls).and_call_original
|
198
166
|
allow(@menu).to receive(:rolls).and_call_original
|
199
167
|
end
|
200
168
|
|
201
169
|
it 'should initialize a roll with the roll options' do
|
202
|
-
expect(
|
203
|
-
expect(
|
204
|
-
expect(
|
170
|
+
expect(MenuOrderRollsOne).to have_received(:appetizers).ordered
|
171
|
+
expect(MenuOrderRollsTwo).to have_received(:appetizers).ordered
|
172
|
+
expect(MenuOrderRollsOne).to have_received(:entree).ordered
|
173
|
+
expect(MenuOrderRollsTwo).to have_received(:entree).ordered
|
174
|
+
expect(MenuOrderRollsOne).to have_received(:dessert).ordered
|
175
|
+
expect(MenuOrderRollsTwo).to have_received(:dessert).ordered
|
205
176
|
end
|
206
177
|
end
|
207
178
|
end
|
data/spec/lib/yuyi/roll_spec.rb
CHANGED
@@ -72,7 +72,7 @@ describe Yuyi::Roll do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'should respond to .pre_install' do
|
75
|
-
expect(
|
75
|
+
expect(TestRoll.pre_install).to be_a Proc
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'should respond to .install' do
|
@@ -80,7 +80,7 @@ describe Yuyi::Roll do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should respond to .post_install' do
|
83
|
-
expect(
|
83
|
+
expect(TestRoll.post_install).to be_a Proc
|
84
84
|
end
|
85
85
|
|
86
86
|
it 'should respond to .uninstall' do
|
@@ -121,10 +121,18 @@ describe Yuyi::Roll do
|
|
121
121
|
expect(@test_roll.dependencies).to eq([:foo])
|
122
122
|
end
|
123
123
|
|
124
|
+
it 'should return the pre_install results' do
|
125
|
+
expect(@test_roll.send(:pre_install)).to eq :pre_install
|
126
|
+
end
|
127
|
+
|
124
128
|
it 'should return the install results' do
|
125
129
|
expect(@test_roll.send(:install)).to eq :install
|
126
130
|
end
|
127
131
|
|
132
|
+
it 'should return the post_install results' do
|
133
|
+
expect(@test_roll.send(:post_install)).to eq :post_install
|
134
|
+
end
|
135
|
+
|
128
136
|
it 'should return the uninstall results' do
|
129
137
|
expect(@test_roll.send(:uninstall)).to eq :uninstall
|
130
138
|
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: 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-06-
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -81,7 +81,6 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Maintain a menu of applications and services to automate the installation
|
84
|
-
of.
|
85
84
|
email: brewster1134@gmail.com
|
86
85
|
executables:
|
87
86
|
- yuyi
|