Browse files

Upgrade to Rails 3.1

  • Loading branch information...
1 parent 6b1df07 commit b1c91c09ff84d4dc53040a2ebf02715ee3fb4ce8 @rwdaigle committed Dec 20, 2011
Showing with 961 additions and 6,337 deletions.
  1. +15 −2 .gitignore
  2. +24 −13 Gemfile
  3. +112 −58 Gemfile.lock
  4. +151 −93 README
  5. +3 −6 Rakefile
  6. BIN app/assets/images/rails.png
  7. +9 −0 app/assets/javascripts/application.js
  8. +7 −0 app/assets/stylesheets/application.css
  9. +21 −0 app/controllers/application_controller.rb
  10. +1 −2 app/helpers/application_helper.rb
  11. 0 app/mailers/.gitkeep
  12. 0 app/models/.gitkeep
  13. +14 −0 app/views/layouts/application.html.erb
  14. +4 −0 config.ru
  15. +48 −0 config/application.rb
  16. +4 −107 config/boot.rb
  17. +4 −51 config/environment.rb
  18. +26 −13 config/environments/development.rb
  19. +54 −15 config/environments/production.rb
  20. +34 −17 config/environments/test.rb
  21. +7 −0 config/initializers/backtrace_silencers.rb
  22. +2 −2 config/initializers/inflections.rb
  23. +7 −0 config/initializers/secret_token.rb
  24. +8 −0 config/initializers/session_store.rb
  25. +14 −0 config/initializers/wrap_parameters.rb
  26. +5 −0 config/locales/en.yml
  27. +73 −19 config/routes.rb
  28. +7 −0 db/seeds.rb
  29. 0 lib/assets/.gitkeep
  30. 0 lib/tasks/.gitkeep
  31. 0 log/.gitkeep
  32. +15 −19 public/404.html
  33. +15 −19 public/422.html
  34. +15 −19 public/500.html
  35. +241 −0 public/index.html
  36. +6 −0 script/rails
  37. 0 test/fixtures/.gitkeep
  38. 0 test/functional/.gitkeep
  39. 0 test/integration/.gitkeep
  40. +12 −0 test/performance/browsing_test.rb
  41. +3 −28 test/test_helper.rb
  42. 0 test/unit/.gitkeep
  43. 0 vendor/assets/stylesheets/.gitkeep
  44. +0 −122 vendor/gems/fiveruns_manage-1.0.4/fiveruns_manage.gemspec
  45. +0 −180 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage.rb
  46. +0 −76 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/plugin.rb
  47. +0 −136 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/reporter.rb
  48. +0 −28 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets.rb
  49. +0 −37 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/configuration.rb
  50. +0 −144 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails.rb
  51. +0 −71 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/action_controller/base.rb
  52. +0 −19 ...r/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/action_controller/routing_error.rb
  53. +0 −27 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/action_mailer/base.rb
  54. +0 −103 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/action_view/base.rb
  55. +0 −27 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/action_view/partial_template.rb
  56. +0 −24 ...or/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/action_view/renderable_partial.rb
  57. +0 −44 ...gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/active_record/active_record_error.rb
  58. +0 −214 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/active_record/base.rb
  59. +0 −29 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/cgi/session.rb
  60. +0 −43 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/mongrel/http_response.rb
  61. +0 −22 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/rails/mongrel/http_server.rb
  62. +0 −112 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/targets/target.rb
  63. +0 −91 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage/version.rb
  64. +0 −1 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns_manage.rb
  65. +0 −138 vendor/gems/haml-2.0.0/FAQ
  66. +0 −20 vendor/gems/haml-2.0.0/MIT-LICENSE
  67. +0 −319 vendor/gems/haml-2.0.0/README.rdoc
  68. +0 −146 vendor/gems/haml-2.0.0/Rakefile
  69. +0 −1 vendor/gems/haml-2.0.0/VERSION
  70. +0 −7 vendor/gems/haml-2.0.0/bin/css2sass
  71. +0 −8 vendor/gems/haml-2.0.0/bin/haml
  72. +0 −8 vendor/gems/haml-2.0.0/bin/sass
  73. +0 −7 vendor/gems/haml-2.0.0/init.rb
  74. +0 −1,029 vendor/gems/haml-2.0.0/lib/haml.rb
  75. +0 −45 vendor/gems/haml-2.0.0/lib/haml/helpers/action_view_extensions.rb
  76. +0 −134 vendor/gems/haml-2.0.0/lib/haml/helpers/action_view_mods.rb
  77. +0 −833 vendor/gems/haml-2.0.0/lib/sass.rb
  78. +0 −15 vendor/gems/haml-2.0.0/test/haml/results/content_for_layout.xhtml
  79. +0 −9 vendor/gems/haml-2.0.0/test/haml/results/eval_suppressed.xhtml
  80. +0 −63 vendor/gems/haml-2.0.0/test/haml/results/just_stuff.xhtml
  81. +0 −34 vendor/gems/haml-2.0.0/test/haml/results/nuke_inner_whitespace.xhtml
  82. +0 −148 vendor/gems/haml-2.0.0/test/haml/results/nuke_outer_whitespace.xhtml
  83. +0 −20 vendor/gems/haml-2.0.0/test/haml/results/original_engine.xhtml
  84. +0 −74 vendor/gems/haml-2.0.0/test/haml/results/silent_script.xhtml
  85. +0 −23 vendor/gems/haml-2.0.0/test/haml/results/tag_parsing.xhtml
  86. +0 −5 vendor/gems/haml-2.0.0/test/haml/results/very_basic.xhtml
  87. +0 −86 vendor/gems/haml-2.0.0/test/haml/results/whitespace_handling.xhtml
  88. +0 −12 vendor/gems/haml-2.0.0/test/haml/rhtml/_av_partial_1.rhtml
  89. +0 −8 vendor/gems/haml-2.0.0/test/haml/rhtml/_av_partial_2.rhtml
  90. +0 −62 vendor/gems/haml-2.0.0/test/haml/rhtml/action_view.rhtml
  91. +0 −9 vendor/gems/haml-2.0.0/test/haml/templates/_av_partial_1.haml
  92. +0 −5 vendor/gems/haml-2.0.0/test/haml/templates/_av_partial_2.haml
  93. +0 −8 vendor/gems/haml-2.0.0/test/haml/templates/_partial.haml
  94. +0 −3 vendor/gems/haml-2.0.0/test/haml/templates/_text_area.haml
  95. +0 −47 vendor/gems/haml-2.0.0/test/haml/templates/action_view.haml
  96. +0 −8 vendor/gems/haml-2.0.0/test/haml/templates/breakage.haml
  97. +0 −10 vendor/gems/haml-2.0.0/test/haml/templates/content_for_layout.haml
  98. +0 −11 vendor/gems/haml-2.0.0/test/haml/templates/eval_suppressed.haml
  99. +0 −77 vendor/gems/haml-2.0.0/test/haml/templates/just_stuff.haml
  100. +0 −26 vendor/gems/haml-2.0.0/test/haml/templates/nuke_inner_whitespace.haml
  101. +0 −144 vendor/gems/haml-2.0.0/test/haml/templates/nuke_outer_whitespace.haml
  102. +0 −17 vendor/gems/haml-2.0.0/test/haml/templates/original_engine.haml
  103. +0 −1 vendor/gems/haml-2.0.0/test/haml/templates/partialize.haml
  104. +0 −12 vendor/gems/haml-2.0.0/test/haml/templates/partials.haml
  105. +0 −40 vendor/gems/haml-2.0.0/test/haml/templates/silent_script.haml
  106. +0 −42 vendor/gems/haml-2.0.0/test/haml/templates/standard.haml
  107. +0 −21 vendor/gems/haml-2.0.0/test/haml/templates/tag_parsing.haml
  108. +0 −4 vendor/gems/haml-2.0.0/test/haml/templates/very_basic.haml
  109. +0 −87 vendor/gems/haml-2.0.0/test/haml/templates/whitespace_handling.haml
  110. +0 −1 vendor/gems/haml-2.0.0/test/sass/results/subdir/nested_subdir/nested_subdir.css
  111. +0 −1 vendor/gems/haml-2.0.0/test/sass/results/subdir/subdir.css
  112. +0 −2 vendor/gems/haml-2.0.0/test/sass/templates/_partial.sass
  113. +0 −15 vendor/gems/haml-2.0.0/test/sass/templates/compressed.sass
  114. +0 −97 vendor/gems/haml-2.0.0/test/sass/templates/constants.sass
  115. +0 −17 vendor/gems/haml-2.0.0/test/sass/templates/expanded.sass
  116. +0 −20 vendor/gems/haml-2.0.0/test/sass/templates/multiline.sass
  117. +0 −25 vendor/gems/haml-2.0.0/test/sass/templates/parent_ref.sass
  118. +0 −3 vendor/gems/haml-2.0.0/test/sass/templates/subdir/nested_subdir/nested_subdir.sass
  119. +0 −6 vendor/gems/haml-2.0.0/test/sass/templates/subdir/subdir.sass
  120. +0 −84 vendor/gems/yfactorial-utility_scopes-0.1.0/.specification
  121. +0 −13 vendor/gems/yfactorial-utility_scopes-0.1.0/lib/utility_scopes.rb
  122. +0 −10 vendor/gems/yfactorial-utility_scopes-0.1.0/lib/utility_scopes/eager.rb
  123. +0 −26 vendor/gems/yfactorial-utility_scopes-0.1.0/lib/utility_scopes/limited.rb
  124. +0 −52 vendor/gems/yfactorial-utility_scopes-0.1.0/lib/utility_scopes/ordered.rb
  125. +0 −10 vendor/gems/yfactorial-utility_scopes-0.1.0/spec/abstract_spec.rb
  126. +0 −20 vendor/gems/yfactorial-utility_scopes-0.1.0/spec/eager_spec.rb
  127. +0 −2 vendor/gems/yfactorial-utility_scopes-0.1.0/spec/fixtures/article.rb
  128. +0 −36 vendor/gems/yfactorial-utility_scopes-0.1.0/spec/limit_spec.rb
  129. +0 −28 vendor/gems/yfactorial-utility_scopes-0.1.0/spec/ordered_spec.rb
  130. +0 −5 vendor/gems/yfactorial-utility_scopes-0.1.0/spec/spec_helper.rb
  131. 0 vendor/plugins/.gitkeep
  132. +0 −5 vendor/rails/actionpack/test/fixtures/layout_tests/layouts/symlinked/symlinked_layout.erb
View
17 .gitignore
@@ -1,2 +1,15 @@
-*.tmproj
-log/*.log
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+
+# Ignore bundler config
+/.bundle
+
+# Ignore the default SQLite database.
+/db/*.sqlite3
+
+# Ignore all logfiles and tempfiles.
+/log/*.log
+/tmp
View
37 Gemfile
@@ -1,13 +1,24 @@
-source "http://rubygems.org"
-
-gem "rails", "~> 2.1"
-gem "haml"
-gem "utility_scopes"
-gem "thin"
-gem "pg"
-
-group :development, :test do
- gem "heroku"
- gem "foreman"
- gem "rspec"
-end
+source 'http://rubygems.org'
+
+gem 'rails', '~> 3.1'
+gem 'utility_scopes'
+
+gem 'haml'
+gem 'jquery-rails'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', '~> 3.1.5'
+ gem 'coffee-rails', '~> 3.1.1'
+ gem 'uglifier', '>= 1.0.3'
+end
+
+group :test do
+ # Pretty printed test output
+ gem 'turn', '0.8.2', :require => false
+end
+
+group :production do
+ gem 'unicorn'
+end
View
170 Gemfile.lock
@@ -1,73 +1,127 @@
GEM
remote: http://rubygems.org/
specs:
- actionmailer (2.3.14)
- actionpack (= 2.3.14)
- actionpack (2.3.14)
- activesupport (= 2.3.14)
- rack (~> 1.1.0)
- activerecord (2.3.14)
- activesupport (= 2.3.14)
- activeresource (2.3.14)
- activesupport (= 2.3.14)
- activesupport (2.3.14)
- addressable (2.2.6)
- daemons (1.1.5)
- diff-lcs (1.1.3)
- eventmachine (0.12.10)
- foreman (0.27.0)
- term-ansicolor (~> 1.0.5)
- thor (>= 0.13.6)
+ actionmailer (3.1.3)
+ actionpack (= 3.1.3)
+ mail (~> 2.3.0)
+ actionpack (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.5)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.3)
+ activemodel (3.1.3)
+ activesupport (= 3.1.3)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.3)
+ activemodel (= 3.1.3)
+ activesupport (= 3.1.3)
+ activesupport (3.1.3)
+ multi_json (~> 1.0)
+ ansi (1.4.1)
+ arel (2.2.1)
+ builder (3.0.0)
+ coffee-rails (3.1.1)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.2.0)
+ erubis (2.7.0)
+ execjs (1.2.13)
+ multi_json (~> 1.0)
haml (3.1.4)
- heroku (2.17.0)
- launchy (>= 0.3.2)
- rest-client (~> 1.6.1)
- rubyzip
- term-ansicolor (~> 1.0.5)
- launchy (2.0.5)
- addressable (~> 2.2.6)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.19)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ json (1.6.3)
+ kgio (2.7.0)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
mime-types (1.17.2)
- pg (0.12.0)
- rake-compiler (~> 0.7)
- rack (1.1.2)
- rails (2.3.14)
- actionmailer (= 2.3.14)
- actionpack (= 2.3.14)
- activerecord (= 2.3.14)
- activeresource (= 2.3.14)
- activesupport (= 2.3.14)
- rake (>= 0.8.3)
- rake (0.9.2.2)
- rake-compiler (0.7.9)
- rake
- rest-client (1.6.7)
- mime-types (>= 1.16)
- rspec (2.7.0)
- rspec-core (~> 2.7.0)
- rspec-expectations (~> 2.7.0)
- rspec-mocks (~> 2.7.0)
- rspec-core (2.7.1)
- rspec-expectations (2.7.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.7.0)
- rubyzip (0.9.5)
- term-ansicolor (1.0.7)
- thin (1.3.1)
- daemons (>= 1.0.9)
- eventmachine (>= 0.12.6)
+ multi_json (1.0.4)
+ polyglot (0.3.3)
+ rack (1.3.5)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.3)
+ actionmailer (= 3.1.3)
+ actionpack (= 3.1.3)
+ activerecord (= 3.1.3)
+ activeresource (= 3.1.3)
+ activesupport (= 3.1.3)
+ bundler (~> 1.0)
+ railties (= 3.1.3)
+ railties (3.1.3)
+ actionpack (= 3.1.3)
+ activesupport (= 3.1.3)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ raindrops (0.8.0)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ sass (3.1.12)
+ sass-rails (3.1.5)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (~> 3.1.10)
+ tilt (~> 1.3.2)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ turn (0.8.2)
+ ansi (>= 1.2.2)
+ tzinfo (0.3.31)
+ uglifier (1.2.0)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+ unicorn (4.1.1)
+ kgio (~> 2.4)
+ rack
+ raindrops (~> 0.6)
utility_scopes (0.3.1)
PLATFORMS
ruby
DEPENDENCIES
- foreman
+ coffee-rails (~> 3.1.1)
haml
- heroku
- pg
- rails (~> 2.1)
- rspec
- thin
+ jquery-rails
+ rails (~> 3.1)
+ sass-rails (~> 3.1.5)
+ turn (= 0.8.2)
+ uglifier (>= 1.0.3)
+ unicorn
utility_scopes
View
244 README
@@ -1,14 +1,15 @@
== Welcome to Rails
-Rails is a web-application and persistence framework that includes everything
-needed to create database-backed web-applications according to the
-Model-View-Control pattern of separation. 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.
+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
@@ -21,59 +22,40 @@ 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
+Rails. You can read more about Action Pack in
link:files/vendor/rails/actionpack/README.html.
== Getting Started
-1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
- and your application name. Ex: rails myapp
- (If you've downloaded Rails in a complete tgz or zip, this step is already done)
-2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
-3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
-4. Follow the guidelines to start developing your application
-
-
-== Web Servers
+1. At the command prompt, create a new Rails application:
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
-By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
-Rails will use WEBrick, the webserver that ships with Ruby. When you run script/server,
-Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
-that you can always get up and running quickly.
+2. Change directory to <tt>myapp</tt> and start the web server:
+ <tt>cd myapp; rails server</tt> (run with --help for options)
-Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
-suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
-getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
-More info at: http://mongrel.rubyforge.org
+3. Go to http://localhost:3000/ and you'll see:
+ "Welcome aboard: You're riding Ruby on Rails!"
-If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
-Mongrel and WEBrick and also suited for production use, but requires additional
-installation and currently only works well on OS X/Unix (Windows users are encouraged
-to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
-http://www.lighttpd.net.
+4. Follow the guidelines to start developing your application. You can find
+the following resources handy:
-And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
-web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
-for production.
-
-But of course its also possible to run Rails on any platform that supports FCGI.
-Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
-please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
+* 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
+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.
+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:
+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
@@ -85,28 +67,31 @@ the Ruby logger class from inside your controllers. Example:
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
+ 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/ including:
+Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
+several books available online as well:
-* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
-* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
-These two online (and free) books will bring you up to speed on the Ruby language
-and also on programming in general.
+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! Example:
+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)
+ @posts = Post.all
debugger
end
end
@@ -115,89 +100,162 @@ 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 you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
+ => "[#<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 is that you can examine how your runtime objects actually work:
+...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 enter "cont"
+Finally, when you're ready to resume execution, you can enter "cont".
== Console
-You can interact with the domain model by starting the console through <tt>script/console</tt>.
-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.
-Passing an argument will specify a different environment, like <tt>script/console production</tt>.
+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:
-To reload your controllers and models after launching the console run <tt>reload!</tt>
+* 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.org/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
+ | |-- assets
+ | |-- images
+ | |-- javascripts
+ | `-- stylesheets
+ | |-- controllers
+ | |-- helpers
+ | |-- mailers
+ | |-- models
+ | `-- views
+ | `-- layouts
+ |-- config
+ | |-- environments
+ | |-- initializers
+ | `-- locales
+ |-- db
+ |-- doc
+ |-- lib
+ | `-- tasks
+ |-- log
+ |-- public
+ |-- script
+ |-- test
+ | |-- fixtures
+ | |-- functional
+ | |-- integration
+ | |-- performance
+ | `-- unit
+ |-- tmp
+ | |-- cache
+ | |-- pids
+ | |-- sessions
+ | `-- sockets
+ `-- vendor
+ |-- assets
+ `-- stylesheets
+ `-- plugins
+
app
Holds all the code that's specific to this particular application.
+app/assets
+ Contains subdirectories for images, stylesheets, and JavaScript files.
+
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.
+ 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.
- Most models will descend from ActiveRecord::Base.
+ 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.erb for the WeblogsController#index action. All views use eRuby
- syntax.
+ 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.erb. Inside default.erb,
- call <% yield %> to render the view using this layout.
+ 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 script/generate for controllers. Helpers can be used to
- wrap functionality for your views into methods.
+ 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.
+ 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.
+ 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>
+ 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.
+ 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.
+ The directory available for the web server. 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 script/generate scripts, template
- test files will be generated for you and placed in this directory.
+ 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.
- This directory is in the load path.
+ 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
9 Rakefile
@@ -1,10 +1,7 @@
+#!/usr/bin/env rake
# 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'
+Ptls::Application.load_tasks
View
BIN app/assets/images/rails.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
9 app/assets/javascripts/application.js
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
View
7 app/assets/stylesheets/application.css
@@ -0,0 +1,7 @@
+/*
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
+ *= require_self
+ *= require_tree .
+*/
View
21 app/controllers/application_controller.rb
@@ -0,0 +1,21 @@
+class ApplicationController < ActionController::Base
+
+ # Standard configs
+ helper :all
+ include AuthenticatedSystem
+ protect_from_forgery
+
+ # Most everything requires a logged in user
+ before_filter :login_required
+ before_filter :set_user_time_zone
+
+ # Assume we want the subject-relevant layout unless told otherwise
+ layout 'subject'
+
+ private
+
+ # User-specific time zones
+ def set_user_time_zone
+ Time.zone = current_user.time_zone if logged_in?
+ end
+end
View
3 app/helpers/application_helper.rb
@@ -1,6 +1,5 @@
-# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
-
+
# Set the title for the page
def page_title(page_title)
content_for(:page_title, page_title)
View
0 app/mailers/.gitkeep
No changes.
View
0 app/models/.gitkeep
No changes.
View
14 app/views/layouts/application.html.erb
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Ptls</title>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>
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 Ptls::Application
View
48 config/application.rb
@@ -0,0 +1,48 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+if defined?(Bundler)
+ # If you precompile assets before deploying to production, use this line
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
+ # If you want your assets lazily compiled in production, use this line
+ # Bundler.require(:default, :assets, Rails.env)
+end
+
+module Ptls
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+
+ # Enable the asset pipeline
+ config.assets.enabled = true
+
+ # Version of your assets, change this if you want to expire all your assets
+ config.assets.version = '1.0'
+ end
+end
View
111 config/boot.rb
@@ -1,109 +1,6 @@
-# Don't change this file!
-# Configure your app in config/environment.rb and config/environments/*.rb
+require 'rubygems'
-RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
-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'
-
- unless rubygems_version >= '0.9.4'
- $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
- exit 1
- end
-
- rescue LoadError
- $stderr.puts %(Rails requires RubyGems >= 0.9.4. 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 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
View
55 config/environment.rb
@@ -1,52 +1,5 @@
-# Bootstrap the Rails environment, frameworks, and default configuration
-require File.join(File.dirname(__FILE__), 'boot')
+# Load the rails application
+require File.expand_path('../application', __FILE__)
-Rails::Initializer.run do |config|
- # Settings in config/environments/* take precedence over those specified here.
- # Application configuration should go into files in config/initializers
- # -- all .rb files in that directory are automatically loaded.
- # See Rails::Configuration for more options.
-
- # Skip frameworks you're not going to use (only works if using vendor/rails).
- # To use Rails without a database, you must remove the Active Record framework
- config.frameworks -= [ :action_mailer ]
-
- # Only load the plugins named here, in the order given. By default, all plugins
- # in vendor/plugins are loaded in alphabetical order.
- # :all can be usesed as a placeholder for all plugins not explicitly named
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
-
- # Add additional load paths for your own custom dirs
- # config.load_paths += %W( #{RAILS_ROOT}/extras )
- config.gem "haml"
- config.gem "utility_scopes"
-
- # Force all environments to use the same logger level
- # (by default production uses :info, the others :debug)
- # config.log_level = :debug
-
- # 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 => '_ptls_session',
- :secret => ENV["SESSION_SECRET"] || "not in production"
- }
-
- # Use the database for sessions instead of the cookie-based default,
- # which shouldn't be used to store highly confidential information
- # (create the session table with 'rake db:sessions:create')
- # config.action_controller.session_store = :active_record_store
-
- # Use SQL instead of Active Record's schema dumper when creating the test database.
- # This is necessary if your schema can't be completely dumped by the schema dumper,
- # like if you have constraints or database-specific column types
- # config.active_record.schema_format = :sql
-
- # Activate observers that should always be running
- config.active_record.observers = :learning_observer
-
- # Make Active Record use UTC-base instead of local time
- config.time_zone = "Eastern Time (US & Canada)"
-end
+# Initialize the rails application
+Ptls::Application.initialize!
View
39 config/environments/development.rb
@@ -1,17 +1,30 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Ptls::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 web server 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_view.debug_rjs = 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
-# Don't care if the mailer can't send
-config.action_mailer.raise_delivery_errors = 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
+
+ # Do not compress assets
+ config.assets.compress = false
+
+ # Expands the lines which load the assets
+ config.assets.debug = true
+end
View
69 config/environments/production.rb
@@ -1,21 +1,60 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Ptls::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
+ # 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
-config.action_view.cache_template_loading = true
+ # Disable Rails's static asset server (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"
+ # Compress JavaScripts and CSS
+ config.assets.compress = true
-# Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
+ # Don't fallback to assets pipeline if a precompiled asset is missed
+ config.assets.compile = false
-config.log_level = :debug
+ # Generate digests for assets URLs
+ config.assets.digest = true
+
+ # Defaults to Rails.root.join("public/assets")
+ # config.assets.manifest = YOUR_PATH
+
+ # Specifies the header that your server uses for sending files
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # 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
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
+ # config.assets.precompile += %w( search.js )
+
+ # 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
51 config/environments/test.rb
@@ -1,22 +1,39 @@
-# Settings specified here will take precedence over those in config/environment.rb
+Ptls::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
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
-# Show full error reports and disable caching
-config.action_controller.consider_all_requests_local = true
-config.action_controller.perform_caching = false
+ # Log error messages when you accidentally call methods on nil
+ config.whiny_nils = true
-# Disable request forgery protection in test environment
-config.action_controller.allow_forgery_protection = false
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
-# Tell ActionMailer not to deliver emails to the real world.
-# The :test delivery method accumulates sent emails in the
-# ActionMailer::Base.deliveries array.
-config.action_mailer.delivery_method = :test
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
View
7 config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
View
4 config/initializers/inflections.rb
@@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.
-# Add new inflection rules using the following format
+# Add new inflection rules using the following format
# (all these examples are active by default):
-# Inflector.inflections do |inflect|
+# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
View
7 config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies 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.
+Ptls::Application.config.secret_token = ENV['SESSION_SECRET'] || 'not in production'
View
8 config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Ptls::Application.config.session_store :cookie_store, key: '_ptls_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+# Ptls::Application.config.session_store :active_record_store
View
14 config/initializers/wrap_parameters.rb
@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+ wrap_parameters format: [:json]
+end
+
+# Disable root element in JSON by default.
+ActiveSupport.on_load(:active_record) do
+ self.include_root_in_json = false
+end
View
5 config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
View
92 config/routes.rb
@@ -1,27 +1,81 @@
-ActionController::Routing::Routes.draw do |map|
-
- map.root :controller => 'sessions', :action => 'start'
+Ptls::Application.routes.draw do
- map.resources :users
+ root :to => 'sessions#start'
- map.resource :session
+ resources :users
+ resource :session
+ resources :reviews, :member => { :review => :put }, :collection => { :shift => :put }
+ resources :learnings, :member => { :review => :put }
+ resources :associations
- map.resources :reviews, :member => { :review => :put }, :collection => { :shift => :put }
-
- map.resources :learnings, :member => { :review => :put }
-
- map.resources :associations
-
- map.resources :units, :member => { :edit_question => :get, :edit_answer => :get } do |unit|
- unit.resources :learnings
+ resources :units, :member => { :edit_question => :get, :edit_answer => :get } do
+ resources :learnings
end
-
- map.resources :subjects, :member => { :learn => :get, :review => :get, :quiz => :get } do |subject|
- subject.resources :learnings, :collection => { :today => :get }
- subject.resources :reviews, :collection => { :missed => :get, :shift => :put }
+
+ resources :subjects, :member => { :learn => :get, :review => :get, :quiz => :get } do
+ resources :learnings, :collection => { :today => :get }
+ resources :reviews, :collection => { :missed => :get, :shift => :put }
end
# Niceities
- map.login 'login', :controller => 'sessions', :action => 'new'
- map.logout 'logout', :controller => 'sessions', :action => 'destroy'
+ match 'login', :to => 'sessions#new'
+ match 'logout', :to => 'sessions#destroy'
+end
+
+ # The priority is based upon order of creation:
+ # first created -> highest priority.
+
+ # Sample of regular route:
+ # match 'products/:id' => 'catalog#view'
+ # Keep in mind you can assign values other than :controller and :action
+
+ # Sample of named route:
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
+ # This route can be invoked with purchase_url(:id => product.id)
+
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
+ # resources :products
+
+ # Sample resource route with options:
+ # resources :products do
+ # member do
+ # get 'short'
+ # post 'toggle'
+ # end
+ #
+ # collection do
+ # get 'sold'
+ # end
+ # end
+
+ # Sample resource route with sub-resources:
+ # resources :products do
+ # resources :comments, :sales
+ # resource :seller
+ # end
+
+ # Sample resource route with more complex sub-resources
+ # resources :products do
+ # resources :comments
+ # resources :sales do
+ # get 'recent', :on => :collection
+ # end
+ # end
+
+ # Sample resource route within a namespace:
+ # namespace :admin do
+ # # Directs /admin/products/* to Admin::ProductsController
+ # # (app/controllers/admin/products_controller.rb)
+ # resources :products
+ # end
+
+ # You can have the root of your site routed with "root"
+ # just remember to delete public/index.html.
+ # root :to => 'welcome#index'
+
+ # See how all your routes lay out with "rake routes"
+
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
+ # Note: This route will make all actions in every controller accessible via GET requests.
+ # match ':controller(/:action(/:id(.:format)))'
end
View
7 db/seeds.rb
@@ -0,0 +1,7 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
+# Mayor.create(name: 'Emanuel', city: cities.first)
View
0 lib/assets/.gitkeep
No changes.
View
0 lib/tasks/.gitkeep
No changes.
View
0 log/.gitkeep
No changes.
View
34 public/404.html
@@ -1,23 +1,19 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
+<!DOCTYPE html>
+<html>
<head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The page you were looking for doesn't exist (404)</title>
- <style type="text/css">
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
</head>
<body>
@@ -27,4 +23,4 @@
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
-</html>
+</html>
View
34 public/422.html
@@ -1,23 +1,19 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
+<!DOCTYPE html>
+<html>
<head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The change you wanted was rejected (422)</title>
- <style type="text/css">
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
</head>
<body>
@@ -27,4 +23,4 @@
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
-</html>
+</html>
View
34 public/500.html
@@ -1,23 +1,19 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
+<!DOCTYPE html>
+<html>
<head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>We're sorry, but something went wrong (500)</title>
- <style type="text/css">
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
- div.dialog {
- width: 25em;
- padding: 0 4em;
- margin: 4em auto 0 auto;
- border: 1px solid #ccc;
- border-right-color: #999;
- border-bottom-color: #999;
- }
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
- </style>
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+ border: 1px solid #ccc;
+ border-right-color: #999;
+ border-bottom-color: #999;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
</head>
<body>
@@ -27,4 +23,4 @@
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
</div>
</body>
-</html>
+</html>
View
241 public/index.html
@@ -0,0 +1,241 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Ruby on Rails: Welcome aboard</title>
+ <style type="text/css" media="screen">
+ body {
+ margin: 0;
+ margin-bottom: 25px;
+ padding: 0;
+ background-color: #f0f0f0;
+ font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
+ font-size: 13px;
+ color: #333;
+ }
+
+ h1 {
+ font-size: 28px;
+ color: #000;
+ }
+
+ a {color: #03c}
+ a:hover {
+ background-color: #03c;
+ color: white;
+ text-decoration: none;
+ }
+
+
+ #page {
+ background-color: #f0f0f0;
+ width: 750px;
+ margin: 0;
+ margin-left: auto;
+ margin-right: auto;
+ }
+
+ #content {
+ float: left;
+ background-color: white;
+ border: 3px solid #aaa;
+ border-top: none;
+ padding: 25px;
+ width: 500px;
+ }
+
+ #sidebar {
+ float: right;
+ width: 175px;
+ }
+
+ #footer {
+ clear: both;
+ }
+
+ #header, #about, #getting-started {
+ padding-left: 75px;
+ padding-right: 30px;
+ }
+
+
+ #header {
+ background-image: url("/assets/rails.png");
+ background-repeat: no-repeat;
+ background-position: top left;
+ height: 64px;
+ }
+ #header h1, #header h2 {margin: 0}
+ #header h2 {
+ color: #888;
+ font-weight: normal;
+ font-size: 16px;
+ }
+
+
+ #about h3 {
+ margin: 0;
+ margin-bottom: 10px;
+ font-size: 14px;
+ }
+
+ #about-content {
+ background-color: #ffd;
+ border: 1px solid #fc0;
+ margin-left: -55px;
+ margin-right: -10px;
+ }
+ #about-content table {
+ margin-top: 10px;
+ margin-bottom: 10px;
+ font-size: 11px;
+ border-collapse: collapse;
+ }
+ #about-content td {
+ padding: 10px;
+ padding-top: 3px;
+ padding-bottom: 3px;
+ }
+ #about-content td.name {color: #555}
+ #about-content td.value {color: #000}
+
+ #about-content ul {
+ padding: 0;
+ list-style-type: none;
+ }
+
+ #about-content.failure {
+ background-color: #fcc;
+ border: 1px solid #f00;
+ }
+ #about-content.failure p {
+ margin: 0;
+ padding: 10px;
+ }
+
+
+ #getting-started {
+ border-top: 1px solid #ccc;
+ margin-top: 25px;
+ padding-top: 15px;
+ }
+ #getting-started h1 {
+ margin: 0;
+ font-size: 20px;
+ }
+ #getting-started h2 {
+ margin: 0;
+ font-size: 14px;
+ font-weight: normal;
+ color: #333;
+ margin-bottom: 25px;
+ }
+ #getting-started ol {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #getting-started li {
+ font-size: 18px;
+ color: #888;
+ margin-bottom: 25px;
+ }
+ #getting-started li h2 {
+ margin: 0;
+ font-weight: normal;
+ font-size: 18px;
+ color: #333;
+ }
+ #getting-started li p {
+ color: #555;
+ font-size: 13px;
+ }
+
+
+ #sidebar ul {
+ margin-left: 0;
+ padding-left: 0;
+ }
+ #sidebar ul h3 {
+ margin-top: 25px;
+ font-size: 16px;
+ padding-bottom: 10px;
+ border-bottom: 1px solid #ccc;
+ }
+ #sidebar li {
+ list-style-type: none;
+ }
+ #sidebar ul.links li {
+ margin-bottom: 5px;
+ }
+
+ .filename {
+ font-style: italic;
+ }
+ </style>
+ <script type="text/javascript">
+ function about() {
+ info = document.getElementById('about-content');
+ if (window.XMLHttpRequest)
+ { xhr = new XMLHttpRequest(); }
+ else
+ { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
+ xhr.open("GET","rails/info/properties",false);
+ xhr.send("");
+ info.innerHTML = xhr.responseText;
+ info.style.display = 'block'
+ }
+ </script>
+ </head>
+ <body>
+ <div id="page">
+ <div id="sidebar">
+ <ul id="sidebar-items">
+ <li>
+ <h3>Browse the documentation</h3>
+ <ul class="links">
+ <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
+ <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
+ <li><a href="http://www.ruby-doc.org/core/">Ruby core</a></li>
+ <li><a href="http://www.ruby-doc.org/stdlib/">Ruby standard library</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+
+ <div id="content">
+ <div id="header">
+ <h1>Welcome aboard</h1>
+ <h2>You&rsquo;re riding Ruby on Rails!</h2>
+ </div>
+
+ <div id="about">
+ <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
+ <div id="about-content" style="display: none"></div>
+ </div>
+
+ <div id="getting-started">
+ <h1>Getting started</h1>
+ <h2>Here&rsquo;s how to get rolling:</h2>
+
+ <ol>
+ <li>
+ <h2>Use <code>rails generate</code> to create your models and controllers</h2>
+ <p>To see all available options, run it without parameters.</p>
+ </li>
+
+ <li>
+ <h2>Set up a default route and remove <span class="filename">public/index.html</span></h2>
+ <p>Routes are set up in <span class="filename">config/routes.rb</span>.</p>
+ </li>
+
+ <li>
+ <h2>Create your database</h2>
+ <p>Run <code>rake db:create</code> to create your database. If you're not using SQLite (the default), edit <span class="filename">config/database.yml</span> with your username and password.</p>
+ </li>
+ </ol>
+ </div>
+ </div>
+
+ <div id="footer">&nbsp;</div>
+ </div>
+ </body>
+</html>
View
6 script/rails
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+APP_PATH = File.expand_path('../../config/application', __FILE__)
+require File.expand_path('../../config/boot', __FILE__)
+require 'rails/commands'
View
0 test/fixtures/.gitkeep
No changes.
View
0 test/functional/.gitkeep
No changes.
View
0 test/integration/.gitkeep
No changes.
View
12 test/performance/browsing_test.rb
@@ -0,0 +1,12 @@
+require 'test_helper'
+require 'rails/performance_test_help'
+
+class BrowsingTest < ActionDispatch::PerformanceTest
+ # Refer to the documentation for all available options
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
+ # :output => 'tmp/performance', :formats => [:flat] }
+
+ def test_homepage
+ get '/'
+ end
+end
View
31 test/test_helper.rb
@@ -1,33 +1,8 @@
ENV["RAILS_ENV"] = "test"
-require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
-require 'test_help'
-
-class Test::Unit::TestCase
- # Transactional fixtures accelerate your tests by wrapping each test method
- # in a transaction that's rolled back on completion. This ensures that the
- # test database remains unchanged so your fixtures don't have to be reloaded
- # between every test method. Fewer database queries means faster tests.
- #
- # Read Mike Clark's excellent walkthrough at
- # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
- #
- # Every Active Record database supports transactions except MyISAM tables
- # in MySQL. Turn off transactional fixtures in this case; however, if you
- # don't care one way or the other, switching from MyISAM to InnoDB tables
- # is recommended.
- #
- # The only drawback to using transactional fixtures is when you actually
- # need to test transactions. Since your test is bracketed by a transaction,
- # any transactions started in your code will be automatically rolled back.
- self.use_transactional_fixtures = true
-
- # Instantiated fixtures are slow, but give you @david where otherwise you
- # would need people(:david). If you don't want to migrate your existing
- # test cases which use the @david style and don't mind the speed hit (each
- # instantiated fixtures translates to a database query per test method),
- # then set this back to true.
- self.use_instantiated_fixtures = false
+require File.expand_path('../../config/environment', __FILE__)
+require 'rails/test_help'
+class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
View
0 test/unit/.gitkeep
No changes.
View
0 vendor/assets/stylesheets/.gitkeep
No changes.
View
122 vendor/gems/fiveruns_manage-1.0.4/fiveruns_manage.gemspec
@@ -1,122 +0,0 @@
-
-# Gem::Specification for Fiveruns_manage-1.0.4
-# Originally generated by Echoe
-
---- !ruby/object:Gem::Specification
-name: fiveruns_manage
-version: !ruby/object:Gem::Version
- version: 1.0.4
-platform: ruby
-authors:
-- FiveRuns Development Team
-autorequire:
-bindir: bin
-
-date: 2008-09-30 00:00:00 -05:00
-default_executable:
-dependencies:
-- !ruby/object:Gem::Dependency
- name: activesupport
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-description: Instrumentation for the FiveRuns Manage 2.0 product.
-email: dev@fiveruns.com
-executables:
-- fiveruns_manage
-extensions: []
-
-extra_rdoc_files:
-- bin/fiveruns_manage
-- CHANGELOG
-- lib/fiveruns/manage/plugin.rb
-- lib/fiveruns/manage/reporter.rb
-- lib/fiveruns/manage/targets/configuration.rb
-- lib/fiveruns/manage/targets/rails/action_controller/base.rb
-- lib/fiveruns/manage/targets/rails/action_controller/routing_error.rb
-- lib/fiveruns/manage/targets/rails/action_mailer/base.rb
-- lib/fiveruns/manage/targets/rails/action_view/base.rb
-- lib/fiveruns/manage/targets/rails/action_view/partial_template.rb
-- lib/fiveruns/manage/targets/rails/action_view/renderable_partial.rb
-- lib/fiveruns/manage/targets/rails/active_record/active_record_error.rb
-- lib/fiveruns/manage/targets/rails/active_record/base.rb
-- lib/fiveruns/manage/targets/rails/cgi/session.rb
-- lib/fiveruns/manage/targets/rails/mongrel/http_response.rb
-- lib/fiveruns/manage/targets/rails/mongrel/http_server.rb
-- lib/fiveruns/manage/targets/rails.rb
-- lib/fiveruns/manage/targets/target.rb
-- lib/fiveruns/manage/targets.rb
-- lib/fiveruns/manage/version.rb
-- lib/fiveruns/manage.rb
-- lib/fiveruns_manage.rb
-- README.rdoc
-files:
-- bin/fiveruns_manage
-- CHANGELOG
-- init.rb
-- lib/fiveruns/manage/plugin.rb
-- lib/fiveruns/manage/reporter.rb
-- lib/fiveruns/manage/targets/configuration.rb
-- lib/fiveruns/manage/targets/rails/action_controller/base.rb
-- lib/fiveruns/manage/targets/rails/action_controller/routing_error.rb
-- lib/fiveruns/manage/targets/rails/action_mailer/base.rb
-- lib/fiveruns/manage/targets/rails/action_view/base.rb
-- lib/fiveruns/manage/targets/rails/action_view/partial_template.rb
-- lib/fiveruns/manage/targets/rails/action_view/renderable_partial.rb
-- lib/fiveruns/manage/targets/rails/active_record/active_record_error.rb
-- lib/fiveruns/manage/targets/rails/active_record/base.rb
-- lib/fiveruns/manage/targets/rails/cgi/session.rb
-- lib/fiveruns/manage/targets/rails/mongrel/http_response.rb
-- lib/fiveruns/manage/targets/rails/mongrel/http_server.rb
-- lib/fiveruns/manage/targets/rails.rb
-- lib/fiveruns/manage/targets/target.rb
-- lib/fiveruns/manage/targets.rb
-- lib/fiveruns/manage/version.rb
-- lib/fiveruns/manage.rb
-- lib/fiveruns_manage.rb
-- Manifest
-- rails/init.rb
-- Rakefile
-- README.rdoc
-- test/target_test.rb
-- test/targets/rails.rb
-- test/test_helper.rb
-- fiveruns_manage.gemspec
-has_rdoc: true
-homepage: http://github.com/fiveruns/fiveruns_manage
-post_install_message:
-rdoc_options:
-- --line-numbers
-- --inline-source
-- --title
-- Fiveruns_manage
-- --main
-- README.rdoc
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-
-rubyforge_project: fiveruns
-rubygems_version: 1.2.0
-specification_version: 2
-summary: Instrumentation for the FiveRuns Manage 2.0 product.
-test_files:
-- test/target_test.rb
-- test/test_helper.rb
View
180 vendor/gems/fiveruns_manage-1.0.4/lib/fiveruns/manage.rb
@@ -1,180 +0,0 @@
-require 'yaml'
-
-# Explicitly require all files
-$:.unshift(File.dirname(__FILE__) << "/..")
-
-require 'fiveruns/manage'
-require 'fiveruns/manage/version'
-require 'fiveruns/manage/targets'
-require 'fiveruns/manage/plugin'
-require 'fiveruns/manage/reporter'
-
-module Fiveruns
- module Manage
-
- class << self
-
- attr_accessor :context
-
- cattr_accessor :bytes_this_request
- cattr_accessor :current_model
- self.bytes_this_request = 0
-
- def instrument(target, *mods)
- mods.each do |mod|
- # Change target for 'ClassMethods' module
- real_target = mod.name.demodulize == 'ClassMethods' ? (class << target; self; end) : target
- real_target.__send__(:include, mod)
- # Find all the instrumentation hooks and chain them in
- mod.instance_methods.each do |meth|
- name = meth.to_s.sub('_with_fiveruns_manage', '')
- begin
- real_target.alias_method_chain(name, :fiveruns_manage)
- rescue
- Fiveruns::Manage.log :debug, "Could not instrument #{target} (#{meth})", true
- end
- end
- end
- end
-
- def log(level, text, require_debug = false)
- if !require_debug || ENV['FIVERUNS_DEBUG']
- text = "*Shhh* #{text}" if require_debug && ENV['FIVERUNS_DEBUG']
- log_with logger, level, text
- end
- end
-
- def log_with(use_logger, level, text)
- use_logger.send(level, "FiveRuns Manage (#{version_description}): #{text}")
- end
-
- def logger
- if ::Fiveruns::Manage::Targets.current?
- ::Fiveruns::Manage::Plugin.target.logger
- else
- Logger.new(STDERR)
- end
- end
-
- def instrumented_adapters
- @instrumented_adapters ||= []
- end
-
- def version_description
- @version_description ||= defined?(Version::DESCRIPTION) ? Version::DESCRIPTION : "v#{Version::STRING}"
- end
-
- def tracking_model(model_class)
- self.current_model = model_class.name
- block_result = yield model_class.name
- self.current_model = nil
- block_result
- end
-
- def controller_in_context
- context[1]
- end
-
- def action_in_context
- context[3]
- end
-
- def mutex
- @mutex ||= Mutex.new
- end
-
- def sync(&block)
- mutex.synchronize(&block)
- end
-
- def stopwatch
- start = Time.now
- yield
- Time.now - start
- end
-
- def namespace(container, context, properties)
- key = [container, context, properties]
- if (found = cache_map[key])
- namespace = cache[found]
- else
- namespace = Namespace.new(*key)
- cache << namespace
- cache_map[key] = cache.size - 1
- end
-
- # This namespace nil check is here to handle the very
- # rare situation where the reporter thread clears the
- # namespace cache in between this main thread's invocations
- # of cache_map[key] and cache[cache_map[key]]. When
- # this happens, the cache_map is populated and the cache
- # is empty, resulting in a nil namespace. This workaround
- # passes a new, valid Namespace to the caller, but its
- # contents are never added to the cache. The metrics
- # contained therein are lost in the ether. :(
- if namespace.nil?
- namespace = Namespace.new(container, context, properties)
- end
- namespace
- end
-
- def tally(metric, container=nil, context=context, properties=nil)
- metrics_in container, context, properties do |metrics|
- metrics[metric] += 1
- end
- yield if block_given?
- end
-
- def metrics_in(container=nil, context=nil, properties=nil)
- namespace = ::Fiveruns::Manage.namespace(container, context, properties)
- block_given? ? yield(namespace) : namespace
- end
- alias :metrics :metrics_in
-
- def cache_snapshot