playmo 0.0.18 → 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.
Files changed (34) hide show
  1. data/README.md +107 -10
  2. data/TODO.md +57 -33
  3. data/lib/playmo.rb +28 -29
  4. data/lib/playmo/action.rb +38 -0
  5. data/lib/playmo/answer.rb +17 -8
  6. data/lib/playmo/choice.rb +23 -22
  7. data/lib/playmo/cli.rb +31 -9
  8. data/lib/playmo/cookbook.rb +16 -17
  9. data/lib/playmo/question.rb +70 -37
  10. data/lib/playmo/recipe.rb +115 -32
  11. data/lib/playmo/recipes/application_controller_recipe.rb +12 -21
  12. data/lib/playmo/recipes/application_helper_recipe.rb +26 -37
  13. data/lib/playmo/recipes/assets_recipe.rb +8 -17
  14. data/lib/playmo/recipes/capistrano_recipe.rb +13 -24
  15. data/lib/playmo/recipes/compass_recipe.rb +7 -18
  16. data/lib/playmo/recipes/devise_recipe.rb +155 -168
  17. data/lib/playmo/recipes/forms_recipe.rb +16 -38
  18. data/lib/playmo/recipes/gemfile_recipe.rb +10 -0
  19. data/lib/playmo/recipes/git_recipe.rb +23 -29
  20. data/lib/playmo/recipes/home_controller_recipe.rb +60 -73
  21. data/lib/playmo/recipes/javascript_framework_recipe.rb +27 -42
  22. data/lib/playmo/recipes/layout_recipe.rb +9 -19
  23. data/lib/playmo/recipes/locale_recipe.rb +22 -0
  24. data/lib/playmo/recipes/markup_recipe.rb +15 -28
  25. data/lib/playmo/recipes/rails_recipe.rb +8 -0
  26. data/lib/playmo/recipes/rspec_recipe.rb +18 -35
  27. data/lib/playmo/recipes/rvm_recipe.rb +9 -16
  28. data/lib/playmo/recipes/setup_database_recipe.rb +10 -19
  29. data/lib/playmo/recipes/thinking_sphinx_recipe.rb +10 -25
  30. data/lib/playmo/recipes/unicorn_recipe.rb +8 -19
  31. data/lib/playmo/silent.rb +3 -13
  32. data/lib/playmo/version.rb +2 -2
  33. metadata +16 -13
  34. data/lib/playmo/recipes/congrats_recipe.rb +0 -20
@@ -1,19 +1,10 @@
1
- module Playmo
2
- module Recipes
3
- class AssetsRecipe < Playmo::Recipe
4
- source_root File.expand_path('../templates/assets_recipe', __FILE__)
1
+ recipe :assets do
2
+ description 'This will adds custom assets into application'
3
+ after :markup
5
4
 
6
- def setup
7
- silently do
8
- directory 'images/', 'app/assets/images/'
9
- directory 'stylesheets/', 'app/assets/stylesheets/'
10
- remove_file 'app/assets/stylesheets/application.css'
11
- end
12
- end
13
- end
5
+ silently do
6
+ directory 'images/', 'app/assets/images/'
7
+ directory 'stylesheets/', 'app/assets/stylesheets/'
8
+ remove_file 'app/assets/stylesheets/application.css'
14
9
  end
15
- end
16
-
17
- # Write down this recipe to our Cookbook if it's available
18
- require File.dirname(__FILE__) + '/markup_recipe'
19
- Playmo::Cookbook.instance.insert_after(Playmo::Recipes::MarkupRecipe, Playmo::Recipes::AssetsRecipe) if defined?(Playmo::Cookbook)
10
+ end
@@ -1,26 +1,15 @@
1
- module Playmo
2
- module Recipes
3
- class CapistranoRecipe < Playmo::Recipe
4
- source_root File.expand_path('../templates/capistrano_recipe', __FILE__)
5
-
6
- def setup
7
- question "Would you like to deploy project with Capistrano?" => :install_capistrano
8
- end
9
-
10
- def install_capistrano
11
- gem 'capistrano'
12
-
13
- # TODO: Copy deploy.rb
14
- Event.events.listen(:after_install) do |event_data|
15
- capify!
16
- remove_file "config/deploy.rb"
17
- template "deploy.rb", "config/deploy.rb"
18
- end
19
- end
1
+ recipe :capistrano do
2
+ description 'This will add remote multi-server automation tool'
3
+ after :rspec
4
+
5
+ ask "Would you like to deploy project with Capistrano?" do
6
+ gem 'capistrano'
7
+
8
+ # TODO: Copy deploy.rb
9
+ after_install do
10
+ capify!
11
+ remove_file "config/deploy.rb"
12
+ template "deploy.rb", "config/deploy.rb"
20
13
  end
21
14
  end
22
- end
23
-
24
- # Write down this recipe to our Cookbook if it's available
25
- require File.dirname(__FILE__) + '/rspec_recipe'
26
- Playmo::Cookbook.instance.insert_after(Playmo::Recipes::RspecRecipe, Playmo::Recipes::CapistranoRecipe) if defined?(Playmo::Cookbook)
15
+ end
@@ -1,19 +1,8 @@
1
- module Playmo
2
- module Recipes
3
- class CompassRecipe < Playmo::Recipe
4
- source_root File.expand_path('../templates/compass_recipe', __FILE__)
5
-
6
- def setup
7
- question "Would you like to use Compass in this project?" => :install_compass
8
- end
9
-
10
- def install_compass
11
- gem "compass", "~> 0.12.alpha.0"
12
- end
13
- end
1
+ recipe :compass do
2
+ description 'This wll add Stylesheet Authoring Environment that makes your website design simpler to implement and easier to maintain'
3
+ after :application_controller
4
+
5
+ ask "Would you like to use Compass in this project?" do
6
+ gem "compass", "~> 0.12.alpha.0"
14
7
  end
15
- end
16
-
17
- # Write down this recipe to our Cookbook if it's available
18
- require File.dirname(__FILE__) + '/application_controller_recipe'
19
- Playmo::Cookbook.instance.insert_after(Playmo::Recipes::ApplicationControllerRecipe, Playmo::Recipes::CompassRecipe) if defined?(Playmo::Cookbook)
8
+ end
@@ -1,190 +1,177 @@
1
- module Playmo
2
- module Recipes
3
- class DeviseRecipe < Playmo::Recipe
4
- source_root File.expand_path('../templates/devise_recipe', __FILE__)
5
-
6
- def setup
7
- question "Would you like to use Devise in this project?" => :install_devise
8
- end
1
+ recipe :devise do
2
+ description 'This will add Devise - flexible authentication solution for Rails'
3
+ after :layout
4
+
5
+ # Add links into layout
6
+ def add_layout_links
7
+ case retrieve(:markup)
8
+ when :erb then create_userbar_with_erb
9
+ when :haml then create_userbar_with_haml
10
+ when :slim then create_userbar_with_slim
11
+ end
12
+ end
9
13
 
10
- def install_devise
11
- gem 'devise'
12
-
13
- Event.events.listen(:after_install) do |event_data|
14
- # Generate Devise stuff
15
- generate "devise:install"
16
- generate "devise User"
17
- generate "devise:views"
18
-
19
- # Add sign_up/login links into layout
20
- add_layout_links
21
-
22
- # Process Devise views to choosen markup
23
- process_views
24
-
25
- # Add :name accessor to default accessors
26
- # Also add some specific methods
27
- gsub_file 'app/models/user.rb', ' attr_accessible :email, :password, :password_confirmation, :remember_me' do
28
- <<-CONTENT.gsub(/^ {12}/, '')
29
- attr_accessible :email, :password, :password_confirmation, :remember_me, :name
30
- cattr_accessor :current
31
-
32
- # Return user name or user name from email address
33
- def username
34
- name.blank? ? email.match(/^[^@]+/)[0] : name
35
- end
36
- CONTENT
37
- end
14
+ # Process Devise views to choosen markup
15
+ def process_views
16
+ case retrieve(:markup)
17
+ when :haml then process_views_with_haml
18
+ when :slim then process_views_with_slim
19
+ end
20
+ end
38
21
 
39
- # Create migration that adds name field to users table
40
- filename = "db/migrate/#{(Time.now - 3600).strftime("%Y%m%d%H%M%S")}_add_name_to_users.rb"
22
+ def create_userbar_with_erb
23
+ gsub_file 'app/views/layouts/application.html.erb', ' </header>' do
24
+ <<-CONTENT.gsub(/^ {6}/, '')
25
+ <%= render 'shared/userbar' %>
26
+ </header>
27
+ CONTENT
28
+ end
41
29
 
42
- create_file filename, <<-CONTENT.gsub(/^ {12}/, '')
43
- class AddNameToUsers < ActiveRecord::Migration
44
- def change
45
- add_column :users, :name, :string
46
- end
47
- end
48
- CONTENT
49
- end
30
+ create_file 'app/views/shared/_userbar.html.erb' do
31
+ <<-CONTENT.gsub(/^ {12}/, '')
32
+ <div id="user-info">
33
+ <ul>
34
+ <% if user_signed_in? %>
35
+ <li>
36
+ Hello, Dear <strong><%= current_user.username %></strong>!
37
+ Maybe, you want to <%= link_to 'logout', main_app.destroy_user_session_path, :method => :delete %>?
38
+ </li>
39
+ <% else %>
40
+ <li>
41
+ Hello Guest, maybe you want to <%= link_to 'Join us', main_app.new_user_registration_path %> or <%= link_to 'login', main_app.new_user_session_path %>?
42
+ </li>
43
+ <% end %>
44
+ </ul>
45
+ </div>
46
+ CONTENT
47
+ end
48
+ end
50
49
 
51
- # Create default user
52
- append_to_file 'db/seeds.rb' do
53
- <<-CONTENT.gsub(/^ {12}/, '')
54
- user = User.create!(
55
- :email => 'johndoe@example.com',
56
- :password => 'secret',
57
- :password_confirmation => 'secret'
58
- )
59
-
60
- user2 = User.create!(
61
- :email => 'annadoe@example.com',
62
- :password => 'secret',
63
- :password_confirmation => 'secret'
64
- )
65
- CONTENT
66
- end
50
+ def create_userbar_with_haml
51
+ gsub_file 'app/views/layouts/application.html.haml', ' #body' do
52
+ <<-CONTENT.gsub(/^ {6}/, '')
53
+ = render 'shared/userbar'
54
+ #body
55
+ CONTENT
56
+ end
67
57
 
68
- end
58
+ create_file 'app/views/shared/_userbar.html.haml' do
59
+ <<-'CONTENT'.gsub(/^ {12}/, '')
60
+ #user-info
61
+ %ul
62
+ - if user_signed_in?
63
+ %li
64
+ Hello, Dear
65
+ = succeed "!" do
66
+ %strong= current_user.username
67
+ Maybe, you want to #{link_to 'logout', main_app.destroy_user_session_path, :method => :delete}?
68
+ - else
69
+ %li
70
+ Hello Guest, maybe you want to #{link_to 'Join us', main_app.new_user_registration_path} or #{link_to 'login', main_app.new_user_session_path}?
71
+ CONTENT
72
+ end
73
+ end
69
74
 
70
- private
75
+ def create_userbar_with_slim
76
+ gsub_file 'app/views/layouts/application.html.slim', ' #body' do
77
+ <<-'CONTENT'.gsub(/^ {6}/, '')
78
+ = render 'shared/userbar'
79
+ #body
80
+ CONTENT
81
+ end
71
82
 
72
- # Add links into layout
73
- def add_layout_links
74
- case retrieve(:markup)
75
- when :erb then create_userbar_with_erb
76
- when :haml then create_userbar_with_haml
77
- when :slim then create_userbar_with_slim
78
- end
79
- end
83
+ create_file 'app/views/shared/_userbar.html.slim' do
84
+ <<-'CONTENT'.gsub(/^ {12}/, '')
85
+ #user-info
86
+ ul
87
+ - if user_signed_in?
88
+ li
89
+ ' Hello, Dear
90
+ strong= current_user.username
91
+ ' ! Maybe, you want to #{link_to 'logout', main_app.destroy_user_session_path, :method => :delete}?
92
+ - else
93
+ li
94
+ | Hello Guest, maybe you want to #{link_to 'Join us', main_app.new_user_registration_path} or #{link_to 'login', main_app.new_user_session_path}?
95
+ CONTENT
96
+ end
97
+ end
80
98
 
81
- # Process Devise views to choosen markup
82
- def process_views
83
- case retrieve(:markup)
84
- when :haml then process_views_with_haml
85
- when :slim then process_views_with_slim
86
- end
87
- end
99
+ def process_views_with_haml
100
+ Dir["#{destination_root}/app/views/devise/**/*.erb"].each do |erb_file|
101
+ haml_file = erb_file.gsub(/\.erb$/, '.haml')
102
+ run "html2haml #{erb_file} #{haml_file}"
103
+ run "rm #{erb_file}"
104
+ end
105
+ end
88
106
 
89
- def create_userbar_with_erb
90
- gsub_file 'app/views/layouts/application.html.erb', ' </header>' do
91
- <<-CONTENT.gsub(/^ {6}/, '')
92
- <%= render 'shared/userbar' %>
93
- </header>
94
- CONTENT
95
- end
107
+ def process_views_with_slim
108
+ process_views_with_haml
96
109
 
97
- create_file 'app/views/shared/_userbar.html.erb' do
98
- <<-CONTENT.gsub(/^ {12}/, '')
99
- <div id="user-info">
100
- <ul>
101
- <% if user_signed_in? %>
102
- <li>
103
- Hello, Dear <strong><%= current_user.username %></strong>!
104
- Maybe, you want to <%= link_to 'logout', main_app.destroy_user_session_path, :method => :delete %>?
105
- </li>
106
- <% else %>
107
- <li>
108
- Hello Guest, maybe you want to <%= link_to 'Join us', main_app.new_user_registration_path %> or <%= link_to 'login', main_app.new_user_session_path %>?
109
- </li>
110
- <% end %>
111
- </ul>
112
- </div>
113
- CONTENT
114
- end
115
- end
110
+ Dir["#{destination_root}/app/views/devise/**/*.haml"].each do |haml_file|
111
+ slim_file = haml_file.gsub(/\.haml$/, '.slim')
112
+ run "haml2slim #{haml_file} #{slim_file}"
113
+ run "rm #{haml_file}"
114
+ end
115
+ end
116
116
 
117
- def create_userbar_with_haml
118
- gsub_file 'app/views/layouts/application.html.haml', ' #body' do
119
- <<-CONTENT.gsub(/^ {6}/, '')
120
- = render 'shared/userbar'
121
- #body
122
- CONTENT
123
- end
124
117
 
125
- create_file 'app/views/shared/_userbar.html.haml' do
126
- <<-'CONTENT'.gsub(/^ {12}/, '')
127
- #user-info
128
- %ul
129
- - if user_signed_in?
130
- %li
131
- Hello, Dear
132
- = succeed "!" do
133
- %strong= current_user.username
134
- Maybe, you want to #{link_to 'logout', main_app.destroy_user_session_path, :method => :delete}?
135
- - else
136
- %li
137
- Hello Guest, maybe you want to #{link_to 'Join us', main_app.new_user_registration_path} or #{link_to 'login', main_app.new_user_session_path}?
138
- CONTENT
139
- end
140
- end
118
+ ask "Would you like to use Devise in this project?" do
119
+ gem 'devise'
141
120
 
142
- def create_userbar_with_slim
143
- gsub_file 'app/views/layouts/application.html.slim', ' #body' do
144
- <<-'CONTENT'.gsub(/^ {6}/, '')
145
- = render 'shared/userbar'
146
- #body
147
- CONTENT
148
- end
121
+ # Generate Devise stuff
122
+ generate "devise:install"
123
+ generate "devise User"
124
+ generate "devise:views"
149
125
 
150
- create_file 'app/views/shared/_userbar.html.slim' do
151
- <<-'CONTENT'.gsub(/^ {12}/, '')
152
- #user-info
153
- ul
154
- - if user_signed_in?
155
- li
156
- ' Hello, Dear
157
- strong= current_user.username
158
- ' ! Maybe, you want to #{link_to 'logout', main_app.destroy_user_session_path, :method => :delete}?
159
- - else
160
- li
161
- | Hello Guest, maybe you want to #{link_to 'Join us', main_app.new_user_registration_path} or #{link_to 'login', main_app.new_user_session_path}?
162
- CONTENT
163
- end
164
- end
126
+ after_install do
127
+ # Add sign_up/login links into layout
128
+ add_layout_links
165
129
 
166
- def process_views_with_haml
167
- Dir["#{destination_root}/app/views/devise/**/*.erb"].each do |erb_file|
168
- haml_file = erb_file.gsub(/\.erb$/, '.haml')
169
- run "html2haml #{erb_file} #{haml_file}"
170
- run "rm #{erb_file}"
171
- end
130
+ # Process Devise views to choosen markup
131
+ process_views
132
+
133
+ # Add :name accessor to default accessors
134
+ # Also add some specific methods
135
+ gsub_file 'app/models/user.rb', ' attr_accessible :email, :password, :password_confirmation, :remember_me' do
136
+ <<-CONTENT.gsub(/^ {12}/, '')
137
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :name
138
+ cattr_accessor :current
139
+
140
+ # Return user name or user name from email address
141
+ def username
142
+ name.blank? ? email.match(/^[^@]+/)[0] : name
143
+ end
144
+ CONTENT
172
145
  end
173
146
 
174
- def process_views_with_slim
175
- process_views_with_haml
147
+ # Create migration that adds name field to users table
148
+ filename = "db/migrate/#{(Time.now - 3600).strftime("%Y%m%d%H%M%S")}_add_name_to_users.rb"
176
149
 
177
- Dir["#{destination_root}/app/views/devise/**/*.haml"].each do |haml_file|
178
- slim_file = haml_file.gsub(/\.haml$/, '.slim')
179
- run "haml2slim #{haml_file} #{slim_file}"
180
- run "rm #{haml_file}"
150
+ create_file filename, <<-CONTENT.gsub(/^ {12}/, '')
151
+ class AddNameToUsers < ActiveRecord::Migration
152
+ def change
153
+ add_column :users, :name, :string
154
+ end
181
155
  end
182
- end
156
+ CONTENT
157
+ end
183
158
 
159
+ # Create default user
160
+ append_to_file 'db/seeds.rb' do
161
+ <<-CONTENT.gsub(/^ {12}/, '')
162
+ user = User.create!(
163
+ :email => 'johndoe@example.com',
164
+ :password => 'secret',
165
+ :password_confirmation => 'secret'
166
+ )
167
+
168
+ user2 = User.create!(
169
+ :email => 'annadoe@example.com',
170
+ :password => 'secret',
171
+ :password_confirmation => 'secret'
172
+ )
173
+ CONTENT
184
174
  end
185
- end
186
- end
187
175
 
188
- # Write down this recipe to our Cookbook if it's available
189
- require File.dirname(__FILE__) + '/layout_recipe'
190
- Playmo::Cookbook.instance.insert_after(Playmo::Recipes::LayoutRecipe, Playmo::Recipes::DeviseRecipe) if defined?(Playmo::Cookbook)
176
+ end
177
+ end
@@ -1,42 +1,20 @@
1
- module Playmo
2
- module Recipes
3
- class FormsRecipe < Playmo::Recipe
4
- source_root File.expand_path('../templates/forms_recipe', __FILE__)
5
-
6
- def setup
7
- question "Which form builder you prefer?" do
8
- answer "Use default form_for helper" => :use_default
9
- answer "Simple Form" => :install_simple_form
10
- answer "Formtastic" => :install_formtastic
11
- end
12
- end
13
-
14
- protected
15
-
16
- def use_default
17
- # do nothing
18
- end
19
-
20
- def install_simple_form
21
- gem 'simple_form'
22
-
23
- Event.events.listen(:after_install) do |event_data|
24
- generate "simple_form:install"
25
- end
26
- end
27
-
28
- def install_formtastic
29
- gem 'formtastic'
1
+ recipe :forms do
2
+ description 'This will add form builder into your app'
3
+ after :compass
4
+
5
+ question "Which form builder you prefer?" do
6
+ answer "Use form_for helper", :default => true do
7
+ # do nothing
8
+ end
30
9
 
31
- Event.events.listen(:after_install) do |event_data|
32
- generate "formtastic:install"
33
- end
34
- end
10
+ answer "Simple Form" do
11
+ gem 'simple_form'
12
+ generate "simple_form:install"
13
+ end
35
14
 
15
+ answer "Formtastic" do
16
+ gem 'formtastic'
17
+ generate "formtastic:install"
36
18
  end
37
19
  end
38
- end
39
-
40
- # Write down this recipe to our Cookbook if it's available
41
- require File.dirname(__FILE__) + '/compass_recipe'
42
- Playmo::Cookbook.instance.insert_after(Playmo::Recipes::CompassRecipe, Playmo::Recipes::FormsRecipe) if defined?(Playmo::Cookbook)
20
+ end