bently 0.1.0 → 1.0.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.
Files changed (58) hide show
  1. data/.travis.yml +6 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +3 -1
  4. data/LICENSE +7 -0
  5. data/README.md +38 -99
  6. data/bently.gemspec +3 -4
  7. data/bin/bently +1 -1
  8. data/lib/bently/base.rb +108 -0
  9. data/lib/bently/core_ext/string.rb +22 -24
  10. data/lib/bently/recipe/action-mailer.rb +8 -26
  11. data/lib/bently/recipe/cucumber-rails.rb +20 -0
  12. data/lib/bently/recipe/devise.rb +11 -13
  13. data/lib/bently/recipe/factory-girl-rails.rb +27 -24
  14. data/lib/bently/recipe/foreman-thin.rb +19 -0
  15. data/lib/bently/recipe/foreman.rb +17 -0
  16. data/lib/bently/recipe/gitignore-emacs.rb +30 -0
  17. data/lib/bently/recipe/gitignore-linux.rb +21 -0
  18. data/lib/bently/recipe/gitignore-osx.rb +30 -0
  19. data/lib/bently/recipe/gitignore-rails.rb +22 -38
  20. data/lib/bently/recipe/gitignore-ruby.rb +36 -0
  21. data/lib/bently/recipe/gitignore-rubymine.rb +19 -0
  22. data/lib/bently/recipe/gitignore-sass.rb +21 -0
  23. data/lib/bently/recipe/gitignore-sublime-text.rb +21 -0
  24. data/lib/bently/recipe/gitignore-textmate.rb +21 -0
  25. data/lib/bently/recipe/gitignore-vim.rb +23 -0
  26. data/lib/bently/recipe/gitignore-windows.rb +27 -0
  27. data/lib/bently/recipe/guard-livereload.rb +10 -4
  28. data/lib/bently/recipe/guard.rb +10 -6
  29. data/lib/bently/recipe/haml-rails.rb +10 -5
  30. data/lib/bently/recipe/heroku-cleardb.rb +25 -0
  31. data/lib/bently/recipe/heroku-rails.rb +23 -0
  32. data/lib/bently/recipe/heroku-sendgrid.rb +6 -12
  33. data/lib/bently/recipe/omniauth-facebook.rb +23 -0
  34. data/lib/bently/recipe/omniauth.rb +44 -0
  35. data/lib/bently/recipe/resque-rails.rb +20 -0
  36. data/lib/bently/recipe/rspec-rails.rb +11 -15
  37. data/lib/bently/recipe/rvmrc.rb +2 -9
  38. data/lib/bently/recipe/twitter-bootstrap-rails.rb +13 -5
  39. data/lib/bently/recipe.rb +90 -43
  40. data/lib/bently/recipe_class/rails.rb +10 -0
  41. data/lib/bently/recipe_class/ruby.rb +62 -0
  42. data/lib/bently/recipebook.rb +21 -0
  43. data/lib/bently/version.rb +1 -1
  44. data/lib/bently.rb +10 -6
  45. data/spec/bently/base_spec.rb +151 -0
  46. metadata +31 -18
  47. data/lib/bently/clo.rb +0 -33
  48. data/lib/bently/himself.rb +0 -105
  49. data/lib/bently/recipe/gitignore.rb +0 -23
  50. data/lib/bently/recipe/heroku-create.rb +0 -27
  51. data/lib/bently/recipe/heroku-procfile.rb +0 -14
  52. data/lib/bently/recipe/heroku-resque.rb +0 -79
  53. data/lib/bently/recipe/resque.rb +0 -10
  54. data/lib/bently/recipe/welcome-index.rb +0 -10
  55. data/lib/bently/recipe_book.rb +0 -15
  56. data/lib/bently/recipe_template/rails.rb +0 -13
  57. data/lib/bently/step.rb +0 -93
  58. data/spec/bently/himself_spec.rb +0 -175
@@ -1,23 +0,0 @@
1
- module Bently
2
-
3
- class Gitignore < Recipe
4
-
5
- step :touch_gitignore
6
-
7
- protected
8
-
9
- def touch_gitignore
10
- touch :file => '.gitignore', :with => gitignore
11
- end
12
-
13
- def gitignore
14
- %{.DS_Store
15
- .rvmrc
16
- *.swap
17
- *.swo
18
- *.swp}
19
- end
20
-
21
- end
22
-
23
- end
@@ -1,27 +0,0 @@
1
- module Bently
2
-
3
- class HerokuCreate < Recipe
4
-
5
- step :add_pg_gem
6
- step :shell, 'bundle install'
7
- step :shell, 'git add Gemfile Gemfile.lock'
8
- step :shell, 'git commit -m "use pg instead of sqlite3"'
9
- step :shell, 'heroku create'
10
- step :shell, 'git push heroku master'
11
- step :shell, 'heroku ps'
12
- step :shell, 'heroku open'
13
- step :shell, 'heroku run rake db:migrate'
14
-
15
- protected
16
-
17
- def add_pg_gem
18
- modify(
19
- :file => 'Gemfile',
20
- :from => /gem 'sqlite3'/,
21
- :to => "gem 'pg'"
22
- )
23
- end
24
-
25
- end
26
-
27
- end
@@ -1,14 +0,0 @@
1
- module Bently
2
-
3
- class HerokuProcfile < RailsRecipe
4
-
5
- step :add_gem, "gem 'thin'"
6
- step :shell, 'bundle install'
7
- step :append, :file => 'Procfile', :with => 'web: bundle exec thin start -p $PORT -e $RACK_ENV'
8
- step :shell, 'gem install foreman'
9
- step :shell, 'echo "RACK_ENV=development" >>.env'
10
- step :shell, 'foreman start'
11
-
12
- end
13
-
14
- end
@@ -1,79 +0,0 @@
1
- module Bently
2
-
3
- class HerokuResque < RailsRecipe
4
-
5
- step :shell, 'echo', :description => "WARNING:\nSome steps in this recipe may incur fees to your Heroku account. By proceeding you agree to bear full responsibility for fees charged to you as a result.", :action => 'proceed', :fail_on_skip => true
6
- step :add_gem, "gem 'resque', \"~> 1.22.0\""
7
- step :shell, 'bundle install'
8
- step :append, :file => 'Procfile', :with => 'resque: env TERM_CHILD=1 bundle exec rake jobs:work'
9
- step :touch_rakefile
10
- step :touch_sample_worker
11
- step :prepend, :file => 'config/routes.rb', :with => "require 'resque/server'"
12
- step :mount_resque_server
13
- step :shell, "heroku addons:add redistogo:nano"
14
- step :shell, 'heroku config | grep REDISTOGO_URL'
15
- step :touch_resque_initializer
16
- step :shell, 'echo REDISTOGO_URL=redis://localhost:6379 >> .env;more .env'
17
- step :shell, 'heroku ps:scale resque=1'
18
-
19
- protected
20
-
21
- def touch_rakefile
22
- touch(
23
- :file => "./lib/tasks/resque.rake",
24
- :with => rakefile
25
- )
26
- end
27
-
28
- def rakefile
29
- %{require 'resque/tasks'
30
-
31
- task "resque:setup" => :environment do
32
- ENV['QUEUE'] = '*'
33
- end
34
-
35
- desc "Alias for resque:work (To run workers on Heroku)"
36
- task "jobs:work" => "resque:work"}
37
- end
38
-
39
- def touch_sample_worker
40
- touch(
41
- :file => './app/workers/sample_worker.rb',
42
- :with => sample_worker
43
- )
44
- end
45
-
46
- def sample_worker
47
- %{# class SampleWorker
48
- # @queue = :sample
49
- #
50
- # def self.perform(resource_id)
51
- # resource = Resource.find(resource_id)
52
- # resource.do_something!
53
- # end
54
- # end}
55
- end
56
-
57
- def mount_resque_server
58
- insert(
59
- :file => 'config/routes.rb',
60
- :with => " mount Resque::Server.new, :at => \"/resque\"\n",
61
- :after => "Application.routes.draw do\n"
62
- )
63
- end
64
-
65
- def touch_resque_initializer
66
- touch :file => 'config/initializers/resque.rb', :with => resque_initializer
67
- end
68
-
69
- def resque_initializer
70
- %{# don't initialize unless ENV hash is present
71
- if ENV["REDISTOGO_URL"].present?
72
- uri = URI.parse(ENV["REDISTOGO_URL"])
73
- Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
74
- end}
75
- end
76
-
77
- end
78
-
79
- end
@@ -1,10 +0,0 @@
1
- module Bently
2
-
3
- class Resque < RailsRecipe
4
-
5
- step :add_gem, "gem 'resque'"
6
- step :shell, 'bundle install'
7
-
8
- end
9
-
10
- end
@@ -1,10 +0,0 @@
1
- module Bently
2
-
3
- class WelcomeIndex < Recipe
4
-
5
- step :shell, 'bundle exec rails g controller welcome index'
6
- step :modify, :file => 'config/routes.rb', :from => /#\s*(root :to => 'welcome#index')/, :to => '\1'
7
-
8
- end
9
-
10
- end
@@ -1,15 +0,0 @@
1
- module Bently
2
-
3
- class RecipeBook
4
-
5
- RECIPE_DIR = "#{BENTLY_REPOSITORY}/lib/bently/recipe/*.rb"
6
-
7
- def self.all
8
- Dir[RECIPE_DIR].map{ |f| File.basename f, '.rb' }.sort
9
- end
10
-
11
- def self.find(recipe)
12
- "Bently::#{recipe.camelize}".constantize
13
- end
14
- end
15
- end
@@ -1,13 +0,0 @@
1
- module Bently
2
-
3
- class RailsRecipe < Recipe
4
- GEMFILE = 'Gemfile'
5
-
6
- # step :add_gem, "gem 'rails'"
7
- def add_gem *args
8
- data = args.shift
9
- append :file => GEMFILE, :with => data
10
- end
11
- end
12
-
13
- end
data/lib/bently/step.rb DELETED
@@ -1,93 +0,0 @@
1
- module Bently
2
-
3
- class Step
4
- def initialize(*args)
5
- end
6
- def question; nil end
7
- def fail_on_skip?; false end
8
- end
9
-
10
- class StepShell < Step
11
- attr_reader :command
12
- def initialize(*args)
13
- @command = args.shift
14
- @options = args.first || {}
15
- end
16
- def action; @options[:action] || 'execute' end
17
- def question; @options[:ask] end
18
- def description
19
- return @options[:description] if @options[:description]
20
- command_desc = command
21
- if command_desc.is_a?(Proc)
22
- placeholder = '...'
23
- command_desc = command_desc.yield(placeholder)
24
- end
25
- "Execute:\n#{command_desc}"
26
- end
27
- def fail_on_skip?; @options[:fail_on_skip] end
28
- end
29
-
30
- class StepTouch < Step
31
- attr_reader :file, :data
32
- def initialize(*args)
33
- opts = args.first
34
- @file, @data = [:file,:with].map{|k| opts[k]}
35
- end
36
- def action; 'touch' end
37
- def description; "Touch #{file}:\n#{data}" end
38
- end
39
-
40
- class StepModify < Step
41
- attr_reader :file, :pattern, :replacement
42
- def initialize(*args)
43
- opts = args.first
44
- @file, @pattern, @replacement = [:file,:from,:to].map{|k| opts[k]}
45
- end
46
- def action; 'modify' end
47
- def description
48
- "Modify #{file}:\n#{pattern.inspect} =>\n#{replacement}"
49
- end
50
- end
51
-
52
- class StepAppend < Step
53
- attr_reader :file, :data
54
- def initialize(*args)
55
- opts = args.first
56
- @file, @data = [:file,:with].map{|k| opts[k]}
57
- end
58
- def action; 'append' end
59
- def description; "Append to #{file}:\n#{data}" end
60
- end
61
-
62
- class StepPrepend < Step
63
- attr_reader :file, :data
64
- def initialize(*args)
65
- opts = args.first
66
- @file, @data = [:file,:with].map{|k| opts[k]}
67
- end
68
- def action; 'prepend' end
69
- def description; "Prepend to #{file}:\n#{data}" end
70
- end
71
-
72
- class StepInsert < Step
73
- attr_reader :file, :data, :options
74
- def initialize(*args)
75
- opts = args.first
76
- @file, @data = [:file,:with].map{|k| opts.delete(k) }
77
- @options = opts
78
- end
79
- def action; 'insert' end
80
- def description; "Insert into #{file}:\n#{data}" end
81
- end
82
-
83
- class StepRemove < Step
84
- attr_reader :file
85
- def initialize(*args)
86
- opts = args.first
87
- @file = opts.delete(:file)
88
- end
89
- def action; 'remove' end
90
- def description; "Remove #{file}" end
91
- end
92
-
93
- end
@@ -1,175 +0,0 @@
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