cashier 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/..gemspec +21 -0
  2. data/.gitignore +42 -0
  3. data/.infinity_test +19 -0
  4. data/Gemfile +2 -14
  5. data/Gemfile.lock +107 -22
  6. data/Rakefile +1 -37
  7. data/cashier.gemspec +22 -62
  8. data/lib/cashier.rb +47 -46
  9. data/lib/cashier/controller_helper.rb +2 -6
  10. data/lib/cashier/cucumber.rb +6 -0
  11. data/lib/cashier/matchers.rb +39 -0
  12. data/lib/cashier/railtie.rb +8 -0
  13. data/lib/cashier/version.rb +3 -0
  14. data/readme.md +40 -25
  15. data/spec/application_controller_spec.rb +31 -0
  16. data/spec/cashier_spec.rb +84 -2
  17. data/spec/spec_helper.rb +6 -0
  18. data/spec/test_app/.gitignore +4 -0
  19. data/spec/test_app/Gemfile +31 -0
  20. data/spec/test_app/Gemfile.lock +73 -0
  21. data/spec/test_app/README +256 -0
  22. data/spec/test_app/Rakefile +7 -0
  23. data/spec/test_app/app/controllers/application_controller.rb +3 -0
  24. data/spec/test_app/app/controllers/home_controller.rb +7 -0
  25. data/spec/test_app/app/helpers/application_helper.rb +2 -0
  26. data/spec/test_app/app/helpers/home_helper.rb +2 -0
  27. data/spec/test_app/app/views/home/index.html.erb +1 -0
  28. data/spec/test_app/app/views/layouts/application.html.erb +14 -0
  29. data/spec/test_app/config.ru +4 -0
  30. data/spec/test_app/config/application.rb +48 -0
  31. data/spec/test_app/config/boot.rb +10 -0
  32. data/spec/test_app/config/database.yml +22 -0
  33. data/spec/test_app/config/environment.rb +5 -0
  34. data/spec/test_app/config/environments/development.rb +28 -0
  35. data/spec/test_app/config/environments/production.rb +49 -0
  36. data/spec/test_app/config/environments/test.rb +36 -0
  37. data/spec/test_app/config/initializers/backtrace_silencers.rb +7 -0
  38. data/spec/test_app/config/initializers/inflections.rb +10 -0
  39. data/spec/test_app/config/initializers/mime_types.rb +5 -0
  40. data/spec/test_app/config/initializers/secret_token.rb +7 -0
  41. data/spec/test_app/config/initializers/session_store.rb +8 -0
  42. data/spec/test_app/config/locales/en.yml +5 -0
  43. data/spec/test_app/config/routes.rb +60 -0
  44. data/spec/test_app/db/seeds.rb +7 -0
  45. data/spec/test_app/lib/tasks/.gitkeep +0 -0
  46. data/spec/test_app/public/404.html +26 -0
  47. data/spec/test_app/public/422.html +26 -0
  48. data/spec/test_app/public/500.html +26 -0
  49. data/spec/test_app/public/favicon.ico +0 -0
  50. data/spec/test_app/public/images/rails.png +0 -0
  51. data/spec/test_app/public/javascripts/application.js +2 -0
  52. data/spec/test_app/public/javascripts/controls.js +965 -0
  53. data/spec/test_app/public/javascripts/dragdrop.js +974 -0
  54. data/spec/test_app/public/javascripts/effects.js +1123 -0
  55. data/spec/test_app/public/javascripts/prototype.js +6001 -0
  56. data/spec/test_app/public/javascripts/rails.js +191 -0
  57. data/spec/test_app/public/robots.txt +5 -0
  58. data/spec/test_app/public/stylesheets/.gitkeep +0 -0
  59. data/spec/test_app/script/rails +6 -0
  60. data/spec/test_app/test/performance/browsing_test.rb +9 -0
  61. data/spec/test_app/test/test_helper.rb +13 -0
  62. data/spec/test_app/vendor/plugins/.gitkeep +0 -0
  63. metadata +144 -39
  64. data/VERSION +0 -1
@@ -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
+ })();
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'rails/performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionDispatch::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
+ #
8
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
+ # -- they do not yet inherit this setting
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end
File without changes
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Hawkins
@@ -14,11 +14,12 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-05 00:00:00 -08:00
17
+ date: 2011-02-20 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: redis
21
+ name: rails
22
+ prerelease: false
22
23
  requirement: &id001 !ruby/object:Gem::Requirement
23
24
  none: false
24
25
  requirements:
@@ -27,11 +28,11 @@ dependencies:
27
28
  segments:
28
29
  - 0
29
30
  version: "0"
30
- type: :runtime
31
- prerelease: false
31
+ type: :development
32
32
  version_requirements: *id001
33
33
  - !ruby/object:Gem::Dependency
34
- name: redis-namespace
34
+ name: rspec
35
+ prerelease: false
35
36
  requirement: &id002 !ruby/object:Gem::Requirement
36
37
  none: false
37
38
  requirements:
@@ -40,56 +41,50 @@ dependencies:
40
41
  segments:
41
42
  - 0
42
43
  version: "0"
43
- type: :runtime
44
- prerelease: false
44
+ type: :development
45
45
  version_requirements: *id002
46
46
  - !ruby/object:Gem::Dependency
47
- name: rspec
47
+ name: rspec-rails
48
+ prerelease: false
48
49
  requirement: &id003 !ruby/object:Gem::Requirement
49
50
  none: false
50
51
  requirements:
51
- - - ~>
52
+ - - ">="
52
53
  - !ruby/object:Gem::Version
53
54
  segments:
54
- - 2
55
- - 3
56
55
  - 0
57
- version: 2.3.0
56
+ version: "0"
58
57
  type: :development
59
- prerelease: false
60
58
  version_requirements: *id003
61
59
  - !ruby/object:Gem::Dependency
62
- name: bundler
60
+ name: infinity_test
61
+ prerelease: false
63
62
  requirement: &id004 !ruby/object:Gem::Requirement
64
63
  none: false
65
64
  requirements:
66
- - - ~>
65
+ - - ">="
67
66
  - !ruby/object:Gem::Version
68
67
  segments:
69
- - 1
70
- - 0
71
68
  - 0
72
- version: 1.0.0
69
+ version: "0"
73
70
  type: :development
74
- prerelease: false
75
71
  version_requirements: *id004
76
72
  - !ruby/object:Gem::Dependency
77
- name: jeweler
73
+ name: memcache-client
74
+ prerelease: false
78
75
  requirement: &id005 !ruby/object:Gem::Requirement
79
76
  none: false
80
77
  requirements:
81
- - - ~>
78
+ - - ">="
82
79
  - !ruby/object:Gem::Version
83
80
  segments:
84
- - 1
85
- - 5
86
- - 2
87
- version: 1.5.2
81
+ - 0
82
+ version: "0"
88
83
  type: :development
89
- prerelease: false
90
84
  version_requirements: *id005
91
85
  - !ruby/object:Gem::Dependency
92
- name: rcov
86
+ name: ruby-debug19
87
+ prerelease: false
93
88
  requirement: &id006 !ruby/object:Gem::Requirement
94
89
  none: false
95
90
  requirements:
@@ -99,33 +94,98 @@ dependencies:
99
94
  - 0
100
95
  version: "0"
101
96
  type: :development
102
- prerelease: false
103
97
  version_requirements: *id006
98
+ - !ruby/object:Gem::Dependency
99
+ name: sqlite3
100
+ prerelease: false
101
+ requirement: &id007 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ type: :development
110
+ version_requirements: *id007
104
111
  description: Associate different cached content with a tag, then expire by tag instead of key
105
- email: Adman1965@gmail.com
112
+ email:
113
+ - adman1965@gmail.com
106
114
  executables: []
107
115
 
108
116
  extensions: []
109
117
 
110
- extra_rdoc_files:
111
- - LICENSE.txt
118
+ extra_rdoc_files: []
119
+
112
120
  files:
121
+ - ..gemspec
122
+ - .gitignore
123
+ - .infinity_test
113
124
  - .rvmrc
114
125
  - Gemfile
115
126
  - Gemfile.lock
116
127
  - LICENSE.txt
117
128
  - Rakefile
118
- - VERSION
119
129
  - cashier.gemspec
120
130
  - lib/cashier.rb
121
131
  - lib/cashier/controller_helper.rb
132
+ - lib/cashier/cucumber.rb
133
+ - lib/cashier/matchers.rb
134
+ - lib/cashier/railtie.rb
135
+ - lib/cashier/version.rb
122
136
  - readme.md
137
+ - spec/application_controller_spec.rb
123
138
  - spec/cashier_spec.rb
124
139
  - spec/spec_helper.rb
140
+ - spec/test_app/.gitignore
141
+ - spec/test_app/Gemfile
142
+ - spec/test_app/Gemfile.lock
143
+ - spec/test_app/README
144
+ - spec/test_app/Rakefile
145
+ - spec/test_app/app/controllers/application_controller.rb
146
+ - spec/test_app/app/controllers/home_controller.rb
147
+ - spec/test_app/app/helpers/application_helper.rb
148
+ - spec/test_app/app/helpers/home_helper.rb
149
+ - spec/test_app/app/views/home/index.html.erb
150
+ - spec/test_app/app/views/layouts/application.html.erb
151
+ - spec/test_app/config.ru
152
+ - spec/test_app/config/application.rb
153
+ - spec/test_app/config/boot.rb
154
+ - spec/test_app/config/database.yml
155
+ - spec/test_app/config/environment.rb
156
+ - spec/test_app/config/environments/development.rb
157
+ - spec/test_app/config/environments/production.rb
158
+ - spec/test_app/config/environments/test.rb
159
+ - spec/test_app/config/initializers/backtrace_silencers.rb
160
+ - spec/test_app/config/initializers/inflections.rb
161
+ - spec/test_app/config/initializers/mime_types.rb
162
+ - spec/test_app/config/initializers/secret_token.rb
163
+ - spec/test_app/config/initializers/session_store.rb
164
+ - spec/test_app/config/locales/en.yml
165
+ - spec/test_app/config/routes.rb
166
+ - spec/test_app/db/seeds.rb
167
+ - spec/test_app/lib/tasks/.gitkeep
168
+ - spec/test_app/public/404.html
169
+ - spec/test_app/public/422.html
170
+ - spec/test_app/public/500.html
171
+ - spec/test_app/public/favicon.ico
172
+ - spec/test_app/public/images/rails.png
173
+ - spec/test_app/public/javascripts/application.js
174
+ - spec/test_app/public/javascripts/controls.js
175
+ - spec/test_app/public/javascripts/dragdrop.js
176
+ - spec/test_app/public/javascripts/effects.js
177
+ - spec/test_app/public/javascripts/prototype.js
178
+ - spec/test_app/public/javascripts/rails.js
179
+ - spec/test_app/public/robots.txt
180
+ - spec/test_app/public/stylesheets/.gitkeep
181
+ - spec/test_app/script/rails
182
+ - spec/test_app/test/performance/browsing_test.rb
183
+ - spec/test_app/test/test_helper.rb
184
+ - spec/test_app/vendor/plugins/.gitkeep
125
185
  has_rdoc: true
126
- homepage: http://github.com/Adman65/cashier
127
- licenses:
128
- - MIT
186
+ homepage: https://github.com/Adman65/cashier
187
+ licenses: []
188
+
129
189
  post_install_message:
130
190
  rdoc_options: []
131
191
 
@@ -136,7 +196,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
196
  requirements:
137
197
  - - ">="
138
198
  - !ruby/object:Gem::Version
139
- hash: -1411570206960376896
140
199
  segments:
141
200
  - 0
142
201
  version: "0"
@@ -150,11 +209,57 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
209
  version: "0"
151
210
  requirements: []
152
211
 
153
- rubyforge_project:
212
+ rubyforge_project: cashier
154
213
  rubygems_version: 1.3.7
155
214
  signing_key:
156
215
  specification_version: 3
157
216
  summary: Tag based caching for Rails
158
217
  test_files:
218
+ - spec/application_controller_spec.rb
159
219
  - spec/cashier_spec.rb
160
220
  - spec/spec_helper.rb
221
+ - spec/test_app/.gitignore
222
+ - spec/test_app/Gemfile
223
+ - spec/test_app/Gemfile.lock
224
+ - spec/test_app/README
225
+ - spec/test_app/Rakefile
226
+ - spec/test_app/app/controllers/application_controller.rb
227
+ - spec/test_app/app/controllers/home_controller.rb
228
+ - spec/test_app/app/helpers/application_helper.rb
229
+ - spec/test_app/app/helpers/home_helper.rb
230
+ - spec/test_app/app/views/home/index.html.erb
231
+ - spec/test_app/app/views/layouts/application.html.erb
232
+ - spec/test_app/config.ru
233
+ - spec/test_app/config/application.rb
234
+ - spec/test_app/config/boot.rb
235
+ - spec/test_app/config/database.yml
236
+ - spec/test_app/config/environment.rb
237
+ - spec/test_app/config/environments/development.rb
238
+ - spec/test_app/config/environments/production.rb
239
+ - spec/test_app/config/environments/test.rb
240
+ - spec/test_app/config/initializers/backtrace_silencers.rb
241
+ - spec/test_app/config/initializers/inflections.rb
242
+ - spec/test_app/config/initializers/mime_types.rb
243
+ - spec/test_app/config/initializers/secret_token.rb
244
+ - spec/test_app/config/initializers/session_store.rb
245
+ - spec/test_app/config/locales/en.yml
246
+ - spec/test_app/config/routes.rb
247
+ - spec/test_app/db/seeds.rb
248
+ - spec/test_app/lib/tasks/.gitkeep
249
+ - spec/test_app/public/404.html
250
+ - spec/test_app/public/422.html
251
+ - spec/test_app/public/500.html
252
+ - spec/test_app/public/favicon.ico
253
+ - spec/test_app/public/images/rails.png
254
+ - spec/test_app/public/javascripts/application.js
255
+ - spec/test_app/public/javascripts/controls.js
256
+ - spec/test_app/public/javascripts/dragdrop.js
257
+ - spec/test_app/public/javascripts/effects.js
258
+ - spec/test_app/public/javascripts/prototype.js
259
+ - spec/test_app/public/javascripts/rails.js
260
+ - spec/test_app/public/robots.txt
261
+ - spec/test_app/public/stylesheets/.gitkeep
262
+ - spec/test_app/script/rails
263
+ - spec/test_app/test/performance/browsing_test.rb
264
+ - spec/test_app/test/test_helper.rb
265
+ - spec/test_app/vendor/plugins/.gitkeep