bard 0.7.9 → 0.8.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/Rakefile CHANGED
@@ -16,6 +16,7 @@ begin
16
16
  gem.add_dependency(%q<thor>, [">= 0.11.7"])
17
17
  gem.add_dependency(%q<grit>, ["= 1.1.1"])
18
18
  gem.add_dependency(%q<git_remote_branch>, [">= 0.3.0"])
19
+ gem.add_dependency(%q<versionomy>, [">= 0.3.0"])
19
20
  gem.add_dependency(%q<systemu>, [">= 1.2.0"])
20
21
  gem.add_dependency(%q<term-ansicolor>, [">= 1.0.3"])
21
22
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.9
1
+ 0.8.0
data/bard.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bard}
8
- s.version = "0.7.9"
8
+ s.version = "0.8.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Micah Geisel", "Nick Hogle"]
@@ -48,6 +48,14 @@ Gem::Specification.new do |s|
48
48
  "lib/bard/io.rb",
49
49
  "lib/bard/rake.rb",
50
50
  "lib/bard/ssh_delegation.rb",
51
+ "lib/bard/template.rb",
52
+ "lib/bard/template/adva.rb",
53
+ "lib/bard/template/authlogic.rb",
54
+ "lib/bard/template/exception_notifier.rb",
55
+ "lib/bard/template/helper.rb",
56
+ "lib/bard/template/initial.rb",
57
+ "lib/bard/template/static_pages.rb",
58
+ "lib/bard/template/testing.rb",
51
59
  "spec/bard_spec.rb",
52
60
  "spec/spec_helper.rb"
53
61
  ]
@@ -72,6 +80,7 @@ Gem::Specification.new do |s|
72
80
  s.add_runtime_dependency(%q<thor>, [">= 0.11.7"])
73
81
  s.add_runtime_dependency(%q<grit>, ["= 1.1.1"])
74
82
  s.add_runtime_dependency(%q<git_remote_branch>, [">= 0.3.0"])
83
+ s.add_runtime_dependency(%q<versionomy>, [">= 0.3.0"])
75
84
  s.add_runtime_dependency(%q<systemu>, [">= 1.2.0"])
76
85
  s.add_runtime_dependency(%q<term-ansicolor>, [">= 1.0.3"])
77
86
  else
@@ -81,6 +90,7 @@ Gem::Specification.new do |s|
81
90
  s.add_dependency(%q<thor>, [">= 0.11.7"])
82
91
  s.add_dependency(%q<grit>, ["= 1.1.1"])
83
92
  s.add_dependency(%q<git_remote_branch>, [">= 0.3.0"])
93
+ s.add_dependency(%q<versionomy>, [">= 0.3.0"])
84
94
  s.add_dependency(%q<systemu>, [">= 1.2.0"])
85
95
  s.add_dependency(%q<term-ansicolor>, [">= 1.0.3"])
86
96
  end
@@ -91,6 +101,7 @@ Gem::Specification.new do |s|
91
101
  s.add_dependency(%q<thor>, [">= 0.11.7"])
92
102
  s.add_dependency(%q<grit>, ["= 1.1.1"])
93
103
  s.add_dependency(%q<git_remote_branch>, [">= 0.3.0"])
104
+ s.add_dependency(%q<versionomy>, [">= 0.3.0"])
94
105
  s.add_dependency(%q<systemu>, [">= 1.2.0"])
95
106
  s.add_dependency(%q<term-ansicolor>, [">= 1.0.3"])
96
107
  end
data/lib/bard.rb CHANGED
@@ -3,6 +3,7 @@ require 'rubygems'
3
3
  require 'term/ansicolor'
4
4
  require 'net/http'
5
5
  require 'systemu'
6
+ require 'versionomy'
6
7
  require 'grit'
7
8
  require 'thor'
8
9
 
@@ -21,6 +22,13 @@ class Bard < Thor
21
22
 
22
23
  method_options %w( verbose -v ) => :boolean
23
24
 
25
+ desc "create [PROJECT_NAME]", "create new project"
26
+ def create(project_name)
27
+ template_path = File.expand_path(File.dirname(__FILE__) + "/bard/template.rb")
28
+ command = "rails --template=#{template_path} #{project_name}"
29
+ exec command
30
+ end
31
+
24
32
  desc "check [PROJECT_PATH]", "check current project and environment for missing dependencies and common problems"
25
33
  def check(project_path = nil)
26
34
  project_path = "." if project_path.nil? and File.directory? ".git" and File.exist? "config/environment.rb"
@@ -65,6 +73,21 @@ class Bard < Thor
65
73
  run_crucial "git push origin master"
66
74
  run_crucial "git checkout integration"
67
75
 
76
+ if `curl -s -I http://integrity.botandrose.com/#{project_name}` !~ /\b404\b/
77
+ puts "Integrity: verifying build..."
78
+ system "curl -sX POST http://integrity.botandrose.com/#{project_name}/builds"
79
+ while true
80
+ response = `curl -s http://integrity.botandrose.com/#{project_name}`
81
+ break unless response =~ /div class='(building|pending)' id='last_build'/
82
+ sleep(2)
83
+ end
84
+ case response
85
+ when /div class='failed' id='last_build'/ then raise TestsFailedError
86
+ when /div class='success' id='last_build'/ then puts "Integrity: success! deploying to production"
87
+ else raise "Unknown response from CI server:\n#{response}"
88
+ end
89
+ end
90
+
68
91
  run_crucial_via_bard "cap deploy"
69
92
  end
70
93
 
@@ -10,98 +10,33 @@ Capistrano::Configuration.instance(:must_exist).load do
10
10
  task :staging, :roles => :staging do
11
11
  data_pull :staging
12
12
  end
13
-
14
- desc "pull data from production"
15
- task :yml, :roles => :production do
16
- run "cd #{application} && rake db:data:dump && gzip -9f db/data.yml"
17
- transfer :down, "#{application}/db/data.yml.gz", "db/data.yml.gz"
18
- system "gunzip -f db/data.yml.gz"
19
- system "rake db:data:load"
20
- end
21
13
  end
22
14
  end
23
15
 
24
16
  def data_pull(env)
25
17
  config = YAML::load(File.open("config/database.yml"))
26
18
  source = config[env.to_s]
27
- target = config["development"]
28
- run "cd #{application} && mysqldump -u#{source["username"]} #{"-p#{source["password"]}" if source["password"]} '#{source["database"]}' > db/data.sql && gzip -9f db/data.sql"
19
+ target = config[ENV['RAILS_ENV'] || "development"]
20
+ run "cd #{application} && mysqldump -u#{source["username"]} --password=#{source["password"]} '#{source["database"]}' > db/data.sql && gzip -9f db/data.sql"
29
21
  transfer :down, "#{application}/db/data.sql.gz", "db/data.sql.gz"
30
22
  run "cd #{application} && rm db/data.sql.gz"
31
23
  system "gunzip -f db/data.sql.gz"
32
- system "echo 'DROP DATABASE `#{target["database"]}`; CREATE DATABASE `#{target["database"]}`;' | mysql -u#{target["username"]}"
33
- system "mysql -u#{target["username"]} '#{target["database"]}' < db/data.sql"
24
+ system "echo 'DROP DATABASE `#{target["database"]}`; CREATE DATABASE `#{target["database"]}`;' | mysql -u#{target["username"]} --password=#{target["password"]}"
25
+ system "mysql -u#{target["username"]} --password=#{target["password"]} '#{target["database"]}' < db/data.sql"
34
26
  # system "rm db/data.sql"
35
27
  end
36
28
 
37
29
  namespace "deploy" do
38
30
  desc "push app from staging to production"
39
31
  task :default, :roles => :production do
40
- begin
41
-
42
- if `curl -s -I http://integrity.botandrose.com/#{application}` !~ /\b404\b/
43
- puts "Integrity: verifying build..."
44
- system "curl -sX POST http://integrity.botandrose.com/#{application}/builds"
45
- while true
46
- response = `curl -s http://integrity.botandrose.com/#{application}`
47
- break unless response =~ /div class='(building|pending)' id='last_build'/
48
- sleep(1)
49
- end
50
- case response
51
- when /div class='failed' id='last_build'/ then raise TestsFailedError
52
- when /div class='success' id='last_build'/ then success "Integrity: success! deploying to production"
53
- else raise "Unknown response from CI server:\n#{response}"
54
- end
55
- end
56
-
57
- system "git push" if `git remote show origin` =~ /github\.com/
58
- run "cd #{application} && git pull"
59
- run "cd #{application} && rake gems:install" if File.exist?("Rakefile")
60
- run "cd #{application} && script/runner 'Sass::Plugin.options[:always_update] = true; Sass::Plugin.update_stylesheets'" if File.exist?("public/stylesheets/sass") or File.exist?("app/sass")
61
- run "cd #{application} && rake asset:packager:build_all" if File.exist?("vendor/plugins/asset_packager")
62
- run "cd #{application} && git submodule init && git submodule update" if File.exist?(".gitmodules")
63
- run "cd #{application} && rake db:migrate && rake restart" if File.exist?("Rakefile")
64
- success "Deploy Succeeded"
65
-
66
- rescue BardError => e
67
- handle_error e
68
- end
69
- end
70
-
71
- def readline(prompt)
72
- STDOUT.print(prompt)
73
- STDOUT.flush
74
- STDIN.gets
75
- end
76
-
77
- def handle_error(error)
78
- name = error.message.split('::').last.gsub(/([A-Z])/, " \\1").gsub(/^ /,'').gsub(/ Error/, '')
79
- failure "!!! Deploy Error: #{name}"
32
+ system "git push github" if `git remote` =~ /\bgithub\b/
33
+ run "cd #{application} && git pull"
34
+ run "cd #{application} && rake gems:install" if File.exist?("Rakefile")
35
+ run "cd #{application} && script/runner 'Sass::Plugin.options[:always_update] = true; Sass::Plugin.update_stylesheets'" if File.exist?("public/stylesheets/sass") or File.exist?("app/sass")
36
+ run "cd #{application} && rake asset:packager:build_all" if File.exist?("vendor/plugins/asset_packager")
37
+ run "cd #{application} && git submodule init && git submodule update" if File.exist?(".gitmodules")
38
+ run "cd #{application} && rake db:migrate && rake restart" if File.exist?("Rakefile")
39
+ puts "Deploy Succeeded"
80
40
  end
81
41
  end
82
-
83
- ## ERROR HANDLING
84
-
85
- def handle_error(error)
86
- name = error.message.split('::').last.gsub(/([A-Z])/, " \\1").gsub(/^ /,'').gsub(/ Error/, '')
87
- failure "!!! Deploy Error: #{name}"
88
- end
89
-
90
- class BardError < Capistrano::Error; end
91
- class TestsFailedError < BardError; end
92
- class WorkingDirectoryDirtyError < BardError; end
93
- class StagingWorkingDirectoryDirtyError < BardError; end
94
- class NonFastForwardError < BardError; end
95
-
96
- def success(msg)
97
- puts "#{GREEN}#{msg}#{DEFAULT}"
98
- end
99
-
100
- def failure(msg)
101
- abort "#{RED}#{msg}#{DEFAULT}"
102
- end
103
-
104
- GREEN = "\033[1;32m"
105
- RED = "\033[1;31m"
106
- DEFAULT = "\033[0m"
107
42
  end
data/lib/bard/check.rb CHANGED
@@ -22,7 +22,7 @@ class Bard < Thor
22
22
 
23
23
  errors = []
24
24
  %w(bard git rubygems ruby).each do |pkg|
25
- if actual[pkg] < required[pkg]
25
+ if Versionomy.parse(actual[pkg]) < Versionomy.parse(required[pkg])
26
26
  errors << red("#{pkg.ljust(9)} (#{actual[pkg]}) ... NEED (#{required[pkg]})\n #{help[pkg]}")
27
27
  elsif options.verbose?
28
28
  puts green("#{pkg.ljust(9)} (#{actual[pkg]})")
data/lib/bard/error.rb CHANGED
@@ -7,7 +7,8 @@ class Bard < Thor
7
7
  "NotInProjectRootError" => "You are not in the project's root directory!",
8
8
  "NotOnIntegrationError" => "You are not on the integration branch!\n Type `git checkout integration` to switch to it. If you have made changes to your current branch, please see Micah for assistance.",
9
9
  "WorkingTreeDirtyError" => "You have uncommitted changes!\n Please run git commit before attempting to push or pull.",
10
- "StagingDetachedHeadError" => "The staging server is on a detached HEAD!\n Please see Micah for assistance."
10
+ "StagingDetachedHeadError" => "The staging server is on a detached HEAD!\n Please see Micah for assistance.",
11
+ "TestsFailedError" => "Automated tests failed!\n See http://integrity.botandrose.com/ for more info."
11
12
  }.each do |error, message|
12
13
  eval <<-RUBY
13
14
  class #{error} < Bard::Error
@@ -0,0 +1,9 @@
1
+ # bard.rb
2
+ # bot and rose design rails template
3
+ require "bard/template/helper"
4
+
5
+ %w(initial testing exception_notifier static_pages adva).each do |template_file|
6
+ bard_load_template template_file
7
+ end
8
+ run "cd #{project_name}"
9
+ say "Project #{project_name} created! Ask Micah to set up staging server."
@@ -0,0 +1,54 @@
1
+ require "bard/template/helper"
2
+
3
+ # Download and install Adva CMS
4
+ file "script/test-adva-cms", <<-src
5
+ #!/usr/bin/env ruby
6
+ paths = ARGV.clone
7
+ load 'vendor/adva/script/test'
8
+ src
9
+
10
+ file_inject 'config/environment.rb',
11
+ "require File.join(File.dirname(__FILE__), 'boot')",
12
+ "require File.join(File.dirname(__FILE__), '../vendor/adva/engines/adva_cms/boot')"
13
+
14
+ git :submodule => "add -b bard git@git.botandrose.com:adva.git vendor/adva # this might take a bit, grab a coffee meanwhile :)"
15
+ git :submodule => "update --init"
16
+ inside("vendor/adva") do
17
+ run "git remote add github git://github.com/svenfuchs/adva_cms.git"
18
+ run "git checkout -b #{project_name}/integration"
19
+ end
20
+
21
+ rake "adva:install:core -R vendor/adva/engines/adva_cms/lib/tasks"
22
+ rake "adva:assets:install"
23
+
24
+ # Install FCKEditor plugin
25
+ rake "adva:install plugins=adva_fckeditor"
26
+ file "config/initializers/fckeditor.rb", <<-src
27
+ Fckeditor.load!
28
+ src
29
+ run "cp public/javascripts/adva_fckeditor/config.js public/javascripts/fck_config.js"
30
+ file_append "public/javascripts/fck_config.js", <<-src
31
+ FCKConfig.CustomStyles = {};
32
+ FCKConfig.StylesXmlPath = '/stylesheets/fck_styles.xml';
33
+
34
+ FCKConfig.EditorAreaCSS = '/stylesheets/fck_editor.css';
35
+ FCKConfig.BodyClass = '';
36
+
37
+ FCKConfig.FirefoxSpellChecker = true;
38
+ FCKConfig.BrowserContextMenuOnCtrl = true;
39
+ FCKConfig.ForcePasteAsPlainText = true;
40
+ src
41
+ run "cp public/javascripts/adva_fckeditor/fckeditor/fckstyles.xml public/stylesheets/fck_styles.xml"
42
+ file "public/stylesheets/fck_editor.css"
43
+
44
+ # Setup FCKEditor upload connector
45
+ run "mkdir public/userfiles"
46
+ run "chmod 777 public/userfiles"
47
+ file "public/userfiles/.gitignore", ""
48
+ file_append ".gitignore", <<-src
49
+ public/userfiles/*
50
+ !public/userfiles/.gitignore
51
+ src
52
+
53
+ git :add => "."
54
+ git :commit => "-m'added adva cms.'"
@@ -0,0 +1,492 @@
1
+ require "bard/template/helper"
2
+
3
+ # GEMS
4
+ #gem 'bcrypt-ruby', :lib => 'bcrypt' # used by authlogic
5
+ gem 'authlogic'
6
+
7
+ rake "gems:install"
8
+ #rake("gems:unpack")
9
+
10
+ # APPCTRL/HELPER/FLASH
11
+ file_inject 'app/controllers/application_controller.rb',
12
+ "class ApplicationController < ActionController::Base", <<-END
13
+ filter_parameter_logging :password, :password_confirmation
14
+ helper_method :current_user_session, :current_user
15
+
16
+ private
17
+ def current_user_session
18
+ return @current_user_session if defined?(@current_user_session)
19
+ @current_user_session = UserSession.find
20
+ end
21
+
22
+ def current_user
23
+ return @current_user if defined?(@current_user)
24
+ @current_user = current_user_session && current_user_session.user
25
+ end
26
+
27
+ def require_user
28
+ unless current_user
29
+ store_location
30
+ flash[:notice] = "You must be logged in!"
31
+ redirect_to new_user_session_url
32
+ return false
33
+ end
34
+ end
35
+
36
+ def require_no_user
37
+ if current_user
38
+ store_location
39
+ flash[:notice] = "You must be logged out!"
40
+ redirect_to account_url
41
+ return false
42
+ end
43
+ end
44
+
45
+ def store_location
46
+ session[:return_to] = request.request_uri
47
+ end
48
+
49
+ def redirect_back_or_default(default)
50
+ redirect_to(session[:return_to] || default)
51
+ session[:return_to] = nil
52
+ end
53
+
54
+ END
55
+
56
+ # AUTHLOGIC
57
+ log 'authlogic', 'setup'
58
+ generate :session, 'user_session'
59
+
60
+ # ROUTES
61
+ route %q(map.resources :password_resets)
62
+ route %q(map.resources :users)
63
+ route %q(map.resource :user_session, :except => [:edit, :update])
64
+ route %q(map.login "login", :controller => "user_sessions", :action => "new")
65
+ route %q(map.logout "logout", :controller => "user_sessions", :action => "destroy")
66
+ route %q(map.register '/register/:activation_code', :controller => 'activations', :action => 'new')
67
+ route %q(map.activate '/activate/:id', :controller => 'activations', :action => 'create')
68
+ route %q(map.resource :account, :controller => "users")
69
+
70
+ # CONTROLLERS
71
+ file 'app/controllers/user_sessions_controller.rb', <<-END
72
+ class UserSessionsController < ResourceController::Base
73
+ actions :new, :create, :destroy
74
+
75
+ before_filter :require_no_user, :only => [:new, :create]
76
+ before_filter :require_user, :only => :destroy
77
+
78
+ create do
79
+ flash "Successfully logged in."
80
+ wants.html { redirect_back_or_default account_url }
81
+
82
+ failure.flash "Bad email or password!"
83
+ end
84
+
85
+ def destroy
86
+ @user_session = UserSession.find
87
+ @user_session.destroy
88
+ flash[:notice] = "Successfully logged out."
89
+ redirect_to root_url
90
+ end
91
+ end
92
+ END
93
+
94
+
95
+ file 'app/controllers/users_controller.rb', <<-END
96
+ class UsersController < ResourceController::Base
97
+ actions :new, :create, :show, :edit, :update
98
+
99
+ before_filter :require_no_user, :only => [:new, :create]
100
+ before_filter :require_user, :only => [:show, :edit, :update]
101
+
102
+ def create
103
+ @user = User.new
104
+
105
+ if @user.signup!(params)
106
+ @user.deliver_activation_instructions!
107
+ flash[:notice] = "Thanks for signing up! Please check your email for activation instructions."
108
+ redirect_to root_url
109
+ else
110
+ render :action => :new
111
+ end
112
+ end
113
+
114
+ update.wants.html { redirect_to account_path }
115
+
116
+ private
117
+ def object
118
+ @object ||= current_user
119
+ end
120
+ end
121
+ END
122
+
123
+ file 'app/controllers/activations_controller.rb', <<-END
124
+ class ActivationsController < ApplicationController
125
+ before_filter :require_no_user, :only => [:new, :create]
126
+
127
+ def new
128
+ @user = User.find_using_perishable_token(params[:activation_code], 1.week) || (raise Exception)
129
+ raise Exception if @user.active?
130
+ end
131
+
132
+ def create
133
+ @user = User.find(params[:id])
134
+
135
+ raise Exception if @user.active?
136
+
137
+ if @user.activate!(params)
138
+ @user.deliver_activation_confirmation!
139
+ flash[:notice] = "Your account has been activated!"
140
+ redirect_to account_url
141
+ else
142
+ render :action => :new
143
+ end
144
+ end
145
+
146
+ end
147
+ END
148
+
149
+ file 'app/controllers/password_resets_controller.rb', <<-END
150
+ class PasswordResetsController < ApplicationController
151
+ before_filter :load_user_using_perishable_token, :only => [:edit, :update]
152
+ before_filter :require_no_user
153
+
154
+ def new
155
+ render
156
+ end
157
+
158
+ def create
159
+ @user = User.find_by_email(params[:email])
160
+ if @user
161
+ @user.deliver_password_reset_instructions!
162
+ flash[:notice] = "Check your email for password reset instructions."
163
+ redirect_to root_url
164
+ else
165
+ flash[:notice] = "No account found for \#{params[:email]}."
166
+ render :action => :new
167
+ end
168
+ end
169
+
170
+ def edit
171
+ render
172
+ end
173
+
174
+ def update
175
+ @user.password = params[:user][:password]
176
+ @user.password_confirmation = params[:user][:password_confirmation]
177
+ if @user.save
178
+ flash[:notice] = "Your password has been reset!"
179
+ redirect_to account_url
180
+ else
181
+ render :action => :edit
182
+ end
183
+ end
184
+
185
+ private
186
+ def load_user_using_perishable_token
187
+ @user = User.find_using_perishable_token(params[:id])
188
+ unless @user
189
+ flash[:notice] = "Bad key."
190
+ redirect_to root_url
191
+ end
192
+ end
193
+ end
194
+
195
+ END
196
+
197
+
198
+ # MIGRATIONS
199
+ file "db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_users.rb", <<-END
200
+ class CreateUsers < ActiveRecord::Migration
201
+ def self.up
202
+ create_table :users, :force => true do |t|
203
+ t.string :email, :null => false
204
+ t.string :crypted_password, :default => nil, :null => true
205
+ t.string :password_salt, :default => nil, :null => true
206
+ t.string :perishable_token, :default => "", :null => false
207
+ t.string :persistence_token, :null => false
208
+ t.integer :login_count, :default => 0, :null => false
209
+ t.datetime :last_request_at
210
+ t.datetime :last_login_at
211
+ t.datetime :current_login_at
212
+ t.string :last_login_ip
213
+ t.string :current_login_ip
214
+ t.boolean :active, :default => false
215
+ t.timestamps
216
+ end
217
+
218
+ add_index :users, :email
219
+ add_index :users, :persistence_token
220
+ add_index :users, :perishable_token
221
+ add_index :users, :last_request_at
222
+ end
223
+
224
+ def self.down
225
+ drop_table :users
226
+ end
227
+ end
228
+ END
229
+
230
+ file "app/models/user.rb", <<-END
231
+ class User < ActiveRecord::Base
232
+ attr_accessible :email, :password, :password_confirmation
233
+
234
+ acts_as_authentic do |c|
235
+ c.validates_length_of_password_field_options = {:on => :update, :minimum => 4, :if => :has_no_credentials?}
236
+ c.validates_length_of_password_confirmation_field_options = {:on => :update, :minimum => 4, :if => :has_no_credentials?}
237
+ end
238
+
239
+ def has_no_credentials?
240
+ self.crypted_password.blank? && self.openid_identifier.blank?
241
+ end
242
+
243
+ # User creation/activation
244
+ def signup!(params)
245
+ self.email = params[:user][:email]
246
+ save_without_session_maintenance
247
+ end
248
+
249
+ def activate!(params)
250
+ self.active = true
251
+ self.password = params[:user][:password]
252
+ self.password_confirmation = params[:user][:password_confirmation]
253
+ save
254
+ end
255
+
256
+ # Email notifications
257
+ def deliver_password_reset_instructions!
258
+ reset_perishable_token!
259
+ UserNotifier.deliver_password_reset_instructions(self)
260
+ end
261
+
262
+ def deliver_activation_instructions!
263
+ reset_perishable_token!
264
+ UserNotifier.deliver_activation_instructions(self)
265
+ end
266
+
267
+ def deliver_activation_confirmation!
268
+ reset_perishable_token!
269
+ UserNotifier.deliver_activation_confirmation(self)
270
+ end
271
+
272
+ # Helper methods
273
+ def active?
274
+ active
275
+ end
276
+
277
+ end
278
+ END
279
+
280
+ # VIEWS
281
+ file 'app/views/activations/new.html.haml', <<-END
282
+ %h1 Activate your account
283
+ - form_for @user, :url => activate_path(@user.id), :html => { :method => :post} do |form|
284
+ = form.error_messages
285
+ = render :partial => "form", :locals => { :form => form }
286
+ = form.submit "Activate"
287
+ END
288
+
289
+ file 'app/views/activations/_form.html.haml', <<-END
290
+ = form.label :email
291
+ %br
292
+ =h @user.email
293
+ %br
294
+ %br
295
+ = form.label :password, "Choose a password"
296
+ %br
297
+ = form.password_field :password
298
+ %br
299
+ %br
300
+ = form.label :password_confirmation
301
+ %br
302
+ = form.password_field :password_confirmation
303
+ %br
304
+ %br
305
+ END
306
+
307
+ file 'app/views/user_sessions/new.html.haml', <<-END
308
+ %h1 Login
309
+ - form_for @user_session, :url => user_session_path do |f|
310
+ = f.error_messages
311
+ = f.label :email
312
+ %br
313
+ = f.text_field :email
314
+ %br
315
+ %br
316
+ = f.label :password
317
+ %br
318
+ = f.password_field :password
319
+ %br
320
+ %br
321
+ = f.check_box :remember_me
322
+ = f.label :remember_me
323
+ %br
324
+ %br
325
+ = f.submit "Login"
326
+
327
+ = link_to "Sign up", new_account_path
328
+ END
329
+
330
+ file 'app/views/password_resets/new.html.haml', <<-END
331
+ %h1 Forgot your password?
332
+
333
+ - form_tag password_resets_path do
334
+ %label Email address
335
+ %br
336
+ = text_field_tag :email
337
+ %br
338
+ = submit_tag "Reset"
339
+ END
340
+
341
+ file 'app/views/password_resets/edit.html.haml', <<-END
342
+ %h1 Choose a new password
343
+
344
+ - form_for @user, :url => password_reset_path, :method => :put do |f|
345
+ = f.error_messages
346
+ %br
347
+ = f.label :password
348
+ %br
349
+ = f.password_field :password
350
+ %br
351
+ %br
352
+ = f.label :password_confirmation
353
+ %br
354
+ = f.password_field :password_confirmation
355
+ %br
356
+ %br
357
+ = f.submit "Save new password"
358
+ END
359
+
360
+
361
+ file 'app/views/users/_form.html.haml', <<-END
362
+ = form.label :email
363
+ %br
364
+ = form.text_field :email
365
+ %br
366
+ %br
367
+ - unless form.object.new_record?
368
+ = form.label :password, form.object.new_record? ? nil : "Change password"
369
+ %br
370
+ = form.password_field :password
371
+ %br
372
+ %br
373
+ = form.label :password_confirmation
374
+ %br
375
+ = form.password_field :password_confirmation
376
+ %br
377
+ %br
378
+ END
379
+
380
+ file 'app/views/users/edit.html.haml', <<-END
381
+ %h1 My Account
382
+
383
+ - form_for @user, :url => account_path do |f|
384
+ = f.error_messages
385
+ = render :partial => "form", :object => f
386
+ = f.submit "Update"
387
+ %br
388
+ = link_to "My account", account_path
389
+ END
390
+
391
+ file 'app/views/users/new.html.haml', <<-END
392
+ %h1 Sign Up
393
+
394
+ - form_for @user, :url => account_path do |f|
395
+ = f.error_messages
396
+ = render :partial => "form", :object => f
397
+ = f.submit "Sign Up"
398
+ END
399
+
400
+ file 'app/views/users/show.html.haml', <<-END
401
+ %p
402
+ %b
403
+ Email:
404
+ = h @user.email
405
+ %p
406
+ %b
407
+ Login count:
408
+ = h @user.login_count
409
+ %p
410
+ %b
411
+ Last request at:
412
+ = h @user.last_request_at
413
+ %p
414
+ %b
415
+ Last login at:
416
+ = h @user.last_login_at
417
+ %p
418
+ %b
419
+ Current login at:
420
+ = h @user.current_login_at
421
+ %p
422
+ %b
423
+ Last login ip:
424
+ = h @user.last_login_ip
425
+ %p
426
+ %b
427
+ Current login ip:
428
+ = h @user.current_login_ip
429
+ = link_to 'Edit', edit_account_path
430
+
431
+ END
432
+
433
+ # AUTHLOGIC Email Notifier
434
+ generate :mailer, "user_notifier"
435
+ file 'app/models/user_notifier.rb', <<-END
436
+ class UserNotifier < ActionMailer::Base
437
+
438
+ default_url_options[:host] = "localhost:3000"
439
+
440
+ def activation_confirmation(user)
441
+ setup_email user
442
+ subject "[#{project_name}] Account activated!"
443
+ body :root_url => root_url
444
+ end
445
+
446
+ def activation_instructions(user)
447
+ setup_email user
448
+ subject "[#{project_name}] Welcome!"
449
+ body :account_activation_url => register_url(user.perishable_token)
450
+ end
451
+
452
+ def password_reset_instructions(user)
453
+ setup_email user
454
+ subject "[#{project_name}] Forgot your password?"
455
+ body :edit_password_reset_url => edit_password_reset_url(user.perishable_token)
456
+ end
457
+
458
+
459
+ protected
460
+ def setup_email(user)
461
+ recipients user.email
462
+ from "#{project_name} Notifier <noreply@#{project_name}>"
463
+ sent_on Time.now
464
+ body :user => user
465
+ end
466
+ end
467
+ END
468
+
469
+ # Authlogic mailer views (RO)
470
+ file 'app/views/user_notifier/activation_instructions.erb', <<-END
471
+ Thanks for signing up!
472
+
473
+ Please visit the following link to activate your account: <%= @account_activation_url %>
474
+ END
475
+
476
+ file 'app/views/user_notifier/activation_confirmation.erb', <<-END
477
+ Your account has been activated!
478
+
479
+ You may log in here: <%= @root_url %>
480
+ END
481
+
482
+ file 'app/views/user_notifier/password_reset_instructions.erb', <<-END
483
+ Forgot your password?
484
+
485
+ Visit the following link to change it to something new: <%= @edit_password_reset_url %>
486
+ END
487
+
488
+ # DATABASE & MIGRATIONS
489
+ rake "db:migrate"
490
+
491
+ git :add => "."
492
+ git :commit => "-am'added authentication.'"
@@ -0,0 +1,18 @@
1
+ require "bard/template/helper"
2
+
3
+ git :clone => "git://github.com/rails/exception_notification.git --branch=2-3-stable vendor/plugins/exception_notification"
4
+ run "rm -rf vendor/plugins/exception_notification/.git"
5
+
6
+ file_inject "app/controllers/application_controller.rb",
7
+ "class ApplicationController < ActionController::Base", <<-END
8
+ include ExceptionNotifiable
9
+
10
+ END
11
+
12
+ file_append "config/environment.rb", <<-END
13
+
14
+ ExceptionNotifier.exception_recipients = %w(micah@botandrose.com)
15
+ END
16
+
17
+ git :add => "."
18
+ git :commit => "-m'added exception notifier.'"
@@ -0,0 +1,28 @@
1
+ module Rails
2
+ class TemplateRunner
3
+
4
+ def project_name
5
+ @root.split("/").last
6
+ end
7
+
8
+ def file_append(file, data)
9
+ log 'file_append', file
10
+ append_file(file, "\n#{data}")
11
+ end
12
+
13
+ def file_inject(file_name, sentinel, string, before_after=:after)
14
+ log 'file_inject', file_name
15
+ gsub_file file_name, /(#{Regexp.escape(sentinel)})/mi do |match|
16
+ if :after == before_after
17
+ "#{match}\n#{string}"
18
+ else
19
+ "#{string}\n#{match}"
20
+ end
21
+ end
22
+ end
23
+
24
+ def bard_load_template(template_file)
25
+ load_template Gem.required_location "bard", "bard/template/#{template_file}.rb"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,203 @@
1
+ # delete unnecessary files
2
+ run "rm README"
3
+ run "rm public/index.html"
4
+ run "rm public/favicon.ico"
5
+ run "rm public/robots.txt"
6
+ run "rm -f public/javascripts/*"
7
+ run "rm -rf test"
8
+ run "rm -rf doc"
9
+
10
+ # Install plugins
11
+ plugin "limerick_rake", :git => "git://github.com/thoughtbot/limerick_rake.git"
12
+ plugin "acts_as_list", :git => "git://github.com/rails/acts_as_list.git"
13
+ plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git'
14
+ #plugin 'fckeditor', :git => 'git://github.com/originofstorms/fckeditor.git'
15
+
16
+ # Install gems
17
+ gem "haml", :version => "2.2.17"
18
+ gem "compass", :version => "0.8.17"
19
+ rake "gems:install"
20
+
21
+ # Set up databases
22
+ file "config/database.yml", <<-END
23
+ login: &login
24
+ adapter: mysql
25
+ database: #{project_name}
26
+ username: root
27
+ password:
28
+ socket: /var/run/mysqld/mysqld.sock
29
+
30
+ development:
31
+ <<: *login
32
+
33
+ test:
34
+ <<: *login
35
+ database: #{project_name}_test
36
+
37
+ staging:
38
+ <<: *login
39
+
40
+ production:
41
+ <<: *login
42
+ END
43
+
44
+ rake "db:create"
45
+ rake "db:migrate"
46
+
47
+ # Restart task
48
+ file "lib/tasks/restart.rake", <<-END
49
+ task :restart do
50
+ system("touch tmp/restart.txt")
51
+ system("touch tmp/debug.txt") if ENV["DEBUG"] == 'true'
52
+ end
53
+ END
54
+
55
+ # Staging Environment
56
+ run "cp config/environments/development.rb config/environments/staging.rb"
57
+
58
+ # application.html.haml
59
+ file "app/views/layouts/application.html.haml", <<-END
60
+ !!!
61
+ %html{html_attrs('en-US')}
62
+ %head
63
+ %meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
64
+ %title
65
+ #{project_name}
66
+ = yield :title
67
+ %meta(name="keywords" content="")
68
+ %meta(name="description" content="")
69
+
70
+ = stylesheet_link_merged :base
71
+ = yield :css
72
+ /[if lte IE 7]
73
+ = stylesheet_link_merged :ie
74
+
75
+ %link(rel="shortcut icon" href="\#{image_path("/favicon.png")}" type="image/png")
76
+
77
+ %body
78
+ #container
79
+ = yield
80
+ - if flash[:notice]
81
+ #flash_notice= flash[:notice]
82
+ - if flash[:error]
83
+ #flash_error= flash[:error]
84
+
85
+ = javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
86
+ = javascript_include_merged :base
87
+ = yield :js
88
+ END
89
+
90
+ run "compass --rails --sass-dir app/sass --css-dir public/stylesheets ."
91
+
92
+ # application.sass
93
+ file "public/stylesheets/sass/application.sass", <<-END
94
+ // global
95
+
96
+ @import constant.sass
97
+
98
+ @import blueprint.sass
99
+ @import compass/reset.sass
100
+ @import compass/utilities.sass
101
+ @import compass/misc.sass
102
+ @import compass/layout.sass
103
+ @import blueprint/modules/buttons.sass
104
+
105
+ =blueprint(!body_selector = "body")
106
+ +blueprint-typography(!body_selector)
107
+ +blueprint-utilities
108
+ +blueprint-debug
109
+ +blueprint-interaction
110
+ +blueprint-colors
111
+
112
+ .left
113
+ +float-left
114
+ .right
115
+ +float-right
116
+
117
+ END
118
+
119
+ # constant.sass
120
+ file "public/stylesheets/sass/_constant.sass", <<-END
121
+ // constant
122
+
123
+ !blueprint_grid_columns = 24
124
+ !blueprint_grid_width = 30px
125
+ !blueprint_grid_margin = 10px
126
+
127
+ =caps
128
+ :font-variant small-caps
129
+ =box-shadow( !blur, !color )
130
+ :-moz-box-shadow= 0px 0px !blur !color
131
+ =border-radius( !radius )
132
+ :-moz-border-radius= !radius
133
+ :-webkit-border-radius= !radius
134
+ :border-radius= !radius
135
+ =auto
136
+ :display inline-block
137
+ +float-left
138
+ :width auto
139
+ =bordering(!location, !color)
140
+ :border-\#{!location}= 1px solid !color
141
+
142
+ END
143
+
144
+ file "public/javascripts/application.js", <<-END
145
+ $(function() {
146
+ });
147
+ END
148
+
149
+ file "config/asset_packages.yml", <<-END
150
+ ---
151
+ javascripts:
152
+ - base:
153
+ - application
154
+ stylesheets:
155
+ - base:
156
+ - screen
157
+ - application
158
+ - ie:
159
+ - ie
160
+ END
161
+
162
+ run "script/runner 'Sass::Plugin.options[:always_update] = true; Sass::Plugin.update_stylesheets'"
163
+
164
+ plugin "input_css", :git => "git://github.com/rpheath/input_css.git"
165
+
166
+ # Set up git repository
167
+ run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
168
+ run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore}
169
+ file '.gitignore', <<-END
170
+ log/*.log
171
+ tmp/*
172
+ !tmp/.gitignore
173
+ .DS_Store
174
+ public/cache/**/*
175
+ doc/api
176
+ doc/app
177
+ doc/spec/*
178
+ db/data.*
179
+ db/*.sqlite3
180
+ config/database.yml
181
+ config/deploy.rb
182
+ converage/**/*
183
+ public/stylesheets/*.css
184
+ *[~]
185
+ END
186
+
187
+ git :init
188
+ git :add => "."
189
+ git :commit => "-m'initial commit.'"
190
+
191
+ # Deployment and staging setup
192
+ file "Capfile", <<-END
193
+ Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
194
+ require 'bard/capistrano'
195
+ load 'config/deploy'
196
+ END
197
+
198
+ file "config/deploy.rb", <<-END
199
+ set :application, "#{project_name}"
200
+ END
201
+
202
+ git :remote => "add origin git@git.botandrose.com:#{project_name}.git"
203
+ run "cap staging:bootstrap"
@@ -0,0 +1,29 @@
1
+ require "bard/template/helper"
2
+
3
+ # Set up static controller
4
+ file "app/controllers/static_controller.rb", <<-END
5
+ class StaticController < ApplicationController
6
+ def dispatch
7
+ view_template_path = "/static/"+params[:path].join("/")
8
+ begin
9
+ render view_template_path, :layout => true
10
+ rescue ActionView::MissingTemplate
11
+ begin
12
+ render view_template_path+"/index", :layout => true
13
+ rescue ActionView::MissingTemplate
14
+ raise ActiveRecord::RecordNotFound
15
+ end
16
+ end
17
+ end
18
+ end
19
+ END
20
+
21
+ route "map.connect '*path', :controller => 'static', :action => 'dispatch'"
22
+ route "map.root :controller => 'static', :action => 'dispatch', :path => ['index']"
23
+
24
+ file "app/views/static/index.html.haml", <<-END
25
+ %h1 #{project_name}
26
+ END
27
+
28
+ git :add => "."
29
+ git :commit => "-m'static controller.'"
@@ -0,0 +1,55 @@
1
+ require "bard/template/helper"
2
+
3
+ # Testing Environment
4
+ with_options :env => :cucumber do
5
+ gem 'cucumber', :lib => false, :version => '0.4.3'
6
+ gem 'webrat', :lib => false, :version => '0.5.3'
7
+ gem 'rspec', :lib => false, :version => '1.2.9'
8
+ gem 'rspec-rails', :lib => false, :version => '1.2.9'
9
+ gem 'faker', :version => '0.3.1'
10
+ gem "email_spec", :version => "0.4.0", :lib => false
11
+ gem "machinist", :version => "1.0.6", :lib => false
12
+ gem "pickle", :version => "0.2.1", :lib => false
13
+ end
14
+
15
+ plugin 'cucumber_rails_debug', :git => "git://github.com/mischa/cucumber_rails_debug"
16
+
17
+ generate "rspec"
18
+ generate "cucumber"
19
+ generate "email_spec"
20
+ generate "pickle"
21
+
22
+ file "features/support/blueprints.rb", <<-END
23
+ require 'machinist/active_record'
24
+ require 'faker'
25
+
26
+ Sham.name { Faker::Name.name }
27
+ Sham.email { Faker::Internet.email }
28
+ Sham.sentence { Faker::Lorem.sentence }
29
+ Sham.paragraph { Faker::Lorem.paragraph }
30
+ Sham.url { "http://\#{Faker::Internet.domain_name}/\#{Faker::Lorem.words(3).join('_').downcase}" }
31
+
32
+ Sham.address { Faker::Address.street_address }
33
+ Sham.city { Faker::Address.city }
34
+ Sham.zip { Faker::Address.zip_code }
35
+ Sham.phone { Faker::PhoneNumber.phone_number }
36
+ END
37
+ run "ln -s features/support/blueprints.rb spec/blueprints.rb"
38
+
39
+ file "features/support/debug.rb", <<-END
40
+ require 'ruby-debug'
41
+ require 'cucumber_rails_debug/steps'
42
+ END
43
+
44
+ file "features/support/email.rb", <<-END
45
+ # Email testing helpers
46
+ require 'email_spec/cucumber'
47
+ END
48
+
49
+ run "rake db:create RAILS_ENV=test"
50
+
51
+ git :add => "."
52
+ git :commit => "-m'added rspec and cucumber setups.'"
53
+
54
+ run "cap stage"
55
+ run "cap staging:bootstrap:ci"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
@@ -73,6 +73,16 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: 0.3.0
75
75
  version:
76
+ - !ruby/object:Gem::Dependency
77
+ name: versionomy
78
+ type: :runtime
79
+ version_requirement:
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 0.3.0
85
+ version:
76
86
  - !ruby/object:Gem::Dependency
77
87
  name: systemu
78
88
  type: :runtime
@@ -132,6 +142,14 @@ files:
132
142
  - lib/bard/io.rb
133
143
  - lib/bard/rake.rb
134
144
  - lib/bard/ssh_delegation.rb
145
+ - lib/bard/template.rb
146
+ - lib/bard/template/adva.rb
147
+ - lib/bard/template/authlogic.rb
148
+ - lib/bard/template/exception_notifier.rb
149
+ - lib/bard/template/helper.rb
150
+ - lib/bard/template/initial.rb
151
+ - lib/bard/template/static_pages.rb
152
+ - lib/bard/template/testing.rb
135
153
  - spec/bard_spec.rb
136
154
  - spec/spec_helper.rb
137
155
  has_rdoc: true