Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated to Rails 3.0.3 + Fixed most deprication warnings

  • Loading branch information...
commit b7b5d676fc47b36d7035c4a7c7667474b7c4224d 1 parent d1e767e
@fd fd authored
Showing with 5,864 additions and 3,423 deletions.
  1. +5 −4 .gitignore
  2. +27 −0 Gemfile
  3. +104 −0 Gemfile.lock
  4. +256 −0 README
  5. +2 −5 Rakefile
  6. +3 −5 app/controllers/application_controller.rb
  7. +1 −1  app/controllers/sessions_controller.rb
  8. +1 −1  app/controllers/users_controller.rb
  9. +0 −1  app/helpers/application_helper.rb
  10. +17 −0 app/mailers/notification.rb
  11. +14 −4 app/models/configuration_parameter.rb
  12. +30 −25 app/models/deployment.rb
  13. +7 −3 app/models/host.rb
  14. +0 −17 app/models/notification.rb
  15. +3 −5 app/models/recipe.rb
  16. +21 −15 app/models/stage.rb
  17. +22 −21 app/models/user.rb
  18. +1 −1  app/views/deployments/index.html.erb
  19. +2 −2 app/views/deployments/new.html.erb
  20. +1 −1  app/views/deployments/show.html.erb
  21. +2 −2 app/views/hosts/edit.html.erb
  22. +1 −1  app/views/hosts/index.html.erb
  23. +2 −2 app/views/hosts/new.html.erb
  24. +1 −1  app/views/hosts/show.html.erb
  25. +6 −52 app/views/layouts/application.html.erb
  26. +2 −2 app/views/project_configurations/edit.html.erb
  27. +2 −2 app/views/project_configurations/new.html.erb
  28. +2 −2 app/views/projects/clone.html.erb
  29. +2 −2 app/views/projects/edit.html.erb
  30. +1 −1  app/views/projects/index.html.erb
  31. +2 −2 app/views/projects/new.html.erb
  32. +1 −1  app/views/projects/show.html.erb
  33. +2 −2 app/views/recipes/edit.html.erb
  34. +1 −1  app/views/recipes/index.html.erb
  35. +2 −2 app/views/recipes/new.html.erb
  36. +1 −1  app/views/recipes/show.html.erb
  37. +1 −1  app/views/roles/_form.html.erb
  38. +2 −2 app/views/roles/edit.html.erb
  39. +2 −2 app/views/roles/new.html.erb
  40. +1 −1  app/views/sessions/new.html.erb
  41. +2 −2 app/views/stage_configurations/edit.html.erb
  42. +2 −2 app/views/stage_configurations/new.html.erb
  43. +2 −2 app/views/stages/edit.html.erb
  44. +2 −2 app/views/stages/new.html.erb
  45. +2 −2 app/views/stages/recipes.html.erb
  46. +1 −1  app/views/stages/show.html.erb
  47. +1 −1  app/views/stages/tasks.html.erb
  48. +1 −1  app/views/users/deployments.html.erb
  49. +2 −2 app/views/users/edit.html.erb
  50. +1 −1  app/views/users/index.html.erb
  51. +1 −1  app/views/users/new.html.erb
  52. +1 −1  app/views/users/show.html.erb
  53. +4 −0 config.ru
  54. +44 −0 config/application.rb
  55. +13 −109 config/boot.rb
  56. +12 −25 config/database.yml.sample
  57. +4 −48 config/environment.rb
  58. +22 −13 config/environments/development.rb
  59. +43 −15 config/environments/production.rb
  60. +29 −19 config/environments/test.rb
  61. +7 −0 config/initializers/backtrace_silencers.rb
  62. +2 −2 config/initializers/inflections.rb
  63. +8 −0 config/initializers/session_store.rb
  64. +2 −2 config/initializers/time_formatting.rb
  65. +4 −2 config/initializers/webistrano_configuration.rb
  66. +5 −0 config/locales/en.yml
  67. +42 −37 config/routes.rb
  68. +1 −1  db/migrate/017_add_default_user.rb
  69. +7 −0 db/seeds.rb
  70. +1 −1  doc/README_FOR_APP
  71. 0  lib/tasks/.gitkeep
  72. +0 −2  lib/webistrano/deployer.rb
  73. +15 −19 public/404.html
  74. +15 −19 public/422.html
  75. +16 −20 public/500.html
  76. +0 −10 public/dispatch.cgi
  77. +0 −24 public/dispatch.fcgi
  78. +0 −10 public/dispatch.rb
  79. BIN  public/favicon.ico
  80. BIN  public/images/rails.png
  81. +239 −0 public/index.html
  82. +2 −49 public/javascripts/application.js
  83. +75 −73 public/javascripts/controls.js
  84. +171 −169 public/javascripts/dragdrop.js
  85. +180 −177 public/javascripts/effects.js
  86. +3,494 −1,718 public/javascripts/prototype.js
  87. +175 −0 public/javascripts/rails.js
  88. +5 −1 public/robots.txt
  89. 0  public/stylesheets/.gitkeep
  90. 0  script/performance/request
  91. +6 −0 script/rails
  92. +1 −1  test/factories.rb
  93. +12 −12 test/functional/deployments_controller_test.rb
  94. +12 −12 test/functional/hosts_controller_test.rb
  95. +5 −5 test/functional/project_configurations_controller_test.rb
  96. +13 −13 test/functional/projects_controller_test.rb
  97. +16 −16 test/functional/recipes_controller_test.rb
  98. +5 −5 test/functional/roles_controller_test.rb
  99. +11 −11 test/functional/sessions_controller_test.rb
  100. +5 −5 test/functional/stage_configurations_controller_test.rb
  101. +11 −11 test/functional/stages_controller_test.rb
  102. +1 −1  test/functional/stylesheets_controller_test.rb
  103. +23 −23 test/functional/users_controller_test.rb
  104. +3 −3 test/non_transactional/deployment_controller_test.rb
  105. +4 −4 test/non_transactional/deployment_test.rb
  106. +0 −23 test/non_transactional_test_helper.rb
  107. +9 −0 test/performance/browsing_test.rb
  108. +28 −10 test/test_helper.rb
  109. +9 −9 test/unit/configuration_parameter_test.rb
  110. +52 −52 test/unit/deployment_test.rb
  111. +7 −7 test/unit/host_test.rb
  112. +7 −26 test/unit/notification_test.rb
  113. +4 −4 test/unit/project_configuration_test.rb
  114. +12 −12 test/unit/project_test.rb
  115. +8 −8 test/unit/recipe_test.rb
  116. +15 −15 test/unit/role_test.rb
  117. +2 −2 test/unit/stage_configuration_test.rb
  118. +20 −18 test/unit/stage_test.rb
  119. +24 −24 test/unit/user_test.rb
  120. +195 −179 test/unit/webistrano_deployer_test.rb
  121. +3 −3 test/unit/webistrano_logger_test.rb
  122. 0  vendor/plugins/.gitkeep
  123. +2 −2 vendor/plugins/exception_notification/lib/exception_notifiable.rb
  124. +2 −2 vendor/plugins/exception_notification/lib/exception_notifier.rb
  125. +2 −2 vendor/plugins/exception_notification/lib/exception_notifier_helper.rb
  126. +58 −58 vendor/plugins/multiple_select/test/multiple_select_test.rb
  127. +9 −9 vendor/plugins/restful_authentication/generators/authenticated/templates/functional_test.rb
  128. +1 −1  vendor/plugins/restful_authentication/generators/authenticated/templates/mailer_test.rb
  129. +3 −3 vendor/plugins/restful_authentication/generators/authenticated/templates/model.rb
  130. +12 −12 vendor/plugins/restful_authentication/generators/authenticated/templates/model_functional_test.rb
  131. +17 −17 vendor/plugins/restful_authentication/generators/authenticated/templates/unit_test.rb
  132. +2 −2 vendor/plugins/rubycas-client/README.txt
  133. +1 −1  vendor/plugins/rubycas-client/lib/casclient/frameworks/rails/cas_proxy_callback_controller.rb
  134. +1 −1  vendor/plugins/rubycas-client/lib/casclient/frameworks/rails/filter.rb
  135. +23 −23 vendor/plugins/version_fu/test/version_fu_test.rb
View
9 .gitignore
@@ -1,7 +1,8 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/**/*
config/*.yml
config/webistrano_config.rb
-tmp/*
-log/*
-*~
.DS_Store
-*.tmproj
+.rake_tasks~
View
27 Gemfile
@@ -0,0 +1,27 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.3'
+
+# TODO: what are the direct dependencies? -- fd
+gem 'net-ssh', '2.0.15', :require => 'net/ssh'
+gem 'net-scp', '1.0.2', :require => 'net/scp'
+gem 'net-sftp', '2.0.2', :require => 'net/sftp'
+gem 'net-ssh-gateway', '1.0.1', :require => 'net/ssh/gateway'
+gem 'capistrano', '2.5.9'
+gem 'highline', '1.5.1'
+gem 'open4', '0.9.3'
+gem 'syntax', '1.0.0'
+
+group :development do
+ gem 'sqlite3-ruby', :require => 'sqlite3'
+end
+
+group :test do
+ gem 'sqlite3-ruby', :require => 'sqlite3'
+ gem 'test-unit', '2.0.9', :require => 'test/unit'
+ gem 'mocha'
+end
+
+group :production do
+ gem 'mysql'
+end
View
104 Gemfile.lock
@@ -0,0 +1,104 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.3)
+ actionpack (= 3.0.3)
+ mail (~> 2.2.9)
+ actionpack (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.4)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.13)
+ rack-test (~> 0.5.6)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.3)
+ activesupport (= 3.0.3)
+ builder (~> 2.1.2)
+ i18n (~> 0.4)
+ activerecord (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.3)
+ activemodel (= 3.0.3)
+ activesupport (= 3.0.3)
+ activesupport (3.0.3)
+ arel (2.0.6)
+ builder (2.1.2)
+ capistrano (2.5.9)
+ highline
+ net-scp (>= 1.0.0)
+ net-sftp (>= 2.0.0)
+ net-ssh (>= 2.0.14)
+ net-ssh-gateway (>= 1.0.0)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ highline (1.5.1)
+ i18n (0.5.0)
+ mail (2.2.14)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ mocha (0.9.10)
+ rake
+ mysql (2.8.1)
+ net-scp (1.0.2)
+ net-ssh (>= 1.99.1)
+ net-sftp (2.0.2)
+ net-ssh (>= 2.0.9)
+ net-ssh (2.0.15)
+ net-ssh-gateway (1.0.1)
+ net-ssh (>= 1.99.1)
+ open4 (0.9.3)
+ polyglot (0.3.1)
+ rack (1.2.1)
+ rack-mount (0.6.13)
+ rack (>= 1.0.0)
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rails (3.0.3)
+ actionmailer (= 3.0.3)
+ actionpack (= 3.0.3)
+ activerecord (= 3.0.3)
+ activeresource (= 3.0.3)
+ activesupport (= 3.0.3)
+ bundler (~> 1.0)
+ railties (= 3.0.3)
+ railties (3.0.3)
+ actionpack (= 3.0.3)
+ activesupport (= 3.0.3)
+ rake (>= 0.8.7)
+ thor (~> 0.14.4)
+ rake (0.8.7)
+ sqlite3-ruby (1.3.2)
+ syntax (1.0.0)
+ test-unit (2.0.9)
+ thor (0.14.6)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.23)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ capistrano (= 2.5.9)
+ highline (= 1.5.1)
+ mocha
+ mysql
+ net-scp (= 1.0.2)
+ net-sftp (= 2.0.2)
+ net-ssh (= 2.0.15)
+ net-ssh-gateway (= 1.0.1)
+ open4 (= 0.9.3)
+ rails (= 3.0.3)
+ sqlite3-ruby
+ syntax (= 1.0.0)
+ test-unit (= 2.0.9)
View
256 README
@@ -0,0 +1,256 @@
+== Welcome to Rails
+
+Rails is a web-application framework that includes everything needed to create
+database-backed web applications according to the Model-View-Control pattern.
+
+This pattern splits the view (also called the presentation) into "dumb"
+templates that are primarily responsible for inserting pre-built data in between
+HTML tags. The model contains the "smart" domain objects (such as Account,
+Product, Person, Post) that holds all the business logic and knows how to
+persist themselves to a database. The controller handles the incoming requests
+(such as Save New Account, Update Product, Show Post) by manipulating the model
+and directing data to the view.
+
+In Rails, the model is handled by what's called an object-relational mapping
+layer entitled Active Record. This layer allows you to present the data from
+database rows as objects and embellish these data objects with business logic
+methods. You can read more about Active Record in
+link:files/vendor/rails/activerecord/README.html.
+
+The controller and view are handled by the Action Pack, which handles both
+layers by its two parts: Action View and Action Controller. These two layers
+are bundled in a single package due to their heavy interdependence. This is
+unlike the relationship between the Active Record and Action Pack that is much
+more separate. Each of these packages can be used independently outside of
+Rails. You can read more about Action Pack in
+link:files/vendor/rails/actionpack/README.html.
+
+
+== Getting Started
+
+1. At the command prompt, create a new Rails application:
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
+
+2. Change directory to <tt>myapp</tt> and start the web server:
+ <tt>cd myapp; rails server</tt> (run with --help for options)
+
+3. Go to http://localhost:3000/ and you'll see:
+ "Welcome aboard: You're riding Ruby on Rails!"
+
+4. Follow the guidelines to start developing your application. You can find
+the following resources handy:
+
+* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
+* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
+
+
+== Debugging Rails
+
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
+will help you debug it and get it back on the rails.
+
+First area to check is the application log files. Have "tail -f" commands
+running on the server.log and development.log. Rails will automatically display
+debugging and runtime information to these files. Debugging info will also be
+shown in the browser on requests from 127.0.0.1.
+
+You can also log your own messages directly into the log file from your code
+using the Ruby logger class from inside your controllers. Example:
+
+ class WeblogController < ActionController::Base
+ def destroy
+ @weblog = Weblog.find(params[:id])
+ @weblog.destroy
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
+ end
+ end
+
+The result will be a message in your log file along the lines of:
+
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
+
+More information on how to use the logger is at http://www.ruby-doc.org/core/
+
+Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
+several books available online as well:
+
+* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+
+These two books will bring you up to speed on the Ruby language and also on
+programming in general.
+
+
+== Debugger
+
+Debugger support is available through the debugger command when you start your
+Mongrel or WEBrick server with --debugger. This means that you can break out of
+execution at any point in the code, investigate and change the model, and then,
+resume execution! You need to install ruby-debug to run the server in debugging
+mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
+
+ class WeblogController < ActionController::Base
+ def index
+ @posts = Post.find(:all)
+ debugger
+ end
+ end
+
+So the controller will accept the action, run the first line, then present you
+with a IRB prompt in the server window. Here you can do things like:
+
+ >> @posts.inspect
+ => "[#<Post:0x14a6be8
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
+ #<Post:0x14a6620
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
+ >> @posts.first.title = "hello from a debugger"
+ => "hello from a debugger"
+
+...and even better, you can examine how your runtime objects actually work:
+
+ >> f = @posts.first
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
+ >> f.
+ Display all 152 possibilities? (y or n)
+
+Finally, when you're ready to resume execution, you can enter "cont".
+
+
+== Console
+
+The console is a Ruby shell, which allows you to interact with your
+application's domain model. Here you'll have all parts of the application
+configured, just like it is when the application is running. You can inspect
+domain models, change values, and save to the database. Starting the script
+without arguments will launch it in the development environment.
+
+To start the console, run <tt>rails console</tt> from the application
+directory.
+
+Options:
+
+* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
+ made to the database.
+* Passing an environment name as an argument will load the corresponding
+ environment. Example: <tt>rails console production</tt>.
+
+To reload your controllers and models after launching the console run
+<tt>reload!</tt>
+
+More information about irb can be found at:
+link:http://www.rubycentral.com/pickaxe/irb.html
+
+
+== dbconsole
+
+You can go to the command line of your database directly through <tt>rails
+dbconsole</tt>. You would be connected to the database with the credentials
+defined in database.yml. Starting the script without arguments will connect you
+to the development database. Passing an argument will connect you to a different
+database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
+PostgreSQL and SQLite 3.
+
+== Description of Contents
+
+The default directory structure of a generated Ruby on Rails application:
+
+ |-- app
+ | |-- controllers
+ | |-- helpers
+ | |-- mailers
+ | |-- models
+ | `-- views
+ | `-- layouts
+ |-- config
+ | |-- environments
+ | |-- initializers
+ | `-- locales
+ |-- db
+ |-- doc
+ |-- lib
+ | `-- tasks
+ |-- log
+ |-- public
+ | |-- images
+ | |-- javascripts
+ | `-- stylesheets
+ |-- script
+ |-- test
+ | |-- fixtures
+ | |-- functional
+ | |-- integration
+ | |-- performance
+ | `-- unit
+ |-- tmp
+ | |-- cache
+ | |-- pids
+ | |-- sessions
+ | `-- sockets
+ `-- vendor
+ `-- plugins
+
+app
+ Holds all the code that's specific to this particular application.
+
+app/controllers
+ Holds controllers that should be named like weblogs_controller.rb for
+ automated URL mapping. All controllers should descend from
+ ApplicationController which itself descends from ActionController::Base.
+
+app/models
+ Holds models that should be named like post.rb. Models descend from
+ ActiveRecord::Base by default.
+
+app/views
+ Holds the template files for the view that should be named like
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
+ eRuby syntax by default.
+
+app/views/layouts
+ Holds the template files for layouts to be used with views. This models the
+ common header/footer method of wrapping views. In your views, define a layout
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
+ Inside default.html.erb, call <% yield %> to render the view using this
+ layout.
+
+app/helpers
+ Holds view helpers that should be named like weblogs_helper.rb. These are
+ generated for you automatically when using generators for controllers.
+ Helpers can be used to wrap functionality for your views into methods.
+
+config
+ Configuration files for the Rails environment, the routing map, the database,
+ and other dependencies.
+
+db
+ Contains the database schema in schema.rb. db/migrate contains all the
+ sequence of Migrations for your schema.
+
+doc
+ This directory is where your application documentation will be stored when
+ generated using <tt>rake doc:app</tt>
+
+lib
+ Application specific libraries. Basically, any kind of custom code that
+ doesn't belong under controllers, models, or helpers. This directory is in
+ the load path.
+
+public
+ The directory available for the web server. Contains subdirectories for
+ images, stylesheets, and javascripts. Also contains the dispatchers and the
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
+ server.
+
+script
+ Helper scripts for automation and generation.
+
+test
+ Unit and functional tests along with fixtures. When using the rails generate
+ command, template test files will be generated for you and placed in this
+ directory.
+
+vendor
+ External libraries that the application depends on. Also includes the plugins
+ subdirectory. If the app has frozen rails, those gems also go here, under
+ vendor/rails/. This directory is in the load path.
View
7 Rakefile
@@ -1,10 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-require(File.join(File.dirname(__FILE__), 'config', 'boot'))
-
+require File.expand_path('../config/application', __FILE__)
require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-require 'tasks/rails'
+Webistrano::Application.load_tasks
View
8 app/controllers/application_controller.rb
@@ -1,5 +1,4 @@
class ApplicationController < ActionController::Base
- include BrowserFilters
include ExceptionNotifiable
include AuthenticatedSystem
@@ -47,7 +46,7 @@ def ensure_admin
return true
else
flash[:notice] = "Action not allowed"
- redirect_to home_path
+ redirect_to root_path
return false
end
end
@@ -67,10 +66,9 @@ def logout
reset_session
if WebistranoConfig[:authentication_method] != :cas
flash[:notice] = "You have been logged out."
- redirect_back_or_default( home_path )
+ redirect_back_or_default( root_path )
else
- redirect_to "#{CASClient::Frameworks::Rails::Filter.config[:logout_url]}?serviceUrl=#{home_url}"
+ redirect_to "#{CASClient::Frameworks::Rails::Filter.config[:logout_url]}?serviceUrl=#{root_url}"
end
end
-
end
View
2  app/controllers/sessions_controller.rb
@@ -14,7 +14,7 @@ def create
self.current_user.remember_me
cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
end
- redirect_back_or_default( home_path )
+ redirect_back_or_default( root_path )
flash[:notice] = "Logged in successfully"
else
flash[:error] = "Login/password wrong"
View
2  app/controllers/users_controller.rb
@@ -121,7 +121,7 @@ def ensure_admin_or_my_entry
if current_user.admin? || current_user.id == User.find(params[:id]).id
return true
else
- redirect_to home_url
+ redirect_to root_url
return false
end
end
View
1  app/helpers/application_helper.rb
@@ -1,4 +1,3 @@
-# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def nice_flash(text)
View
17 app/mailers/notification.rb
@@ -0,0 +1,17 @@
+class Notification < ActionMailer::Base
+
+ default :from => 'Webistrano'
+
+ def self.webistrano_sender_address=(val)
+ default :from => val
+ end
+
+ def deployment(deployment, email)
+ @deployment = deployment
+
+ mail(
+ :to => email,
+ :subject => "Deployment of #{deployment.stage.project.name}/#{deployment.stage.name} finished: #{deployment.status}"
+ )
+ end
+end
View
18 app/models/configuration_parameter.rb
@@ -6,10 +6,7 @@ class ConfigurationParameter < ActiveRecord::Base
before_validation :empty_value_if_deploy_is_set
- def validate
- self.errors.add('value', 'must be empty if prompt on deploy is set') if (self.prompt? && !self.value.blank?)
- self.errors.add('name', 'can\'t contain a colon') if (!self.name.blank? && self.name.strip.starts_with?(":"))
- end
+ validate :custom_validations
def prompt?
self.prompt_on_deploy == 1
@@ -26,4 +23,17 @@ def prompt_status_in_html
''
end
end
+
+private
+
+ def custom_validations
+ if self.prompt? and !self.value.blank?
+ self.errors.add('value', 'must be empty if prompt on deploy is set')
+ end
+
+ if !self.name.blank? and self.name.strip.starts_with?(":")
+ self.errors.add('name', 'can\'t contain a colon')
+ end
+ end
+
end
View
55 app/models/deployment.rb
@@ -26,22 +26,8 @@ class Deployment < ActiveRecord::Base
STATUS_VALUES = [STATUS_SUCCESS, STATUS_FAILED, STATUS_CANCELED, STATUS_RUNNING]
validates_inclusion_of :status, :in => STATUS_VALUES
-
- # check (on on creation ) that the stage is ready
- # his has to done only on creation as later DB logging MUST always work
- def validate_on_create
- unless self.stage.blank?
- errors.add('stage', 'is not ready to deploy') unless self.stage.deployment_possible?
-
- self.stage.prompt_configurations.each do |conf|
- errors.add('base', "Please fill out the parameter '#{conf.name}'") unless !prompt_config.blank? && !prompt_config[conf.name.to_sym].blank?
- end
-
- errors.add('lock', 'The stage is locked') if self.stage.locked? && !self.override_locking
-
- ensure_not_all_hosts_excluded
- end
- end
+
+ validate :guard_readiness_of_stage, :on => :create
def self.lock_and_fire(&block)
transaction do
@@ -55,7 +41,7 @@ def self.lock_and_fire(&block)
end
true
rescue => e
- RAILS_DEFAULT_LOGGER.debug "DEPLOYMENT: could not fire deployment: #{e.inspect} #{e.backtrace.join("\n")}"
+ Rails.logger.debug "DEPLOYMENT: could not fire deployment: #{e.inspect} #{e.backtrace.join("\n")}"
false
end
@@ -125,15 +111,15 @@ def complete_canceled!
# deploy through Webistrano::Deployer in background (== other process)
# TODO - at the moment `Unix &` hack
def deploy_in_background!
- unless RAILS_ENV == 'test'
- RAILS_DEFAULT_LOGGER.info "Calling other ruby process in the background in order to deploy deployment #{self.id} (stage #{self.stage.id}/#{self.stage.name})"
- system("sh -c \"cd #{RAILS_ROOT} && ruby script/runner -e #{RAILS_ENV} ' deployment = Deployment.find(#{self.id}); deployment.prompt_config = #{self.prompt_config.inspect.gsub('"', '\"')} ; Webistrano::Deployer.new(deployment).invoke_task! ' >> #{RAILS_ROOT}/log/#{RAILS_ENV}.log 2>&1\" &")
+ unless Rails.env.test?
+ Rails.logger.info "Calling other ruby process in the background in order to deploy deployment #{self.id} (stage #{self.stage.id}/#{self.stage.name})"
+ system("sh -c \"cd #{Rails.root} && ruby script/runner -e #{Rails.env} ' deployment = Deployment.find(#{self.id}); deployment.prompt_config = #{self.prompt_config.inspect.gsub('"', '\"')} ; Webistrano::Deployer.new(deployment).invoke_task! ' >> #{Rails.root}/log/#{Rails.env}.log 2>&1\" &")
end
end
# returns an unsaved, new deployment with the same task/stage/description
def repeat
- returning Deployment.new do |d|
+ Deployment.new.tap do |d|
d.stage = self.stage
d.task = self.task
d.description = "Repetition of deployment #{self.id}: \n"
@@ -167,12 +153,12 @@ def excluded_hosts
end
def excluded_host_ids
- self.read_attribute('excluded_host_ids').blank? ? [] : self.read_attribute('excluded_host_ids')
+ self['excluded_host_ids'].blank? ? [] : self['excluded_host_ids']
end
def excluded_host_ids=(val)
val = [val] unless val.is_a?(Array)
- self.write_attribute('excluded_host_ids', val.map(&:to_i))
+ self['excluded_host_ids'] = val.map(&:to_i)
end
def cancelling_possible?
@@ -193,7 +179,8 @@ def clear_lock_error
self.errors.instance_variable_get("@errors").delete('lock')
end
- protected
+protected
+
def ensure_not_all_hosts_excluded
unless self.stage.blank? || self.excluded_host_ids.blank?
if deploy_to_roles(self.stage.roles).blank?
@@ -215,7 +202,25 @@ def save_completed_status!(status)
def notify_per_mail
self.stage.emails.each do |email|
- Notification.deliver_deployment(self, email)
+ Notification.deployment(self, email).deliver
+ end
+ end
+
+private
+
+ # check (on on creation ) that the stage is ready
+ # his has to done only on creation as later DB logging MUST always work
+ def guard_readiness_of_stage
+ unless self.stage.blank?
+ errors.add('stage', 'is not ready to deploy') unless self.stage.deployment_possible?
+
+ self.stage.prompt_configurations.each do |conf|
+ errors.add('base', "Please fill out the parameter '#{conf.name}'") unless !prompt_config.blank? && !prompt_config[conf.name.to_sym].blank?
+ end
+
+ errors.add('lock', 'The stage is locked') if self.stage.locked? && !self.override_locking
+
+ ensure_not_all_hosts_excluded
end
end
end
View
10 app/models/host.rb
@@ -14,9 +14,7 @@ def strip_whitespace
self.name = self.name.strip rescue nil
end
- def validate
- errors.add("name", "is not a valid hostname or IP") unless ( valid_ip? || valid_hostname? )
- end
+ validate :guard_valid_hostname_or_ip
def valid_hostname?
self.name =~ /\A[a-zA-Z0-9\_\-\.]+\Z/
@@ -30,4 +28,10 @@ def valid_ip?
end
end
+private
+
+ def guard_valid_hostname_or_ip
+ errors.add("name", "is not a valid hostname or IP") unless ( valid_ip? || valid_hostname? )
+ end
+
end
View
17 app/models/notification.rb
@@ -1,17 +0,0 @@
-class Notification < ActionMailer::Base
-
- @@webistrano_sender_address = 'Webistrano'
-
- def self.webistrano_sender_address=(val)
- @@webistrano_sender_address = val
- end
-
- def deployment(deployment, email)
- @subject = "Deployment of #{deployment.stage.project.name}/#{deployment.stage.name} finished: #{deployment.status}"
- @body = {:deployment => deployment}
- @recipients = email
- @from = @@webistrano_sender_address
- @sent_on = Time.now
- @headers = {}
- end
-end
View
8 app/models/recipe.rb
@@ -7,13 +7,11 @@ class Recipe < ActiveRecord::Base
attr_accessible :name, :body, :description
- named_scope :ordered, :order => "name ASC"
+ scope :ordered, order("name ASC")
version_fu rescue nil # hack to silence migration errors when the original table is not there
- def validate
- check_syntax
- end
+ validate :check_syntax
def check_syntax
return if self.body.blank?
@@ -32,7 +30,7 @@ def check_syntax
errors.add(:body, "syntax error at line: #{line}") unless line.nil?
end
rescue => e
- RAILS_DEFAULT_LOGGER.error "Error while validating recipe syntax of recipe #{self.id}: #{e.inspect} - #{e.backtrace.join("\n")}"
+ Rails.logger.error "Error while validating recipe syntax of recipe #{self.id}: #{e.inspect} - #{e.backtrace.join("\n")}"
end
end
View
36 app/models/stage.rb
@@ -18,19 +18,7 @@ class Stage < ActiveRecord::Base
# (think model.errors lite)
attr_accessor :deployment_problems
- EMAIL_BASE_REGEX = '([^@\s\,\<\>\?\&\;\:]+)@((?:[\-a-z0-9]+\.)+[a-z]{2,})'
- EMAIL_REGEX = /^#{EMAIL_BASE_REGEX}$/i
-
- def validate
- unless self.alert_emails.blank?
- self.alert_emails.split(" ").each do |email|
- unless email.match(EMAIL_REGEX)
- self.errors.add('alert_emails', 'format is not valid, please seperate email addresses by space')
- break
- end
- end
- end
- end
+ validate :guard_valid_email_addresses
# wrapper around alert_emails, returns an array of email addresses
def emails
@@ -126,7 +114,7 @@ def list_tasks
begin
deployer.list_tasks.collect { |t| {:name => t.fully_qualified_name, :description => t.description} }.delete_if{|t| t[:name] == 'shell' || t[:name] == 'invoke'}
rescue Exception => e
- RAILS_DEFAULT_LOGGER.error("Problem listing tasks of stage #{id}: #{e} - #{e.backtrace.join("\n")} ")
+ Rails.logger.error("Problem listing tasks of stage #{id}: #{e} - #{e.backtrace.join("\n")} ")
[{:name => "Error", :description => "Could not load tasks - syntax error in recipe definition?"}]
end
end
@@ -152,9 +140,27 @@ def lock_with(deployment)
self.reload
end
- protected
+protected
+
def add_deployment_problem(key, desc)
@deployment_problems = @deployment_problems || {}
@deployment_problems[key] = desc
end
+
+private
+
+ EMAIL_BASE_REGEX = '([^@\s\,\<\>\?\&\;\:]+)@((?:[\-a-z0-9]+\.)+[a-z]{2,})'
+ EMAIL_REGEX = /^#{EMAIL_BASE_REGEX}$/i
+
+ def guard_valid_email_addresses
+ unless self.alert_emails.blank?
+ self.alert_emails.split(" ").each do |email|
+ unless email.match(EMAIL_REGEX)
+ self.errors.add('alert_emails', 'format is not valid, please seperate email addresses by space')
+ break
+ end
+ end
+ end
+ end
+
end
View
43 app/models/user.rb
@@ -17,14 +17,10 @@ class User < ActiveRecord::Base
validates_uniqueness_of :login, :email, :case_sensitive => false
before_save :encrypt_password
- named_scope :enabled, :conditions => {:disabled => nil}
- named_scope :disabled, :conditions => "disabled IS NOT NULL"
+ scope :enabled, where(:disabled => nil)
+ scope :disabled, where("disabled IS NOT NULL")
- def validate_on_update
- if User.find(self.id).admin? && !self.admin?
- errors.add('admin', 'status can no be revoked as there needs to be one admin left.') if User.admin_count == 1
- end
- end
+ validate :guard_last_admin, :on => :update
# Authenticates a user by their login name and unencrypted password. Returns the user or nil.
def self.authenticate(login, password)
@@ -62,13 +58,13 @@ def remember_me_for(time)
def remember_me_until(time)
self.remember_token_expires_at = time
self.remember_token = encrypt("#{email}--#{remember_token_expires_at}")
- save(false)
+ save(:validate => false)
end
def forget_me
self.remember_token_expires_at = nil
self.remember_token = nil
- save(false)
+ save(:validate => false)
end
def admin?
@@ -106,17 +102,22 @@ def enable
self.update_attribute(:disabled, nil)
end
- protected
- # before filter
- def encrypt_password
- return if password.blank?
- self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
- self.crypted_password = encrypt(password)
- end
-
- def password_required?
- WebistranoConfig[:authentication_method] != :cas && (crypted_password.blank? || !password.blank?)
- end
+protected
+ # before filter
+ def encrypt_password
+ return if password.blank?
+ self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
+ self.crypted_password = encrypt(password)
+ end
+
+ def password_required?
+ WebistranoConfig[:authentication_method] != :cas && (crypted_password.blank? || !password.blank?)
+ end
-
+ def guard_last_admin
+ if User.find(self.id).admin? && !self.admin?
+ errors.add('admin', 'status can no be revoked as there needs to be one admin left.') if User.admin_count == 1
+ end
+ end
+
end
View
2  app/views/deployments/index.html.erb
@@ -19,7 +19,7 @@
<%= link_to "Back", project_stage_path(current_project, current_stage), :class => 'arrow_link' %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
Stage <%= link_to current_stage.name, project_stage_path(current_project, current_stage) %> &gt;
View
4 app/views/deployments/new.html.erb
@@ -6,7 +6,7 @@
<% flashed_errors(:deployment) %>
-<% form_for(:deployment, :url => project_stage_deployments_path(@project, @stage)) do |f| %>
+<%= form_for(:deployment, :url => project_stage_deployments_path(@project, @stage)) do |f| %>
<div style="width:330px;">
<p>
<b>Task</b><br />
@@ -119,7 +119,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to stage", project_stage_path(current_project, current_stage), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
2  app/views/deployments/show.html.erb
@@ -3,7 +3,7 @@
</div>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
Stage <%= link_to current_stage.name, project_stage_path(current_project, current_stage) %> &gt;
View
4 app/views/hosts/edit.html.erb
@@ -1,6 +1,6 @@
<% flashed_errors(:host) %>
-<% form_for(:host, :url => host_path(@host), :html => { :method => :put }) do |f| %>
+<%= form_for(:host, :url => host_path(@host), :html => { :method => :put }) do |f| %>
<p>
<b>Name (DNS name or IP address)</b><br />
<%= f.text_field :name, :style => 'width: 330px' %>
@@ -14,7 +14,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to host", host_path(@host), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Hosts", hosts_path %> &gt;
Host <%= link_to @host.name, host_path(@host) %> &gt;
View
2  app/views/hosts/index.html.erb
@@ -23,7 +23,7 @@
</table>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Hosts", hosts_path %>
<% end %>
<% end %>
View
4 app/views/hosts/new.html.erb
@@ -1,6 +1,6 @@
<% flashed_errors(:host) %>
-<% form_for(:host, :url => hosts_path) do |f| %>
+<%= form_for(:host, :url => hosts_path) do |f| %>
<p>
<b>Name (DNS name or IP address)</b><br />
<%= f.text_field :name, :style => 'width: 330px' %>
@@ -14,7 +14,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Manage hosts", hosts_path, :style => "float:right", :class => "arrow_link" %>
<%= link_to "Hosts", hosts_path %> &gt;
New
View
2  app/views/hosts/show.html.erb
@@ -37,7 +37,7 @@
</fieldset>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Manage hosts", hosts_path, :style => "float:right", :class => "arrow_link" %>
<%= link_to "Hosts", hosts_path %> &gt;
Host <%= link_to @host.name, host_path(@host) %>
View
58 app/views/layouts/application.html.erb
@@ -1,60 +1,14 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
+<!DOCTYPE html>
+<html>
<head>
- <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
- <meta name="description" content="Peritor Webistrano - Capristrano Deployment the easy way" />
- <meta name="keywords" content="rubyonrails ruby rails capistrano deployment" />
- <title>Peritor Webistrano - <%=h @page_title %></title>
- <link rel="shortcut icon" href="/favicon.ico"></link>
+ <title>Webistrano</title>
+ <%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
- <%= stylesheet_link_tag 'application' %>
- <%= yield :page_scripts %>
+ <%= csrf_meta_tag %>
</head>
-
<body>
- <div id="app_top">
- <div id="header">
- <div id="header_claim">Capistrano deployment the easy way</div>
- <a href="<%= home_path %>"><%= image_tag('peritor_theme/webistrano_logo.gif', :border => '0')%></a>
- </div>
- <div id="main_content">
- <% if logged_in? %>
- <div class="menu">
- <%= render(:partial => 'layouts/menu') %>
- </div>
- <% else %>
- <div style="width:80px; float:left;">&nbsp;</div>
- <% end %>
- <div class="content">
- <%= yield :breadcrumb %>
- <%= yield :flash_content %>
- <%= yield :page_title %>
-
- <% unless flash[:notice].blank? %>
- <%= nice_flash(flash[:notice]) %>
- <% end %>
- <% unless flash[:error].blank? %>
- <%= error_flash(flash[:error]) %>
- <% end %>
+<%= yield %>
- <%= yield :action_box %>
-
- <%= yield %>
- </div>
- <div class="clear"></div>
- </div>
- </div>
- <div id="app_bottom"></div>
-
- <div id="footer">
- <div id="footer_logged">
- <% if logged_in? %>
- Logged in as <%= link_to h(current_user.login), user_path(current_user) %> | <%= link_to 'Logout', logout_path %>
- <% end %>
- </div>
- Copyright &copy; 2007, 2008, 2009 | Version <%=h WEBISTRANO_VERSION %> | <a href="http://labs.peritor.com/webistrano" target="_blank">http://labs.peritor.com/webistrano</a>
- </div>
</body>
-
</html>
View
4 app/views/project_configurations/edit.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:configuration, :url => project_project_configuration_path(@project, @configuration), :html => { :method => :put }) do |f| %>
+<%= form_for(:configuration, :url => project_project_configuration_path(@project, @configuration), :html => { :method => :put }) do |f| %>
<%= render(:partial => 'form')%>
<br/>
@@ -12,7 +12,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to project", project_path(current_project), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
4 app/views/project_configurations/new.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:configuration, :url => project_project_configurations_path(current_project)) do |f| %>
+<%= form_for(:configuration, :url => project_project_configurations_path(current_project)) do |f| %>
<%= render(:partial => 'form')%>
<br/>
@@ -12,7 +12,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to project", project_path(current_project), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
4 app/views/projects/clone.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:project, :url => clone_path(@original)) do |f| %>
+<%= form_for(:project, :url => clone_path(@original)) do |f| %>
<%= render(:partial => 'form')%>
@@ -10,7 +10,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to project", project_path(@original), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Clone <%= link_to @original.name, project_path(@original) %>
View
4 app/views/projects/edit.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:project, :url => project_path(@project), :html => { :method => :put }) do |f| %>
+<%= form_for(:project, :url => project_path(@project), :html => { :method => :put }) do |f| %>
<%= render(:partial => 'form')%>
@@ -11,7 +11,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to project", project_path(current_project), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
2  app/views/projects/index.html.erb
@@ -37,7 +37,7 @@
</fieldset>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Projects", projects_path %>
<% end %>
<% end %>
View
4 app/views/projects/new.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:project, :url => projects_path) do |f| %>
+<%= form_for(:project, :url => projects_path) do |f| %>
<div style="width:335px;">
<%= render(:partial => 'form')%>
@@ -13,7 +13,7 @@
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Manage Projects", projects_path, :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
New
View
2  app/views/projects/show.html.erb
@@ -64,7 +64,7 @@
</fieldset>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Manage projects", projects_path, :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %>
View
4 app/views/recipes/edit.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:recipe, :url => recipe_path(@recipe), :html => { :method => :put }) do |f| %>
+<%= form_for(:recipe, :url => recipe_path(@recipe), :html => { :method => :put }) do |f| %>
<%= render(:partial => 'form')%>
@@ -11,7 +11,7 @@
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to recipe", recipe_path(@recipe), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Recipes", recipes_path %> &gt;
Recipe <%= link_to @recipe.name, recipe_path(@recipe) %> &gt;
View
2  app/views/recipes/index.html.erb
@@ -37,7 +37,7 @@
</fieldset>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Recipes", recipes_path %>
<% end %>
<% end %>
View
4 app/views/recipes/new.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:recipe, :url => recipes_path) do |f| %>
+<%= form_for(:recipe, :url => recipes_path) do |f| %>
<%= render(:partial => 'form')%>
@@ -12,7 +12,7 @@
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Manage recipes", recipes_path, :style => "float:right", :class => "arrow_link" %>
<%= link_to "Recipes", recipes_path %> &gt;
New
View
2  app/views/recipes/show.html.erb
@@ -56,7 +56,7 @@
</fieldset>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Manage recipes", recipes_path, :style => "float:right", :class => "arrow_link" %>
<%= link_to "Recipes", recipes_path %> &gt;
Recipe <%= link_to @recipe.name, recipe_path(@recipe) %>
View
2  app/views/roles/_form.html.erb
@@ -22,7 +22,7 @@
</p>
<p>
<b>Host</b><br />
- <span class="<%= @role.errors.on('host') ? 'fieldWithErrors' : '' %>">
+ <span class="<%= @role.errors['host'] ? 'fieldWithErrors' : '' %>">
<%= select('role', 'host_id', @host_choices, { :include_blank => true }, {:style => 'width:250px;'}) %>
</span>
</p>
View
4 app/views/roles/edit.html.erb
@@ -1,4 +1,4 @@
-<% form_tag(project_stage_role_path(current_project, current_stage), :method => :put) do %>
+<%= form_tag(project_stage_role_path(current_project, current_stage), :method => :put) do %>
<%= render(:partial => 'form')%>
@@ -10,7 +10,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to stage", project_stage_path(current_project, current_stage), :style => "float:right", :class => "arrow_link" %>
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
Stage <%= link_to current_stage.name, project_stage_path(current_project, current_stage) %> &gt;
View
4 app/views/roles/new.html.erb
@@ -1,4 +1,4 @@
-<% form_tag(project_stage_roles_path(current_project, current_stage), :method => :post) do %>
+<%= form_tag(project_stage_roles_path(current_project, current_stage), :method => :post) do %>
<%= render(:partial => 'form')%>
@@ -10,7 +10,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to stage", project_stage_path(current_project, current_stage), :style => "float:right", :class => "arrow_link" %>
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
Stage <%= link_to current_stage.name, project_stage_path(current_project, current_stage) %> &gt;
View
2  app/views/sessions/new.html.erb
@@ -1,4 +1,4 @@
-<% form_tag sessions_path do -%>
+<%= form_tag sessions_path do -%>
<fieldset class="fieldset">
<legend>Webistrano login</legend>
View
4 app/views/stage_configurations/edit.html.erb
@@ -1,6 +1,6 @@
<% flashed_errors(:configuration) %>
-<% form_for(:configuration, :url => project_stage_stage_configuration_path(@project, @stage, @configuration), :html => { :method => :put }) do |f| %>
+<%= form_for(:configuration, :url => project_stage_stage_configuration_path(@project, @stage, @configuration), :html => { :method => :put }) do |f| %>
<%= render(:partial => 'project_configurations/form')%>
<br/>
@@ -13,7 +13,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to stage", project_stage_path(current_project, current_stage), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
4 app/views/stage_configurations/new.html.erb
@@ -1,6 +1,6 @@
<% flashed_errors(:configuration) %>
-<% form_for(:configuration, :url => project_stage_stage_configurations_path(@project, @stage)) do |f| %>
+<%= form_for(:configuration, :url => project_stage_stage_configurations_path(@project, @stage)) do |f| %>
<%= render(:partial => 'project_configurations/form')%>
<br/>
@@ -13,7 +13,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to stage", project_stage_path(current_project, current_stage), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
4 app/views/stages/edit.html.erb
@@ -1,6 +1,6 @@
<% flashed_errors(:stage) %>
-<% form_for(:stage, :url => project_stage_path(@project, @stage), :html => { :method => :put }) do |f| %>
+<%= form_for(:stage, :url => project_stage_path(@project, @stage), :html => { :method => :put }) do |f| %>
<%= render(:partial => 'form' ) %>
@@ -12,7 +12,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to stage", project_stage_path(current_project, current_stage), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
4 app/views/stages/new.html.erb
@@ -1,6 +1,6 @@
<% flashed_errors(:stage) %>
-<% form_for(:stage, :url => project_stages_path(current_project)) do |f| %>
+<%= form_for(:stage, :url => project_stages_path(current_project)) do |f| %>
<%= render(:partial => 'form' ) %>
@@ -12,7 +12,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to project", project_path(current_project), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
4 app/views/stages/recipes.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:stage, :url => recipes_project_stage_path(@project, @stage), :html => { :method => :put }) do |f| %>
+<%= form_for(:stage, :url => recipes_project_stage_path(@project, @stage), :html => { :method => :put }) do |f| %>
<fieldset class="fieldset">
<legend>Recipes to use</legend>
@@ -39,7 +39,7 @@
<%= link_to 'Back to stage', project_stage_path(current_project, current_stage), :class => 'arrow_link' %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to stage", project_stage_path(current_project, current_stage), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
2  app/views/stages/show.html.erb
@@ -106,7 +106,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to project", project_path(@project), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
2  app/views/stages/tasks.html.erb
@@ -16,7 +16,7 @@
<%= link_to 'Back to stage', project_stage_path(@project, @stage), :class => 'arrow_link' %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to stage", project_stage_path(current_project, current_stage), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Projects", projects_path %> &gt;
Project <%= link_to current_project.name, project_path(current_project) %> &gt;
View
2  app/views/users/deployments.html.erb
@@ -7,7 +7,7 @@
<%= link_to 'Back to user', user_path(@user), :class => 'arrow_link' %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to user", user_path(@user), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Users", users_path %> &gt;
User <%= link_to @user.login, user_path(@user) %> &gt;
View
4 app/views/users/edit.html.erb
@@ -1,4 +1,4 @@
-<% form_for(:user, :url => user_path(@user), :html => { :method => :put }) do |f| %>
+<%= form_for(:user, :url => user_path(@user), :html => { :method => :put }) do |f| %>
<%= render(:partial => 'form')%>
@@ -10,7 +10,7 @@
<% end %>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Back to user", user_path(@user), :style => "float:right", :class => "arrow_link" %>
<%= link_to "Users", users_path %> &gt;
User <%= link_to @user.login, user_path(@user) %> &gt;
View
2  app/views/users/index.html.erb
@@ -44,7 +44,7 @@
</fieldset>
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Users", users_path %>
<% end %>
<% end %>
View
2  app/views/users/new.html.erb
@@ -1,4 +1,4 @@
-<% form_for :user, :url => users_path do |f| -%>
+<%= form_for :user, :url => users_path do |f| -%>
<%= render(:partial => 'form')%>
<%= link_to 'Back to users', users_path, :class => 'arrow_link ontheright', :style => 'margin-right: 330px' %>
View
2  app/views/users/show.html.erb
@@ -52,7 +52,7 @@
<% content_for(:breadcrumb) do %>
- <% breadcrumb_box do %>
+ <%= breadcrumb_box do %>
<%= link_to "Manage users", users_path, :style => "float:right", :class => "arrow_link" %>
<%= link_to "Users", users_path %> &gt;
User <%= link_to @user.login, user_path(@user) %>
View
4 config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Webistrano::Application
View
44 config/application.rb
@@ -0,0 +1,44 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+module Webistrano
+ class Application < Rails::Application
+
+
+ # Make Active Record use UTC-base instead of local time
+ config.time_zone = 'UTC'
+
+ initializer "webistrano.load" do
+ require 'authenticated_system'
+ require 'webistrano'
+ end
+
+ initializer "webistrano.configure" do
+ require "#{Rails.root}/config/webistrano_config"
+ config.secret_token = WebistranoConfig[:session_secret]
+ end
+
+ initializer "webistrano.clean_stylsheet" do
+ stylesheet = "#{Rails.root}/public/stylesheets/application.css"
+ File.delete(stylesheet) if File.exists?(stylesheet)
+ end
+
+ end
+end
+
+
+# TODO: is this needed? -- fd
+require 'open4'
+require 'capistrano/cli'
+require 'syntax/convertors/html'
+
+
+# set default time_zone to UTC
+# TODO: is this needed? -- fd
+ENV['TZ'] = 'UTC'
+Time.zone = 'UTC'
View
122 config/boot.rb
@@ -1,109 +1,13 @@
-# Don't change this file!
-# Configure your app in config/environment.rb and config/environments/*.rb
-
-RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
-
-module Rails
- class << self
- def boot!
- unless booted?
- preinitialize
- pick_boot.run
- end
- end
-
- def booted?
- defined? Rails::Initializer
- end
-
- def pick_boot
- (vendor_rails? ? VendorBoot : GemBoot).new
- end
-
- def vendor_rails?
- File.exist?("#{RAILS_ROOT}/vendor/rails")
- end
-
- def preinitialize
- load(preinitializer_path) if File.exist?(preinitializer_path)
- end
-
- def preinitializer_path
- "#{RAILS_ROOT}/config/preinitializer.rb"
- end
- end
-
- class Boot
- def run
- load_initializer
- Rails::Initializer.run(:set_load_path)
- end
- end
-
- class VendorBoot < Boot
- def load_initializer
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
- Rails::Initializer.run(:install_gem_spec_stubs)
- end
- end
-
- class GemBoot < Boot
- def load_initializer
- self.class.load_rubygems
- load_rails_gem
- require 'initializer'
- end
-
- def load_rails_gem
- if version = self.class.gem_version
- gem 'rails', version
- else
- gem 'rails'
- end
- rescue Gem::LoadError => load_error
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
- exit 1
- end
-
- class << self
- def rubygems_version
- Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
- end
-
- def gem_version
- if defined? RAILS_GEM_VERSION
- RAILS_GEM_VERSION
- elsif ENV.include?('RAILS_GEM_VERSION')
- ENV['RAILS_GEM_VERSION']
- else
- parse_gem_version(read_environment_rb)
- end
- end
-
- def load_rubygems
- require 'rubygems'
- min_version = '1.1.1'
- unless rubygems_version >= min_version
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
- exit 1
- end
-
- rescue LoadError
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
- exit 1
- end
-
- def parse_gem_version(text)
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
- end
-
- private
- def read_environment_rb
- File.read("#{RAILS_ROOT}/config/environment.rb")
- end
- end
- end
-end
-
-# All that for this:
-Rails.boot!
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+gemfile = File.expand_path('../../Gemfile', __FILE__)
+begin
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ require 'bundler'
+ Bundler.setup
+rescue Bundler::GemNotFound => e
+ STDERR.puts e.message
+ STDERR.puts "Try running `bundle install`."
+ exit!
+end if File.exist?(gemfile)
View
37 config/database.yml.sample
@@ -1,32 +1,19 @@
-# MySQL (default setup). Versions 4.1 and 5.0 are recommended.
-#
-# Install the MySQL driver:
-# gem install mysql
-# On MacOS X:
-# gem install mysql -- --include=/usr/local/lib
-# On Windows:
-# gem install mysql
-# Choose the win32 build.
-# Install MySQL and put its /bin directory on your path.
-#
-# And be sure to use new-style password hashing:
-# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
- adapter: mysql
- database: webistrano_development
- username: root
- password:
- socket: /tmp/mysql.sock
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
-# Warning: The database defined as 'test' will be erased and
-# re-generated from your development database when you run 'rake'.
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
- adapter: mysql
- database: webistrano_test
- username: root
- password:
- socket: /tmp/mysql.sock
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
production:
adapter: mysql
View
52 config/environment.rb
@@ -1,49 +1,5 @@
-# Be sure to restart your server when you modify this file
+# Load the rails application
+require File.expand_path('../application', __FILE__)
-# Uncomment below to force Rails into production mode when
-# you don't control web/app server and can't set it the proper way
-# ENV['RAILS_ENV'] ||= 'production'
-
-# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
-
-# Bootstrap the Rails environment, frameworks, and default configuration
-require File.join(File.dirname(__FILE__), 'boot')
-
-# load Webistrano configuration
-require "#{RAILS_ROOT}/config/webistrano_config"
-
-Rails::Initializer.run do |config|
-
- # Your secret key for verifying cookie session data integrity.
- # If you change this key, all old sessions will become invalid!
- # Make sure the secret is at least 30 characters and all random,
- # no regular words or you'll be exposed to dictionary attacks.
- config.action_controller.session = {
- :session_key => '_webistrano_session',
- :secret => WebistranoConfig[:session_secret]
- }
-
- # Make Active Record use UTC-base instead of local time
- config.time_zone = 'UTC'
-
- config.gem 'net-ssh', :version => '2.0.15', :lib => 'net/ssh'
- config.gem 'net-scp', :version => '1.0.2', :lib => 'net/scp'
- config.gem 'net-sftp', :version => '2.0.2', :lib => 'net/sftp'
- config.gem 'net-ssh-gateway', :version => '1.0.1', :lib => 'net/ssh/gateway'
- config.gem 'capistrano', :version => '2.5.9'
- config.gem 'highline', :version => '1.5.1'
- config.gem 'open4', :version => '0.9.3'
- config.gem 'syntax', :version => '1.0.0'
-end
-
-require 'open4'
-require 'capistrano/cli'
-require 'syntax/convertors/html'
-
-# delete cached stylesheet on boot in order to delete stale versions
-File.delete("#{RAILS_ROOT}/public/stylesheets/application.css") if File.exists?("#{RAILS_ROOT}/public/stylesheets/application.css")
-
-# set default time_zone to UTC
-ENV['TZ'] = 'UTC'
-Time.zone = 'UTC'
+# Initialize the rails application
+Webistrano::Application.initialize!
View
35 config/environments/development.rb
@@ -1,17 +1,26 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Webistrano::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# In the development environment your application's code is reloaded on
-# every request. This slows down response time but is perfect for development
-# since you don't have to restart the webserver when you make code changes.
-config.cache_classes = false
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the webserver when you make code changes.
+ config.cache_classes = false
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching = false
-config.action_view.debug_rjs = true
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_view.debug_rjs = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+end
-# Don't care if the mailer can't send
-config.action_mailer.raise_delivery_errors = false
View
58 config/environments/production.rb
@@ -1,21 +1,49 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Webistrano::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# The production environment is meant for finished, "live" apps.
-# Code is not reloaded between requests
-config.cache_classes = true
+ # The production environment is meant for finished, "live" apps.
+ # Code is not reloaded between requests
+ config.cache_classes = true
-# Use a different logger for distributed setups
-# config.logger = SyslogLogger.new
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
-# Full error reports are disabled and caching is turned on
-config.action_controller.consider_all_requests_local = false
-config.action_controller.perform_caching = true
+ # Specifies the header that your server uses for sending files
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
-# Enable serving of images, stylesheets, and javascripts from an asset server
-# config.action_controller.asset_host = "http://assets.example.com"
+ # For nginx:
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
-# Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
+ # If you have no front-end server that supports something like X-Sendfile,
+ # just comment this out and Rails will serve the files
-# long only errors
-config.log_level = :error
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Disable Rails's static asset server
+ # In production, Apache or nginx will already do this
+ config.serve_static_assets = false
+
+ # Enable serving of images, stylesheets, and javascripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
View
48 config/environments/test.rb
@@ -1,25 +1,35 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Webistrano::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
-# The test environment is used exclusively to run your application's
-# test suite. You never need to work with it otherwise. Remember that
-# your test database is "scratch space" for the test suite and is wiped
-# and recreated between test runs. Don't rely on the data there!
-config.cache_classes = true
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = true
-# Log error messages when you accidentally call methods on nil.
-config.whiny_nils = true
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching = false
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
-# Disable request forgery protection in test environment
-config.action_controller.allow_forgery_protection = false
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
-# Tell ActionMailer not to deliver emails to the real world.
-# The :test delivery method accumulates sent emails in the
-# ActionMailer::Base.deliveries array.