steak 2.0.0.beta2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/README.md +2 -2
  2. data/lib/steak/version.rb +1 -1
  3. data/spec/fixtures/rails_project/.gitignore +0 -1
  4. data/spec/fixtures/rails_project/Gemfile +17 -14
  5. data/spec/fixtures/rails_project/README +7 -12
  6. data/spec/fixtures/rails_project/Rakefile +1 -1
  7. data/spec/fixtures/rails_project/app/views/layouts/application.html.erb +3 -3
  8. data/spec/fixtures/rails_project/config/application.rb +3 -3
  9. data/spec/fixtures/rails_project/config/database.yml +0 -3
  10. data/spec/fixtures/rails_project/config/environments/development.rb +3 -4
  11. data/spec/fixtures/rails_project/config/environments/production.rb +12 -17
  12. data/spec/fixtures/rails_project/config/environments/test.rb +1 -5
  13. data/spec/fixtures/rails_project/config/initializers/secret_token.rb +1 -1
  14. data/spec/fixtures/rails_project/config/locales/en.yml +1 -1
  15. data/spec/fixtures/rails_project/config/routes.rb +1 -1
  16. data/spec/fixtures/rails_project/db/seeds.rb +1 -1
  17. data/spec/fixtures/rails_project/{app/assets → public}/images/rails.png +0 -0
  18. data/spec/fixtures/rails_project/public/index.html +8 -10
  19. data/spec/fixtures/rails_project/public/javascripts/application.js +2 -0
  20. data/spec/fixtures/rails_project/public/javascripts/controls.js +965 -0
  21. data/spec/fixtures/rails_project/public/javascripts/dragdrop.js +974 -0
  22. data/spec/fixtures/rails_project/public/javascripts/effects.js +1123 -0
  23. data/spec/fixtures/rails_project/public/javascripts/prototype.js +6001 -0
  24. data/spec/fixtures/rails_project/public/javascripts/rails.js +191 -0
  25. data/spec/fixtures/rails_project/{app/mailers → public/stylesheets}/.gitkeep +0 -0
  26. data/spec/fixtures/rails_project/test/performance/browsing_test.rb +1 -4
  27. data/spec/fixtures/rails_project_with_steak/.gitignore +0 -1
  28. data/spec/fixtures/rails_project_with_steak/Gemfile +17 -14
  29. data/spec/fixtures/rails_project_with_steak/README +7 -12
  30. data/spec/fixtures/rails_project_with_steak/Rakefile +1 -1
  31. data/spec/fixtures/rails_project_with_steak/app/views/layouts/application.html.erb +3 -3
  32. data/spec/fixtures/rails_project_with_steak/config/application.rb +3 -3
  33. data/spec/fixtures/rails_project_with_steak/config/database.yml +0 -3
  34. data/spec/fixtures/rails_project_with_steak/config/environments/development.rb +3 -4
  35. data/spec/fixtures/rails_project_with_steak/config/environments/production.rb +12 -17
  36. data/spec/fixtures/rails_project_with_steak/config/environments/test.rb +1 -5
  37. data/spec/fixtures/rails_project_with_steak/config/initializers/secret_token.rb +1 -1
  38. data/spec/fixtures/rails_project_with_steak/config/locales/en.yml +1 -1
  39. data/spec/fixtures/rails_project_with_steak/config/routes.rb +1 -1
  40. data/spec/fixtures/rails_project_with_steak/db/seeds.rb +1 -1
  41. data/spec/fixtures/rails_project_with_steak/{app/assets → public}/images/rails.png +0 -0
  42. data/spec/fixtures/rails_project_with_steak/public/index.html +8 -10
  43. data/spec/fixtures/rails_project_with_steak/public/javascripts/application.js +2 -0
  44. data/spec/fixtures/rails_project_with_steak/public/javascripts/controls.js +965 -0
  45. data/spec/fixtures/rails_project_with_steak/public/javascripts/dragdrop.js +974 -0
  46. data/spec/fixtures/rails_project_with_steak/public/javascripts/effects.js +1123 -0
  47. data/spec/fixtures/rails_project_with_steak/public/javascripts/prototype.js +6001 -0
  48. data/spec/fixtures/rails_project_with_steak/public/javascripts/rails.js +191 -0
  49. data/spec/fixtures/{rails_project/app/models → rails_project_with_steak/public/stylesheets}/.gitkeep +0 -0
  50. data/spec/fixtures/rails_project_with_steak/test/performance/browsing_test.rb +1 -4
  51. metadata +42 -64
  52. data/spec/fixtures/rails_project/app/assets/javascripts/application.js +0 -9
  53. data/spec/fixtures/rails_project/app/assets/stylesheets/application.css +0 -7
  54. data/spec/fixtures/rails_project/config/initializers/wrap_parameters.rb +0 -12
  55. data/spec/fixtures/rails_project/log/.gitkeep +0 -0
  56. data/spec/fixtures/rails_project/test/fixtures/.gitkeep +0 -0
  57. data/spec/fixtures/rails_project/test/functional/.gitkeep +0 -0
  58. data/spec/fixtures/rails_project/test/integration/.gitkeep +0 -0
  59. data/spec/fixtures/rails_project/test/unit/.gitkeep +0 -0
  60. data/spec/fixtures/rails_project/vendor/assets/stylesheets/.gitkeep +0 -0
  61. data/spec/fixtures/rails_project_with_steak/app/assets/javascripts/application.js +0 -9
  62. data/spec/fixtures/rails_project_with_steak/app/assets/stylesheets/application.css +0 -7
  63. data/spec/fixtures/rails_project_with_steak/app/mailers/.gitkeep +0 -0
  64. data/spec/fixtures/rails_project_with_steak/app/models/.gitkeep +0 -0
  65. data/spec/fixtures/rails_project_with_steak/config/initializers/wrap_parameters.rb +0 -12
  66. data/spec/fixtures/rails_project_with_steak/log/.gitkeep +0 -0
  67. data/spec/fixtures/rails_project_with_steak/test/fixtures/.gitkeep +0 -0
  68. data/spec/fixtures/rails_project_with_steak/test/functional/.gitkeep +0 -0
  69. data/spec/fixtures/rails_project_with_steak/test/integration/.gitkeep +0 -0
  70. data/spec/fixtures/rails_project_with_steak/test/unit/.gitkeep +0 -0
  71. data/spec/fixtures/rails_project_with_steak/vendor/assets/stylesheets/.gitkeep +0 -0
@@ -0,0 +1,191 @@
1
+ (function() {
2
+ // Technique from Juriy Zaytsev
3
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
4
+ function isEventSupported(eventName) {
5
+ var el = document.createElement('div');
6
+ eventName = 'on' + eventName;
7
+ var isSupported = (eventName in el);
8
+ if (!isSupported) {
9
+ el.setAttribute(eventName, 'return;');
10
+ isSupported = typeof el[eventName] == 'function';
11
+ }
12
+ el = null;
13
+ return isSupported;
14
+ }
15
+
16
+ function isForm(element) {
17
+ return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
18
+ }
19
+
20
+ function isInput(element) {
21
+ if (Object.isElement(element)) {
22
+ var name = element.nodeName.toUpperCase()
23
+ return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
24
+ }
25
+ else return false
26
+ }
27
+
28
+ var submitBubbles = isEventSupported('submit'),
29
+ changeBubbles = isEventSupported('change')
30
+
31
+ if (!submitBubbles || !changeBubbles) {
32
+ // augment the Event.Handler class to observe custom events when needed
33
+ Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
34
+ function(init, element, eventName, selector, callback) {
35
+ init(element, eventName, selector, callback)
36
+ // is the handler being attached to an element that doesn't support this event?
37
+ if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
38
+ (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
39
+ // "submit" => "emulated:submit"
40
+ this.eventName = 'emulated:' + this.eventName
41
+ }
42
+ }
43
+ )
44
+ }
45
+
46
+ if (!submitBubbles) {
47
+ // discover forms on the page by observing focus events which always bubble
48
+ document.on('focusin', 'form', function(focusEvent, form) {
49
+ // special handler for the real "submit" event (one-time operation)
50
+ if (!form.retrieve('emulated:submit')) {
51
+ form.on('submit', function(submitEvent) {
52
+ var emulated = form.fire('emulated:submit', submitEvent, true)
53
+ // if custom event received preventDefault, cancel the real one too
54
+ if (emulated.returnValue === false) submitEvent.preventDefault()
55
+ })
56
+ form.store('emulated:submit', true)
57
+ }
58
+ })
59
+ }
60
+
61
+ if (!changeBubbles) {
62
+ // discover form inputs on the page
63
+ document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
64
+ // special handler for real "change" events
65
+ if (!input.retrieve('emulated:change')) {
66
+ input.on('change', function(changeEvent) {
67
+ input.fire('emulated:change', changeEvent, true)
68
+ })
69
+ input.store('emulated:change', true)
70
+ }
71
+ })
72
+ }
73
+
74
+ function handleRemote(element) {
75
+ var method, url, params;
76
+
77
+ var event = element.fire("ajax:before");
78
+ if (event.stopped) return false;
79
+
80
+ if (element.tagName.toLowerCase() === 'form') {
81
+ method = element.readAttribute('method') || 'post';
82
+ url = element.readAttribute('action');
83
+ params = element.serialize();
84
+ } else {
85
+ method = element.readAttribute('data-method') || 'get';
86
+ url = element.readAttribute('href');
87
+ params = {};
88
+ }
89
+
90
+ new Ajax.Request(url, {
91
+ method: method,
92
+ parameters: params,
93
+ evalScripts: true,
94
+
95
+ onComplete: function(request) { element.fire("ajax:complete", request); },
96
+ onSuccess: function(request) { element.fire("ajax:success", request); },
97
+ onFailure: function(request) { element.fire("ajax:failure", request); }
98
+ });
99
+
100
+ element.fire("ajax:after");
101
+ }
102
+
103
+ function handleMethod(element) {
104
+ var method = element.readAttribute('data-method'),
105
+ url = element.readAttribute('href'),
106
+ csrf_param = $$('meta[name=csrf-param]')[0],
107
+ csrf_token = $$('meta[name=csrf-token]')[0];
108
+
109
+ var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
110
+ element.parentNode.insert(form);
111
+
112
+ if (method !== 'post') {
113
+ var field = new Element('input', { type: 'hidden', name: '_method', value: method });
114
+ form.insert(field);
115
+ }
116
+
117
+ if (csrf_param) {
118
+ var param = csrf_param.readAttribute('content'),
119
+ token = csrf_token.readAttribute('content'),
120
+ field = new Element('input', { type: 'hidden', name: param, value: token });
121
+ form.insert(field);
122
+ }
123
+
124
+ form.submit();
125
+ }
126
+
127
+
128
+ document.on("click", "*[data-confirm]", function(event, element) {
129
+ var message = element.readAttribute('data-confirm');
130
+ if (!confirm(message)) event.stop();
131
+ });
132
+
133
+ document.on("click", "a[data-remote]", function(event, element) {
134
+ if (event.stopped) return;
135
+ handleRemote(element);
136
+ event.stop();
137
+ });
138
+
139
+ document.on("click", "a[data-method]", function(event, element) {
140
+ if (event.stopped) return;
141
+ handleMethod(element);
142
+ event.stop();
143
+ });
144
+
145
+ document.on("submit", function(event) {
146
+ var element = event.findElement(),
147
+ message = element.readAttribute('data-confirm');
148
+ if (message && !confirm(message)) {
149
+ event.stop();
150
+ return false;
151
+ }
152
+
153
+ var inputs = element.select("input[type=submit][data-disable-with]");
154
+ inputs.each(function(input) {
155
+ input.disabled = true;
156
+ input.writeAttribute('data-original-value', input.value);
157
+ input.value = input.readAttribute('data-disable-with');
158
+ });
159
+
160
+ var element = event.findElement("form[data-remote]");
161
+ if (element) {
162
+ handleRemote(element);
163
+ event.stop();
164
+ }
165
+ });
166
+
167
+ document.on("ajax:after", "form", function(event, element) {
168
+ var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
169
+ inputs.each(function(input) {
170
+ input.value = input.readAttribute('data-original-value');
171
+ input.removeAttribute('data-original-value');
172
+ input.disabled = false;
173
+ });
174
+ });
175
+
176
+ Ajax.Responders.register({
177
+ onCreate: function(request) {
178
+ var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
179
+
180
+ if (csrf_meta_tag) {
181
+ var header = 'X-CSRF-Token',
182
+ token = csrf_meta_tag.readAttribute('content');
183
+
184
+ if (!request.options.requestHeaders) {
185
+ request.options.requestHeaders = {};
186
+ }
187
+ request.options.requestHeaders[header] = token;
188
+ }
189
+ }
190
+ });
191
+ })();
@@ -1,11 +1,8 @@
1
1
  require 'test_helper'
2
2
  require 'rails/performance_test_help'
3
3
 
4
+ # Profiling results for each test method are written to tmp/performance.
4
5
  class BrowsingTest < ActionDispatch::PerformanceTest
5
- # Refer to the documentation for all available options
6
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
7
- # :output => 'tmp/performance', :formats => [:flat] }
8
-
9
6
  def test_homepage
10
7
  get '/'
11
8
  end
@@ -2,4 +2,3 @@
2
2
  db/*.sqlite3
3
3
  log/*.log
4
4
  tmp/
5
- .sass-cache/
@@ -1,17 +1,15 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rails', '3.1.0.rc4'
3
+ gem 'rails', '3.0.8'
4
4
 
5
5
  # Bundle edge Rails instead:
6
- # gem 'rails', :git => 'git://github.com/rails/rails.git'
6
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
7
 
8
8
  platforms :ruby do
9
9
  gem 'sqlite3'
10
10
  end
11
11
 
12
12
  platforms :jruby do
13
- # the javascript engine for execjs gem
14
- gem 'therubyrhino'
15
13
 
16
14
  gem 'activerecord-jdbc-adapter'
17
15
 
@@ -39,23 +37,28 @@ platforms :jruby do
39
37
  end
40
38
 
41
39
 
42
- # Asset template engines
43
- gem 'json'
44
- gem 'sass-rails', "~> 3.1.0.rc"
45
- gem 'coffee-script'
46
- gem 'uglifier'
47
-
48
- gem 'jquery-rails'
49
-
50
40
  # Use unicorn as the web server
51
41
  # gem 'unicorn'
52
42
 
53
43
  # Deploy with Capistrano
54
44
  # gem 'capistrano'
55
45
 
56
- # To use debugger
46
+ # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
57
47
  # gem 'ruby-debug'
58
-
48
+ # gem 'ruby-debug19', :require => 'ruby-debug'
49
+
50
+ # Bundle the extra gems:
51
+ # gem 'bj'
52
+ # gem 'nokogiri'
53
+ # gem 'sqlite3-ruby', :require => 'sqlite3'
54
+ # gem 'aws-s3', :require => 'aws/s3'
55
+
56
+ # Bundle gems for the local environment. Make sure to
57
+ # put test-only gems in this group so their generators
58
+ # and rake tasks are available in development mode:
59
+ # group :development, :test do
60
+ # gem 'webrat'
61
+ # end
59
62
  group :test, :development do
60
63
  gem 'steak', :path => '/Users/luismi/p/steak'
61
64
  end
@@ -91,7 +91,7 @@ mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
91
91
 
92
92
  class WeblogController < ActionController::Base
93
93
  def index
94
- @posts = Post.all
94
+ @posts = Post.find(:all)
95
95
  debugger
96
96
  end
97
97
  end
@@ -139,7 +139,7 @@ To reload your controllers and models after launching the console run
139
139
  <tt>reload!</tt>
140
140
 
141
141
  More information about irb can be found at:
142
- link:http://www.rubycentral.org/pickaxe/irb.html
142
+ link:http://www.rubycentral.com/pickaxe/irb.html
143
143
 
144
144
 
145
145
  == dbconsole
@@ -156,10 +156,6 @@ PostgreSQL and SQLite 3.
156
156
  The default directory structure of a generated Ruby on Rails application:
157
157
 
158
158
  |-- app
159
- | |-- assets
160
- | |-- images
161
- | |-- javascripts
162
- | `-- stylesheets
163
159
  | |-- controllers
164
160
  | |-- helpers
165
161
  | |-- mailers
@@ -176,6 +172,9 @@ The default directory structure of a generated Ruby on Rails application:
176
172
  | `-- tasks
177
173
  |-- log
178
174
  |-- public
175
+ | |-- images
176
+ | |-- javascripts
177
+ | `-- stylesheets
179
178
  |-- script
180
179
  |-- test
181
180
  | |-- fixtures
@@ -189,16 +188,11 @@ The default directory structure of a generated Ruby on Rails application:
189
188
  | |-- sessions
190
189
  | `-- sockets
191
190
  `-- vendor
192
- |-- assets
193
- `-- stylesheets
194
191
  `-- plugins
195
192
 
196
193
  app
197
194
  Holds all the code that's specific to this particular application.
198
195
 
199
- app/assets
200
- Contains subdirectories for images, stylesheets, and JavaScript files.
201
-
202
196
  app/controllers
203
197
  Holds controllers that should be named like weblogs_controller.rb for
204
198
  automated URL mapping. All controllers should descend from
@@ -243,7 +237,8 @@ lib
243
237
  the load path.
244
238
 
245
239
  public
246
- The directory available for the web server. Also contains the dispatchers and the
240
+ The directory available for the web server. Contains subdirectories for
241
+ images, stylesheets, and javascripts. Also contains the dispatchers and the
247
242
  default HTML files. This should be set as the DOCUMENT_ROOT of your web
248
243
  server.
249
244
 
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env rake
2
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
3
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
3
 
5
4
  require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
6
 
7
7
  RailsProject::Application.load_tasks
@@ -2,9 +2,9 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>RailsProject</title>
5
- <%= stylesheet_link_tag "application" %>
6
- <%= javascript_include_tag "application" %>
7
- <%= csrf_meta_tags %>
5
+ <%= stylesheet_link_tag :all %>
6
+ <%= javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
8
  </head>
9
9
  <body>
10
10
 
@@ -30,13 +30,13 @@ module RailsProject
30
30
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
31
  # config.i18n.default_locale = :de
32
32
 
33
+ # JavaScript files you want as :defaults (application.js is always included).
34
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35
+
33
36
  # Configure the default encoding used in templates for Ruby 1.9.
34
37
  config.encoding = "utf-8"
35
38
 
36
39
  # Configure sensitive parameters which will be filtered from the log file.
37
40
  config.filter_parameters += [:password]
38
-
39
- # Enable the asset pipeline
40
- config.assets.enabled = true
41
41
  end
42
42
  end
@@ -23,9 +23,6 @@
23
23
 
24
24
  # SQLite version 3.x
25
25
  # gem install sqlite3
26
- #
27
- # Ensure the SQLite 3 gem is defined in your Gemfile
28
- # gem 'sqlite3'
29
26
  development:
30
27
  adapter: sqlite3
31
28
  database: db/development.sqlite3
@@ -3,7 +3,7 @@ RailsProject::Application.configure do
3
3
 
4
4
  # In the development environment your application's code is reloaded on
5
5
  # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
6
+ # since you don't have to restart the webserver when you make code changes.
7
7
  config.cache_classes = false
8
8
 
9
9
  # Log error messages when you accidentally call methods on nil.
@@ -11,6 +11,7 @@ RailsProject::Application.configure do
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
14
15
  config.action_controller.perform_caching = false
15
16
 
16
17
  # Don't care if the mailer can't send
@@ -21,7 +22,5 @@ RailsProject::Application.configure do
21
22
 
22
23
  # Only use best-standards-support built into browsers
23
24
  config.action_dispatch.best_standards_support = :builtin
24
-
25
- # Do not compress assets
26
- config.assets.compress = false
27
25
  end
26
+
@@ -1,6 +1,7 @@
1
1
  RailsProject::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/application.rb
3
3
 
4
+ # The production environment is meant for finished, "live" apps.
4
5
  # Code is not reloaded between requests
5
6
  config.cache_classes = true
6
7
 
@@ -8,21 +9,14 @@ RailsProject::Application.configure do
8
9
  config.consider_all_requests_local = false
9
10
  config.action_controller.perform_caching = true
10
11
 
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
13
-
14
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
16
-
17
- # Specify the default JavaScript compressor
18
- config.assets.js_compressor = :uglifier
19
-
20
12
  # Specifies the header that your server uses for sending files
21
- # (comment out if your front-end server doesn't support this)
22
- config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
23
14
 
24
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
25
- # config.force_ssl = true
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
26
20
 
27
21
  # See everything in the log (default is :info)
28
22
  # config.log_level = :debug
@@ -33,11 +27,12 @@ RailsProject::Application.configure do
33
27
  # Use a different cache store in production
34
28
  # config.cache_store = :mem_cache_store
35
29
 
36
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
37
- # config.action_controller.asset_host = "http://assets.example.com"
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
38
33
 
39
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
40
- # config.assets.precompile += %w( search.js )
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
41
36
 
42
37
  # Disable delivery errors, bad email addresses will be ignored
43
38
  # config.action_mailer.raise_delivery_errors = false