bently 0.0.0 → 0.1.0
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.
- data/Gemfile +2 -2
- data/Gemfile.lock +18 -0
- data/README.md +123 -0
- data/bently.gemspec +5 -1
- data/bin/bently +2 -6
- data/lib/bently/clo.rb +33 -0
- data/lib/bently/himself.rb +105 -0
- data/lib/bently/recipe/action-mailer.rb +82 -0
- data/lib/bently/recipe/devise.rb +13 -11
- data/lib/bently/recipe/factory-girl-rails.rb +35 -0
- data/lib/bently/recipe/gitignore-rails.rb +52 -0
- data/lib/bently/recipe/gitignore.rb +12 -7
- data/lib/bently/recipe/guard-livereload.rb +11 -0
- data/lib/bently/recipe/guard.rb +11 -0
- data/lib/bently/recipe/haml-rails.rb +4 -9
- data/lib/bently/recipe/heroku-create.rb +27 -0
- data/lib/bently/recipe/heroku-procfile.rb +14 -0
- data/lib/bently/recipe/heroku-resque.rb +79 -0
- data/lib/bently/recipe/heroku-sendgrid.rb +37 -0
- data/lib/bently/recipe/resque.rb +5 -1
- data/lib/bently/recipe/rspec-rails.rb +16 -11
- data/lib/bently/recipe/rvmrc.rb +18 -0
- data/lib/bently/recipe/twitter-bootstrap-rails.rb +4 -10
- data/lib/bently/recipe/welcome-index.rb +2 -10
- data/lib/bently/recipe.rb +37 -107
- data/lib/bently/recipe_book.rb +15 -0
- data/lib/bently/recipe_template/rails.rb +13 -0
- data/lib/bently/step.rb +93 -0
- data/lib/bently/version.rb +5 -0
- data/lib/bently.rb +11 -1
- data/spec/bently/himself_spec.rb +175 -0
- data/spec/spec_helper.rb +24 -0
- metadata +43 -6
- data/lib/bently/cli.rb +0 -27
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bently::Himself do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@bently = Bently::Himself.new
|
7
|
+
@bently.stub(:`)
|
8
|
+
@bently.stub(:create_file)
|
9
|
+
@bently.stub(:append_to_file)
|
10
|
+
@bently.stub(:prepend_to_file)
|
11
|
+
@bently.stub(:gsub_file)
|
12
|
+
@bently.stub(:insert_into_file)
|
13
|
+
@bently.stub(:yes?)
|
14
|
+
@bently.stub(:ask)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#read" do
|
18
|
+
before do
|
19
|
+
@recipe_class = Class.new(Bently::Recipe){
|
20
|
+
step :shell, 'echo knead the dough'
|
21
|
+
}
|
22
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "outputs the step" do
|
26
|
+
out = capture_stdout do
|
27
|
+
@bently.read 'recipe'
|
28
|
+
end
|
29
|
+
|
30
|
+
out.string.should_not be_blank
|
31
|
+
end
|
32
|
+
|
33
|
+
it "doesn't execute any commands" do
|
34
|
+
@bently.should_receive(:`).exactly(0).times
|
35
|
+
@bently.read 'recipe'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
describe "#bake" do
|
41
|
+
before do
|
42
|
+
STDOUT.stub(:puts).and_return(true)
|
43
|
+
@bently.stub(:yes?).and_return(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
context "given an shell step" do
|
47
|
+
before do
|
48
|
+
@recipe_class = Class.new(Bently::Recipe){
|
49
|
+
step :shell, 'echo command'
|
50
|
+
}
|
51
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "executes the step" do
|
55
|
+
@bently.should_receive(:`).with('echo command').and_return(nil)
|
56
|
+
@bently.bake 'recipe'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "given a touch step" do
|
61
|
+
before do
|
62
|
+
@recipe_class = Class.new(Bently::Recipe){
|
63
|
+
step :touch, :file => 'file.rb', :with => 'abc'
|
64
|
+
}
|
65
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "executes the step" do
|
69
|
+
@bently.should_receive(:create_file).with('file.rb','abc')
|
70
|
+
@bently.bake 'recipe'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "given a modify step" do
|
75
|
+
before do
|
76
|
+
@recipe_class = Class.new(Bently::Recipe){
|
77
|
+
step :modify, :file => 'file.rb', :from => /dog/, :to => 'abc'
|
78
|
+
}
|
79
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "executes the step" do
|
83
|
+
@bently.should_receive(:gsub_file).with('file.rb',/dog/,'abc')
|
84
|
+
@bently.bake 'recipe'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "given an append step" do
|
89
|
+
before do
|
90
|
+
@recipe_class = Class.new(Bently::Recipe){
|
91
|
+
step :append, :file => 'file.rb', :with => 'abc'
|
92
|
+
}
|
93
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "executes the step" do
|
97
|
+
@bently.should_receive(:append_to_file).with('file.rb',"abc\n")
|
98
|
+
@bently.bake 'recipe'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "given a prepend step" do
|
103
|
+
before do
|
104
|
+
@recipe_class = Class.new(Bently::Recipe){
|
105
|
+
step :prepend, :file => 'file.rb', :with => 'abc'
|
106
|
+
}
|
107
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "executes the step" do
|
111
|
+
@bently.should_receive(:prepend_to_file).with('file.rb',"\nabc")
|
112
|
+
@bently.bake 'recipe'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context "given an insert step" do
|
117
|
+
before do
|
118
|
+
@recipe_class = Class.new(Bently::Recipe){
|
119
|
+
step :insert, :file => 'file.rb', :with => 'abc', :after => 'whatever\n'
|
120
|
+
}
|
121
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "executes the step" do
|
125
|
+
@bently.should_receive(:insert_into_file).with('file.rb','abc',:after => 'whatever\n')
|
126
|
+
@bently.bake 'recipe'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "given a remove step" do
|
131
|
+
before do
|
132
|
+
@recipe_class = Class.new(Bently::Recipe){
|
133
|
+
step :remove, :file => 'file.rb'
|
134
|
+
}
|
135
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "executes the step" do
|
139
|
+
@bently.should_receive(:remove_file).with('file.rb')
|
140
|
+
@bently.bake 'recipe'
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context "given a custom step" do
|
145
|
+
before do
|
146
|
+
@recipe_class = Class.new(Bently::Recipe){
|
147
|
+
step :add_gem, "gem 'wallabe'"
|
148
|
+
def add_gem(*args); shell("echo #{args.first}") end
|
149
|
+
}
|
150
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "executes the step" do
|
154
|
+
@bently.should_receive(:`).with("echo gem 'wallabe'")
|
155
|
+
@bently.bake 'recipe'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "given a shell step with a lambda" do
|
160
|
+
before do
|
161
|
+
@recipe_class = Class.new(Bently::Recipe){
|
162
|
+
step :shell, lambda{|x| "echo #{x}" }
|
163
|
+
}
|
164
|
+
Bently::RecipeBook.stub(:find).and_return(@recipe_class)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "executes the step" do
|
168
|
+
@bently.should_receive(:`).with("echo wallabe")
|
169
|
+
@bently.should_receive(:ask).and_return("wallabe")
|
170
|
+
@bently.bake 'recipe'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bently'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module Kernel
|
5
|
+
|
6
|
+
def capture_stdout
|
7
|
+
out = StringIO.new
|
8
|
+
$stdout = out
|
9
|
+
yield
|
10
|
+
return out
|
11
|
+
ensure
|
12
|
+
$stdout = STDOUT
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
class String
|
19
|
+
def blank?; self=='' end
|
20
|
+
end
|
21
|
+
|
22
|
+
class NilClass
|
23
|
+
def blank?; true end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bently
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-09-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,28 @@ dependencies:
|
|
21
21
|
version: 0.14.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.14.6
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.6'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.6'
|
25
46
|
description: Bently executes (bakes) predefined formulas (recipes) for trivial stuff
|
26
47
|
you do a lot
|
27
48
|
email: bsullivan2@gmail.com
|
@@ -37,17 +58,34 @@ files:
|
|
37
58
|
- bently.gemspec
|
38
59
|
- bin/bently
|
39
60
|
- lib/bently.rb
|
40
|
-
- lib/bently/
|
61
|
+
- lib/bently/clo.rb
|
41
62
|
- lib/bently/core_ext/string.rb
|
42
63
|
- lib/bently/globals.rb
|
64
|
+
- lib/bently/himself.rb
|
43
65
|
- lib/bently/recipe.rb
|
66
|
+
- lib/bently/recipe/action-mailer.rb
|
44
67
|
- lib/bently/recipe/devise.rb
|
68
|
+
- lib/bently/recipe/factory-girl-rails.rb
|
69
|
+
- lib/bently/recipe/gitignore-rails.rb
|
45
70
|
- lib/bently/recipe/gitignore.rb
|
71
|
+
- lib/bently/recipe/guard-livereload.rb
|
72
|
+
- lib/bently/recipe/guard.rb
|
46
73
|
- lib/bently/recipe/haml-rails.rb
|
74
|
+
- lib/bently/recipe/heroku-create.rb
|
75
|
+
- lib/bently/recipe/heroku-procfile.rb
|
76
|
+
- lib/bently/recipe/heroku-resque.rb
|
77
|
+
- lib/bently/recipe/heroku-sendgrid.rb
|
47
78
|
- lib/bently/recipe/resque.rb
|
48
79
|
- lib/bently/recipe/rspec-rails.rb
|
80
|
+
- lib/bently/recipe/rvmrc.rb
|
49
81
|
- lib/bently/recipe/twitter-bootstrap-rails.rb
|
50
82
|
- lib/bently/recipe/welcome-index.rb
|
83
|
+
- lib/bently/recipe_book.rb
|
84
|
+
- lib/bently/recipe_template/rails.rb
|
85
|
+
- lib/bently/step.rb
|
86
|
+
- lib/bently/version.rb
|
87
|
+
- spec/bently/himself_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
51
89
|
homepage: http://github.com/bonsaiben/bently
|
52
90
|
licenses: []
|
53
91
|
post_install_message:
|
@@ -68,9 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
106
|
version: '0'
|
69
107
|
requirements: []
|
70
108
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.8.
|
109
|
+
rubygems_version: 1.8.24
|
72
110
|
signing_key:
|
73
111
|
specification_version: 3
|
74
112
|
summary: Bently executes (bakes) predefined formulas (recipes)
|
75
113
|
test_files: []
|
76
|
-
has_rdoc:
|
data/lib/bently/cli.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Bently
|
2
|
-
|
3
|
-
class CLI < Thor
|
4
|
-
include Thor::Actions
|
5
|
-
|
6
|
-
desc 'list', 'list recipes'
|
7
|
-
def list
|
8
|
-
Recipe.list.each {|f| puts f }
|
9
|
-
end
|
10
|
-
|
11
|
-
desc 'read [RECIPE]', 'display a recipe'
|
12
|
-
def read recipe_name
|
13
|
-
bake recipe_name, true
|
14
|
-
end
|
15
|
-
|
16
|
-
desc 'bake [RECIPE]', 'execute a recipe'
|
17
|
-
def bake(recipe_name, read_only=false)
|
18
|
-
if Recipe.list.include?(recipe_name)
|
19
|
-
recipe = Recipe.from_name(recipe_name).new(:read_only => read_only)
|
20
|
-
recipe.bake
|
21
|
-
else
|
22
|
-
puts "Recipe not found."
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|