bently 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +3 -1
- data/LICENSE +7 -0
- data/README.md +38 -99
- data/bently.gemspec +3 -4
- data/bin/bently +1 -1
- data/lib/bently/base.rb +108 -0
- data/lib/bently/core_ext/string.rb +22 -24
- data/lib/bently/recipe/action-mailer.rb +8 -26
- data/lib/bently/recipe/cucumber-rails.rb +20 -0
- data/lib/bently/recipe/devise.rb +11 -13
- data/lib/bently/recipe/factory-girl-rails.rb +27 -24
- data/lib/bently/recipe/foreman-thin.rb +19 -0
- data/lib/bently/recipe/foreman.rb +17 -0
- data/lib/bently/recipe/gitignore-emacs.rb +30 -0
- data/lib/bently/recipe/gitignore-linux.rb +21 -0
- data/lib/bently/recipe/gitignore-osx.rb +30 -0
- data/lib/bently/recipe/gitignore-rails.rb +22 -38
- data/lib/bently/recipe/gitignore-ruby.rb +36 -0
- data/lib/bently/recipe/gitignore-rubymine.rb +19 -0
- data/lib/bently/recipe/gitignore-sass.rb +21 -0
- data/lib/bently/recipe/gitignore-sublime-text.rb +21 -0
- data/lib/bently/recipe/gitignore-textmate.rb +21 -0
- data/lib/bently/recipe/gitignore-vim.rb +23 -0
- data/lib/bently/recipe/gitignore-windows.rb +27 -0
- data/lib/bently/recipe/guard-livereload.rb +10 -4
- data/lib/bently/recipe/guard.rb +10 -6
- data/lib/bently/recipe/haml-rails.rb +10 -5
- data/lib/bently/recipe/heroku-cleardb.rb +25 -0
- data/lib/bently/recipe/heroku-rails.rb +23 -0
- data/lib/bently/recipe/heroku-sendgrid.rb +6 -12
- data/lib/bently/recipe/omniauth-facebook.rb +23 -0
- data/lib/bently/recipe/omniauth.rb +44 -0
- data/lib/bently/recipe/resque-rails.rb +20 -0
- data/lib/bently/recipe/rspec-rails.rb +11 -15
- data/lib/bently/recipe/rvmrc.rb +2 -9
- data/lib/bently/recipe/twitter-bootstrap-rails.rb +13 -5
- data/lib/bently/recipe.rb +90 -43
- data/lib/bently/recipe_class/rails.rb +10 -0
- data/lib/bently/recipe_class/ruby.rb +62 -0
- data/lib/bently/recipebook.rb +21 -0
- data/lib/bently/version.rb +1 -1
- data/lib/bently.rb +10 -6
- data/spec/bently/base_spec.rb +151 -0
- metadata +31 -18
- data/lib/bently/clo.rb +0 -33
- data/lib/bently/himself.rb +0 -105
- data/lib/bently/recipe/gitignore.rb +0 -23
- data/lib/bently/recipe/heroku-create.rb +0 -27
- data/lib/bently/recipe/heroku-procfile.rb +0 -14
- data/lib/bently/recipe/heroku-resque.rb +0 -79
- data/lib/bently/recipe/resque.rb +0 -10
- data/lib/bently/recipe/welcome-index.rb +0 -10
- data/lib/bently/recipe_book.rb +0 -15
- data/lib/bently/recipe_template/rails.rb +0 -13
- data/lib/bently/step.rb +0 -93
- data/spec/bently/himself_spec.rb +0 -175
data/lib/bently/recipe.rb
CHANGED
@@ -1,63 +1,110 @@
|
|
1
1
|
module Bently
|
2
|
-
|
3
|
-
module RecipeMethods
|
4
|
-
def self.extended(base)
|
5
|
-
base.send(:include, InstanceMethods) if base.is_a? Class
|
6
|
-
end
|
2
|
+
class Recipe
|
7
3
|
|
8
|
-
|
9
|
-
|
4
|
+
class Operation
|
5
|
+
def say; nil end
|
6
|
+
def after; nil end
|
10
7
|
end
|
11
8
|
|
12
|
-
|
13
|
-
|
9
|
+
class Say < Operation
|
10
|
+
attr_reader :message, :status, :color
|
11
|
+
def initialize *args
|
12
|
+
@message, @status, @color = args
|
13
|
+
end
|
14
|
+
def args
|
15
|
+
@status ? [@status,@message,@color] : [@status]
|
16
|
+
end
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
class Run < Operation
|
20
|
+
attr_reader :command
|
21
|
+
def initialize *args
|
22
|
+
@command = args.shift
|
23
|
+
end
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
class Create < Operation
|
27
|
+
attr_reader :args, :file, :data
|
28
|
+
def initialize *args
|
29
|
+
@file, @data = @args = args
|
26
30
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
def parse_steps
|
31
|
-
self.class.step_args.map do |args|
|
32
|
-
self.send(args.shift, *args)
|
33
|
-
end
|
31
|
+
def after
|
32
|
+
@data.each_line.each_with_index.map{|l,i| [i+1, l] }
|
34
33
|
end
|
35
34
|
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class Recipe
|
39
|
-
extend RecipeMethods
|
40
35
|
|
41
|
-
|
42
|
-
|
36
|
+
class Modify < Operation
|
37
|
+
attr_reader :args, :file, :pattern, :replace
|
38
|
+
def initialize *args
|
39
|
+
@file, @pattern, @replace = @args = args
|
40
|
+
end
|
41
|
+
def after
|
42
|
+
[[1,@pattern.inspect], [2,@replace.inspect]]
|
43
|
+
end
|
44
|
+
end
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
+
class Append < Operation
|
47
|
+
attr_reader :file, :data
|
48
|
+
def initialize *args
|
49
|
+
@file, @data = args
|
50
|
+
end
|
51
|
+
def args; [@file, @data] end
|
52
|
+
def after
|
53
|
+
@data.each_line.each_with_index.map{|l,i| [i+1, l] }
|
54
|
+
end
|
55
|
+
end
|
46
56
|
|
47
|
-
|
48
|
-
|
57
|
+
class Prepend < Operation
|
58
|
+
attr_reader :args, :file, :data
|
59
|
+
def initialize *args
|
60
|
+
@file, @data = @args = args
|
61
|
+
end
|
62
|
+
def after
|
63
|
+
@data.each_line.each_with_index.map{|l,i| [i+1, l] }
|
64
|
+
end
|
65
|
+
end
|
49
66
|
|
50
|
-
|
51
|
-
|
67
|
+
class Insert < Operation
|
68
|
+
attr_reader :args, :file, :data, :options
|
69
|
+
def initialize *args
|
70
|
+
@file, @data, @options = @args = args
|
71
|
+
end
|
72
|
+
def after
|
73
|
+
@data.each_line.each_with_index.map{|l,i| [i+1, l] }
|
74
|
+
end
|
75
|
+
end
|
52
76
|
|
53
|
-
|
54
|
-
|
77
|
+
class Remove < Operation
|
78
|
+
attr_reader :args, :file
|
79
|
+
def initialize *args
|
80
|
+
@args = args
|
81
|
+
@file = @args[0]
|
82
|
+
end
|
83
|
+
end
|
55
84
|
|
56
|
-
|
57
|
-
|
85
|
+
def self.breakdown
|
86
|
+
new.operations
|
87
|
+
end
|
58
88
|
|
59
|
-
|
60
|
-
def
|
89
|
+
def self.name(name) @name ||= name; end
|
90
|
+
def self.category(category) @category ||= category; end
|
91
|
+
def self.description(description) @description ||= description; end
|
92
|
+
def self.homepage(homepage=nil) @homepage ||= homepage; end
|
93
|
+
def self.version(version) @version ||= version; end
|
94
|
+
|
95
|
+
def operations; @operations ||= []; end
|
96
|
+
|
97
|
+
def say(*args) ; operations << Say.new(*args) end
|
98
|
+
def run(*args) ; operations << Run.new(*args) end
|
99
|
+
def create(*args) ; operations << Create.new(*args) end
|
100
|
+
def modify(*args) ; operations << Modify.new(*args) end
|
101
|
+
def append(*args) ; operations << Append.new(*args) end
|
102
|
+
def prepend(*args) ; operations << Prepend.new(*args) end
|
103
|
+
def insert(*args) ; operations << Insert.new(*args) end
|
104
|
+
def remove(*args) ; operations << Remove.new(*args) end
|
105
|
+
def operate(op, *args) ; operations << op.new(*args) end
|
106
|
+
def todo(name) ; say(name, 'TODO', :red) end
|
107
|
+
def warn(text) ; say(text, 'WARNING', :red) end
|
108
|
+
def requirement(text) ; say(text, 'REQUIRED', :red) end
|
61
109
|
end
|
62
|
-
|
63
110
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Bently
|
2
|
+
class RubyRecipe < Recipe
|
3
|
+
GEMFILE = 'Gemfile'
|
4
|
+
|
5
|
+
class Gem < Append
|
6
|
+
def initialize *args
|
7
|
+
super
|
8
|
+
@name = args[2]
|
9
|
+
end
|
10
|
+
def say; ['gemfile',@name] end
|
11
|
+
def args; [@file, @data, {:verbose => false}] end
|
12
|
+
end
|
13
|
+
|
14
|
+
def gem(*args)
|
15
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
16
|
+
name, version = args
|
17
|
+
|
18
|
+
# Set the message to be shown in logs. Uses the git repo if one is given,
|
19
|
+
# otherwise use name (version).
|
20
|
+
parts, message = [ name.inspect ], name
|
21
|
+
if version ||= options.delete(:version)
|
22
|
+
parts << version.inspect
|
23
|
+
message << " (#{version})"
|
24
|
+
end
|
25
|
+
message = options[:git] if options[:git]
|
26
|
+
|
27
|
+
options.each do |option, value|
|
28
|
+
parts << "#{option}: #{value.inspect}"
|
29
|
+
end
|
30
|
+
|
31
|
+
str = "gem #{parts.join(", ")}"
|
32
|
+
str = " " + str if @in_group
|
33
|
+
str = "\n" + str
|
34
|
+
|
35
|
+
if @in_group
|
36
|
+
@gems = @gems.to_s + str
|
37
|
+
else
|
38
|
+
operate Gem, GEMFILE, str, message
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def gem_group(*names, &block)
|
43
|
+
name = names.map(&:inspect).join(", ")
|
44
|
+
|
45
|
+
str = "\ngroup #{name} do"
|
46
|
+
|
47
|
+
@in_group = true
|
48
|
+
instance_eval(&block)
|
49
|
+
@in_group = false
|
50
|
+
|
51
|
+
str += @gems
|
52
|
+
str += "\nend\n"
|
53
|
+
|
54
|
+
operate Gem, GEMFILE, str
|
55
|
+
end
|
56
|
+
|
57
|
+
def bundle
|
58
|
+
run 'bundle install'
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Bently
|
2
|
+
|
3
|
+
class Recipebook
|
4
|
+
|
5
|
+
RECIPE_DIR = "#{BENTLY_REPOSITORY}/lib/bently/recipe/*.rb"
|
6
|
+
LOCAL_DIR = "#{Dir.pwd}/.bently/*.rb"
|
7
|
+
RECIPE_CLASS_DIR = "#{BENTLY_REPOSITORY}/lib/bently/recipe_class/*.rb"
|
8
|
+
|
9
|
+
def self.all
|
10
|
+
files = Dir[RECIPE_DIR].map{ |f| File.basename f, '.rb' }
|
11
|
+
files += Dir[LOCAL_DIR].map{ |f| File.basename f, '.rb' }
|
12
|
+
files.sort
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.find(recipe)
|
16
|
+
"Bently::#{recipe.camelize}".constantize
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/lib/bently/version.rb
CHANGED
data/lib/bently.rb
CHANGED
@@ -2,16 +2,20 @@ require 'thor'
|
|
2
2
|
|
3
3
|
require 'bently/core_ext/string'
|
4
4
|
require 'bently/globals'
|
5
|
-
require 'bently/step'
|
6
5
|
require 'bently/recipe'
|
7
|
-
require 'bently/
|
8
|
-
require 'bently/
|
9
|
-
require 'bently/clo'
|
10
|
-
require 'bently/himself'
|
6
|
+
require 'bently/recipebook'
|
7
|
+
require 'bently/base'
|
11
8
|
|
12
|
-
Dir[Bently::
|
9
|
+
Dir[Bently::Recipebook::RECIPE_CLASS_DIR].map do |f|
|
10
|
+
File.basename f, '.rb'
|
11
|
+
end.each do |f|
|
12
|
+
require 'bently/recipe_class/' + f
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir[Bently::Recipebook::RECIPE_DIR].map do |f|
|
13
16
|
File.basename f, '.rb'
|
14
17
|
end.each do |f|
|
15
18
|
require 'bently/recipe/' + f
|
16
19
|
end
|
17
20
|
|
21
|
+
Dir[Bently::Recipebook::LOCAL_DIR].each {|file| require file }
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bently::Base do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@bently = Bently::Base.new
|
7
|
+
@bently.stub(:`)
|
8
|
+
@bently.stub(:run)
|
9
|
+
@bently.stub(:create_file)
|
10
|
+
@bently.stub(:append_to_file)
|
11
|
+
@bently.stub(:prepend_to_file)
|
12
|
+
@bently.stub(:gsub_file)
|
13
|
+
@bently.stub(:insert_into_file)
|
14
|
+
@bently.stub(:remove_file)
|
15
|
+
@bently.stub(:yes?)
|
16
|
+
@bently.stub(:ask)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
describe "#read" do
|
21
|
+
before do
|
22
|
+
@recipe_class = Class.new(Bently::Recipe){
|
23
|
+
def initialize; run 'echo knead the dough' end
|
24
|
+
}
|
25
|
+
Bently::Recipebook.stub(:find).and_return(@recipe_class)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "triggers the operation" do
|
29
|
+
@bently.should_receive(:run)
|
30
|
+
@bently.read 'recipe'
|
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
|
+
end
|
44
|
+
|
45
|
+
context "given a run operation" do
|
46
|
+
before do
|
47
|
+
@recipe_class = Class.new(Bently::Recipe){
|
48
|
+
def initialize; run 'echo foobar' end
|
49
|
+
}
|
50
|
+
Bently::Recipebook.stub(:find).and_return(@recipe_class)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "performs the operation" do
|
54
|
+
@bently.should_receive(:run).with('echo foobar').and_return(nil)
|
55
|
+
@bently.bake 'recipe'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
context "given a create operation" do
|
61
|
+
before do
|
62
|
+
@recipe_class = Class.new(Bently::Recipe){
|
63
|
+
def initialize; create 'file.rb', 'abc' end
|
64
|
+
}
|
65
|
+
Bently::Recipebook.stub(:find).and_return(@recipe_class)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "performs the operation" do
|
69
|
+
@bently.should_receive(:create_file).with('file.rb','abc')
|
70
|
+
@bently.bake 'recipe'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
context "given a modify operation" do
|
76
|
+
before do
|
77
|
+
@recipe_class = Class.new(Bently::Recipe){
|
78
|
+
def initialize; modify 'file.rb', /dog/, 'abc' end
|
79
|
+
}
|
80
|
+
Bently::Recipebook.stub(:find).and_return(@recipe_class)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "performs the operation" do
|
84
|
+
@bently.should_receive(:gsub_file).with('file.rb', /dog/, 'abc')
|
85
|
+
@bently.bake 'recipe'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
context "given an append operation" do
|
91
|
+
before do
|
92
|
+
@recipe_class = Class.new(Bently::Recipe){
|
93
|
+
def initialize; append 'file.rb', 'abc' end
|
94
|
+
}
|
95
|
+
Bently::Recipebook.stub(:find).and_return(@recipe_class)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "performs the operation" do
|
99
|
+
@bently.should_receive(:append_to_file).with('file.rb',"abc")
|
100
|
+
@bently.bake 'recipe'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
context "given a prepend operation" do
|
106
|
+
before do
|
107
|
+
@recipe_class = Class.new(Bently::Recipe){
|
108
|
+
def initialize; prepend 'file.rb', 'abc' end
|
109
|
+
}
|
110
|
+
Bently::Recipebook.stub(:find).and_return(@recipe_class)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "performs the operation" do
|
114
|
+
@bently.should_receive(:prepend_to_file).with('file.rb',"abc")
|
115
|
+
@bently.bake 'recipe'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
context "given an insert operation" do
|
121
|
+
before do
|
122
|
+
@recipe_class = Class.new(Bently::Recipe){
|
123
|
+
def initialize; insert 'file.rb', 'abc', :after => 'whatever\n' end
|
124
|
+
}
|
125
|
+
Bently::Recipebook.stub(:find).and_return(@recipe_class)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "performs the operation" do
|
129
|
+
@bently.should_receive(:insert_into_file).with('file.rb','abc',:after => 'whatever\n')
|
130
|
+
@bently.bake 'recipe'
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
context "given a remove operation" do
|
136
|
+
before do
|
137
|
+
@recipe_class = Class.new(Bently::Recipe){
|
138
|
+
def initialize; remove 'file.rb' end
|
139
|
+
}
|
140
|
+
Bently::Recipebook.stub(:find).and_return(@recipe_class)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "performs the operation" do
|
144
|
+
@bently.should_receive(:remove_file).with('file.rb')
|
145
|
+
@bently.bake 'recipe'
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
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:
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -43,48 +43,61 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '2.6'
|
46
|
-
description: Bently
|
47
|
-
|
48
|
-
email:
|
46
|
+
description: Bently is a community maintained library of recipes for the installation
|
47
|
+
and configuration of application-level dependencies
|
48
|
+
email: ruby-bently@googlegroups.com
|
49
49
|
executables:
|
50
50
|
- bently
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
54
|
- .gitignore
|
55
|
+
- .travis.yml
|
55
56
|
- Gemfile
|
56
57
|
- Gemfile.lock
|
58
|
+
- LICENSE
|
57
59
|
- README.md
|
58
60
|
- bently.gemspec
|
59
61
|
- bin/bently
|
60
62
|
- lib/bently.rb
|
61
|
-
- lib/bently/
|
63
|
+
- lib/bently/base.rb
|
62
64
|
- lib/bently/core_ext/string.rb
|
63
65
|
- lib/bently/globals.rb
|
64
|
-
- lib/bently/himself.rb
|
65
66
|
- lib/bently/recipe.rb
|
66
67
|
- lib/bently/recipe/action-mailer.rb
|
68
|
+
- lib/bently/recipe/cucumber-rails.rb
|
67
69
|
- lib/bently/recipe/devise.rb
|
68
70
|
- lib/bently/recipe/factory-girl-rails.rb
|
71
|
+
- lib/bently/recipe/foreman-thin.rb
|
72
|
+
- lib/bently/recipe/foreman.rb
|
73
|
+
- lib/bently/recipe/gitignore-emacs.rb
|
74
|
+
- lib/bently/recipe/gitignore-linux.rb
|
75
|
+
- lib/bently/recipe/gitignore-osx.rb
|
69
76
|
- lib/bently/recipe/gitignore-rails.rb
|
70
|
-
- lib/bently/recipe/gitignore.rb
|
77
|
+
- lib/bently/recipe/gitignore-ruby.rb
|
78
|
+
- lib/bently/recipe/gitignore-rubymine.rb
|
79
|
+
- lib/bently/recipe/gitignore-sass.rb
|
80
|
+
- lib/bently/recipe/gitignore-sublime-text.rb
|
81
|
+
- lib/bently/recipe/gitignore-textmate.rb
|
82
|
+
- lib/bently/recipe/gitignore-vim.rb
|
83
|
+
- lib/bently/recipe/gitignore-windows.rb
|
71
84
|
- lib/bently/recipe/guard-livereload.rb
|
72
85
|
- lib/bently/recipe/guard.rb
|
73
86
|
- lib/bently/recipe/haml-rails.rb
|
74
|
-
- lib/bently/recipe/heroku-
|
75
|
-
- lib/bently/recipe/heroku-
|
76
|
-
- lib/bently/recipe/heroku-resque.rb
|
87
|
+
- lib/bently/recipe/heroku-cleardb.rb
|
88
|
+
- lib/bently/recipe/heroku-rails.rb
|
77
89
|
- lib/bently/recipe/heroku-sendgrid.rb
|
78
|
-
- lib/bently/recipe/
|
90
|
+
- lib/bently/recipe/omniauth-facebook.rb
|
91
|
+
- lib/bently/recipe/omniauth.rb
|
92
|
+
- lib/bently/recipe/resque-rails.rb
|
79
93
|
- lib/bently/recipe/rspec-rails.rb
|
80
94
|
- lib/bently/recipe/rvmrc.rb
|
81
95
|
- lib/bently/recipe/twitter-bootstrap-rails.rb
|
82
|
-
- lib/bently/
|
83
|
-
- lib/bently/
|
84
|
-
- lib/bently/
|
85
|
-
- lib/bently/step.rb
|
96
|
+
- lib/bently/recipe_class/rails.rb
|
97
|
+
- lib/bently/recipe_class/ruby.rb
|
98
|
+
- lib/bently/recipebook.rb
|
86
99
|
- lib/bently/version.rb
|
87
|
-
- spec/bently/
|
100
|
+
- spec/bently/base_spec.rb
|
88
101
|
- spec/spec_helper.rb
|
89
102
|
homepage: http://github.com/bonsaiben/bently
|
90
103
|
licenses: []
|
@@ -109,5 +122,5 @@ rubyforge_project:
|
|
109
122
|
rubygems_version: 1.8.24
|
110
123
|
signing_key:
|
111
124
|
specification_version: 3
|
112
|
-
summary:
|
125
|
+
summary: Application-level dependency installation/configuration recipe manager
|
113
126
|
test_files: []
|
data/lib/bently/clo.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
module Bently
|
2
|
-
|
3
|
-
module CLO
|
4
|
-
TAB_SPACES = 6
|
5
|
-
|
6
|
-
protected
|
7
|
-
|
8
|
-
# prompt arrow
|
9
|
-
def bullet(text); puts "#{magenta('==>')} #{bold(text)}" end
|
10
|
-
def listout(text,num); puts magenta("#{num}. #{text}") end
|
11
|
-
|
12
|
-
# blockquote
|
13
|
-
def blockquote text
|
14
|
-
text = text.split("\n") unless text.is_a?(Array)
|
15
|
-
text.each do |text|
|
16
|
-
puts tab(text)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# colorizes text
|
21
|
-
def colorize(text, color_code)
|
22
|
-
"#{color_code}#{text}\033[0m"
|
23
|
-
end
|
24
|
-
|
25
|
-
def red(text); colorize(text, "\033[31m"); end
|
26
|
-
def green(text); colorize(text, "\033[32m"); end
|
27
|
-
def magenta(text); colorize(text, "\033[35m"); end
|
28
|
-
def light_green(text); colorize(text, "\033[32m"); end
|
29
|
-
def bold(text); "\033[1m#{text}\033[22m"; end
|
30
|
-
def tab(text); "#{' '*TAB_SPACES}#{text}" end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
data/lib/bently/himself.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
module Bently
|
2
|
-
|
3
|
-
class Himself < Thor
|
4
|
-
include Thor::Actions
|
5
|
-
include CLO
|
6
|
-
|
7
|
-
desc 'list', 'list recipes'
|
8
|
-
def list
|
9
|
-
RecipeBook.all.each {|f| puts f }
|
10
|
-
end
|
11
|
-
|
12
|
-
desc 'read [RECIPE]', 'display a recipe'
|
13
|
-
def read recipe
|
14
|
-
recipe = RecipeBook.find(recipe).new
|
15
|
-
recipe.steps.each_with_index do |step,i|
|
16
|
-
read_step step, i+1
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
desc 'bake [RECIPE]', 'execute a recipe'
|
21
|
-
def bake recipe
|
22
|
-
recipe = RecipeBook.find(recipe).new
|
23
|
-
recipe.steps.each_with_index do |step,i|
|
24
|
-
read_step step, i+1
|
25
|
-
if confirmed_step? step
|
26
|
-
bake_step step
|
27
|
-
else
|
28
|
-
cancel_step
|
29
|
-
exit if step.fail_on_skip?
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
protected
|
35
|
-
|
36
|
-
def read_step step, num
|
37
|
-
text = step.description.split("\n")
|
38
|
-
listout text.shift, num
|
39
|
-
blockquote text if text.any?
|
40
|
-
end
|
41
|
-
|
42
|
-
def confirmed_step? step
|
43
|
-
yes? tab(magenta("#{step.action}?"))
|
44
|
-
end
|
45
|
-
|
46
|
-
def cancel_step
|
47
|
-
puts red(tab('skipped'))
|
48
|
-
end
|
49
|
-
|
50
|
-
def bake_step step
|
51
|
-
if step.is_a?(StepShell)
|
52
|
-
execute step
|
53
|
-
elsif step.is_a?(StepTouch)
|
54
|
-
touch step
|
55
|
-
elsif step.is_a?(StepModify)
|
56
|
-
modify step
|
57
|
-
elsif step.is_a?(StepAppend)
|
58
|
-
append step
|
59
|
-
elsif step.is_a?(StepPrepend)
|
60
|
-
prepend step
|
61
|
-
elsif step.is_a?(StepInsert)
|
62
|
-
insert step
|
63
|
-
elsif step.is_a?(StepRemove)
|
64
|
-
remove step
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def execute step
|
69
|
-
command = step.command
|
70
|
-
if command.is_a?(Proc)
|
71
|
-
resp = ask(tab(magenta(step.question)))
|
72
|
-
command = command.yield(resp)
|
73
|
-
end
|
74
|
-
puts `#{command}`
|
75
|
-
end
|
76
|
-
|
77
|
-
def touch step
|
78
|
-
create_file(step.file, step.data)
|
79
|
-
end
|
80
|
-
|
81
|
-
def modify step
|
82
|
-
gsub_file step.file, step.pattern, step.replacement
|
83
|
-
end
|
84
|
-
|
85
|
-
def append step
|
86
|
-
create_file(step.file) unless File.exists? step.file
|
87
|
-
append_to_file step.file, "#{step.data}\n"
|
88
|
-
end
|
89
|
-
|
90
|
-
def prepend step
|
91
|
-
create_file(step.file) unless File.exists? step.file
|
92
|
-
prepend_to_file step.file, "\n#{step.data}"
|
93
|
-
end
|
94
|
-
|
95
|
-
def insert step
|
96
|
-
insert_into_file step.file, step.data, step.options
|
97
|
-
end
|
98
|
-
|
99
|
-
def remove step
|
100
|
-
remove_file step.file
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|