flagpole_sitta 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +38 -0
- data/README.rdoc +121 -0
- data/Rakefile +29 -0
- data/app/helpers/flagpole_sitta_helper.rb +169 -0
- data/flagpole_sitta.gemspec +23 -0
- data/lib/flagpole_sitta/bracket_retrieval.rb +83 -0
- data/lib/flagpole_sitta/cache_sitta.rb +198 -0
- data/lib/flagpole_sitta/config_sitta.rb +35 -0
- data/lib/flagpole_sitta/engine.rb +12 -0
- data/lib/flagpole_sitta/existance_hash.rb +164 -0
- data/lib/flagpole_sitta/version.rb +3 -0
- data/lib/flagpole_sitta.rb +20 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +22 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +26 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/javascripts/application.js +2 -0
- data/test/dummy/public/javascripts/controls.js +965 -0
- data/test/dummy/public/javascripts/dragdrop.js +974 -0
- data/test/dummy/public/javascripts/effects.js +1123 -0
- data/test/dummy/public/javascripts/prototype.js +6001 -0
- data/test/dummy/public/javascripts/rails.js +202 -0
- data/test/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/flagpole_sitta_test.rb +7 -0
- data/test/integration/navigation_test.rb +7 -0
- data/test/support/integration_case.rb +5 -0
- data/test/test_helper.rb +22 -0
- metadata +116 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
Ajax.Responders.register({
|
|
3
|
+
onCreate: function(request) {
|
|
4
|
+
var token = $$('meta[name=csrf-token]')[0];
|
|
5
|
+
if (token) {
|
|
6
|
+
if (!request.options.requestHeaders) request.options.requestHeaders = {};
|
|
7
|
+
request.options.requestHeaders['X-CSRF-Token'] = token.readAttribute('content');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Technique from Juriy Zaytsev
|
|
13
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
|
14
|
+
function isEventSupported(eventName) {
|
|
15
|
+
var el = document.createElement('div');
|
|
16
|
+
eventName = 'on' + eventName;
|
|
17
|
+
var isSupported = (eventName in el);
|
|
18
|
+
if (!isSupported) {
|
|
19
|
+
el.setAttribute(eventName, 'return;');
|
|
20
|
+
isSupported = typeof el[eventName] == 'function';
|
|
21
|
+
}
|
|
22
|
+
el = null;
|
|
23
|
+
return isSupported;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isForm(element) {
|
|
27
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isInput(element) {
|
|
31
|
+
if (Object.isElement(element)) {
|
|
32
|
+
var name = element.nodeName.toUpperCase();
|
|
33
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA';
|
|
34
|
+
}
|
|
35
|
+
else return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var submitBubbles = isEventSupported('submit'),
|
|
39
|
+
changeBubbles = isEventSupported('change');
|
|
40
|
+
|
|
41
|
+
if (!submitBubbles || !changeBubbles) {
|
|
42
|
+
// augment the Event.Handler class to observe custom events when needed
|
|
43
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
|
44
|
+
function(init, element, eventName, selector, callback) {
|
|
45
|
+
init(element, eventName, selector, callback);
|
|
46
|
+
// is the handler being attached to an element that doesn't support this event?
|
|
47
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
|
48
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
|
49
|
+
// "submit" => "emulated:submit"
|
|
50
|
+
this.eventName = 'emulated:' + this.eventName;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!submitBubbles) {
|
|
57
|
+
// discover forms on the page by observing focus events which always bubble
|
|
58
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
|
59
|
+
// special handler for the real "submit" event (one-time operation)
|
|
60
|
+
if (!form.retrieve('emulated:submit')) {
|
|
61
|
+
form.on('submit', function(submitEvent) {
|
|
62
|
+
var emulated = form.fire('emulated:submit', submitEvent, true);
|
|
63
|
+
// if custom event received preventDefault, cancel the real one too
|
|
64
|
+
if (emulated.returnValue === false) submitEvent.preventDefault();
|
|
65
|
+
});
|
|
66
|
+
form.store('emulated:submit', true);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!changeBubbles) {
|
|
72
|
+
// discover form inputs on the page
|
|
73
|
+
document.on('focusin', 'input, select, textarea', function(focusEvent, input) {
|
|
74
|
+
// special handler for real "change" events
|
|
75
|
+
if (!input.retrieve('emulated:change')) {
|
|
76
|
+
input.on('change', function(changeEvent) {
|
|
77
|
+
input.fire('emulated:change', changeEvent, true);
|
|
78
|
+
});
|
|
79
|
+
input.store('emulated:change', true);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function handleRemote(element) {
|
|
85
|
+
var method, url, params;
|
|
86
|
+
|
|
87
|
+
var event = element.fire("ajax:before");
|
|
88
|
+
if (event.stopped) return false;
|
|
89
|
+
|
|
90
|
+
if (element.tagName.toLowerCase() === 'form') {
|
|
91
|
+
method = element.readAttribute('method') || 'post';
|
|
92
|
+
url = element.readAttribute('action');
|
|
93
|
+
// serialize the form with respect to the submit button that was pressed
|
|
94
|
+
params = element.serialize({ submit: element.retrieve('rails:submit-button') });
|
|
95
|
+
// clear the pressed submit button information
|
|
96
|
+
element.store('rails:submit-button', null);
|
|
97
|
+
} else {
|
|
98
|
+
method = element.readAttribute('data-method') || 'get';
|
|
99
|
+
url = element.readAttribute('href');
|
|
100
|
+
params = {};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
new Ajax.Request(url, {
|
|
104
|
+
method: method,
|
|
105
|
+
parameters: params,
|
|
106
|
+
evalScripts: true,
|
|
107
|
+
|
|
108
|
+
onCreate: function(response) { element.fire("ajax:create", response); },
|
|
109
|
+
onComplete: function(response) { element.fire("ajax:complete", response); },
|
|
110
|
+
onSuccess: function(response) { element.fire("ajax:success", response); },
|
|
111
|
+
onFailure: function(response) { element.fire("ajax:failure", response); }
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
element.fire("ajax:after");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function insertHiddenField(form, name, value) {
|
|
118
|
+
form.insert(new Element('input', { type: 'hidden', name: name, value: value }));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function handleMethod(element) {
|
|
122
|
+
var method = element.readAttribute('data-method'),
|
|
123
|
+
url = element.readAttribute('href'),
|
|
124
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
|
125
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
|
126
|
+
|
|
127
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
|
128
|
+
$(element.parentNode).insert(form);
|
|
129
|
+
|
|
130
|
+
if (method !== 'post') {
|
|
131
|
+
insertHiddenField(form, '_method', method);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (csrf_param) {
|
|
135
|
+
insertHiddenField(form, csrf_param.readAttribute('content'), csrf_token.readAttribute('content'));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
form.submit();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function disableFormElements(form) {
|
|
142
|
+
form.select('input[type=submit][data-disable-with]').each(function(input) {
|
|
143
|
+
input.store('rails:original-value', input.getValue());
|
|
144
|
+
input.setValue(input.readAttribute('data-disable-with')).disable();
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function enableFormElements(form) {
|
|
149
|
+
form.select('input[type=submit][data-disable-with]').each(function(input) {
|
|
150
|
+
input.setValue(input.retrieve('rails:original-value')).enable();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function allowAction(element) {
|
|
155
|
+
var message = element.readAttribute('data-confirm');
|
|
156
|
+
return !message || confirm(message);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
document.on('click', 'a[data-confirm], a[data-remote], a[data-method]', function(event, link) {
|
|
160
|
+
if (!allowAction(link)) {
|
|
161
|
+
event.stop();
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (link.readAttribute('data-remote')) {
|
|
166
|
+
handleRemote(link);
|
|
167
|
+
event.stop();
|
|
168
|
+
} else if (link.readAttribute('data-method')) {
|
|
169
|
+
handleMethod(link);
|
|
170
|
+
event.stop();
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
document.on("click", "form input[type=submit], form button[type=submit], form button:not([type])", function(event, button) {
|
|
175
|
+
// register the pressed submit button
|
|
176
|
+
event.findElement('form').store('rails:submit-button', button.name || false);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
document.on("submit", function(event) {
|
|
180
|
+
var form = event.findElement();
|
|
181
|
+
|
|
182
|
+
if (!allowAction(form)) {
|
|
183
|
+
event.stop();
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (form.readAttribute('data-remote')) {
|
|
188
|
+
handleRemote(form);
|
|
189
|
+
event.stop();
|
|
190
|
+
} else {
|
|
191
|
+
disableFormElements(form);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
document.on('ajax:create', 'form', function(event, form) {
|
|
196
|
+
if (form == event.findElement()) disableFormElements(form);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
document.on('ajax:complete', 'form', function(event, form) {
|
|
200
|
+
if (form == event.findElement()) enableFormElements(form);
|
|
201
|
+
});
|
|
202
|
+
})();
|
|
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'
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Configure Rails Envinronment
|
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
|
3
|
+
|
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
5
|
+
require "rails/test_help"
|
|
6
|
+
|
|
7
|
+
ActionMailer::Base.delivery_method = :test
|
|
8
|
+
ActionMailer::Base.perform_deliveries = true
|
|
9
|
+
ActionMailer::Base.default_url_options[:host] = "test.com"
|
|
10
|
+
|
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
|
12
|
+
|
|
13
|
+
# Configure capybara for integration testing
|
|
14
|
+
require "capybara/rails"
|
|
15
|
+
Capybara.default_driver = :rack_test
|
|
16
|
+
Capybara.default_selector = :css
|
|
17
|
+
|
|
18
|
+
# Run any available migration
|
|
19
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
|
20
|
+
|
|
21
|
+
# Load support files
|
|
22
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
metadata
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: flagpole_sitta
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.5.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Andrew Rove (Rover)
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-07-18 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: dalli
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
description: ! "Flagpole Sitta is a gem that main purpose is to make it easier to
|
|
31
|
+
effectively fragment cache in dynamic fashions.\n When ever a cache is created it
|
|
32
|
+
is associated with any model and/or record you tell it to be from the helper method.
|
|
33
|
+
When that model and/or record is updated all it's associated cache's are cleared.\n
|
|
34
|
+
Flagpole also expects you to put all your database calls into Procs/Lamdbas. This
|
|
35
|
+
makes it so that your database calls wont have to happen unless your cache hasn't
|
|
36
|
+
been created. Thus speeding up response time and reducing database traffic."
|
|
37
|
+
email:
|
|
38
|
+
- rovermicrover@gmail.com
|
|
39
|
+
executables: []
|
|
40
|
+
extensions: []
|
|
41
|
+
extra_rdoc_files: []
|
|
42
|
+
files:
|
|
43
|
+
- .gitignore
|
|
44
|
+
- Gemfile
|
|
45
|
+
- Gemfile.lock
|
|
46
|
+
- README.rdoc
|
|
47
|
+
- Rakefile
|
|
48
|
+
- app/helpers/flagpole_sitta_helper.rb
|
|
49
|
+
- flagpole_sitta.gemspec
|
|
50
|
+
- lib/flagpole_sitta.rb
|
|
51
|
+
- lib/flagpole_sitta/bracket_retrieval.rb
|
|
52
|
+
- lib/flagpole_sitta/cache_sitta.rb
|
|
53
|
+
- lib/flagpole_sitta/config_sitta.rb
|
|
54
|
+
- lib/flagpole_sitta/engine.rb
|
|
55
|
+
- lib/flagpole_sitta/existance_hash.rb
|
|
56
|
+
- lib/flagpole_sitta/version.rb
|
|
57
|
+
- test/dummy/Rakefile
|
|
58
|
+
- test/dummy/app/controllers/application_controller.rb
|
|
59
|
+
- test/dummy/app/helpers/application_helper.rb
|
|
60
|
+
- test/dummy/app/views/layouts/application.html.erb
|
|
61
|
+
- test/dummy/config.ru
|
|
62
|
+
- test/dummy/config/application.rb
|
|
63
|
+
- test/dummy/config/boot.rb
|
|
64
|
+
- test/dummy/config/database.yml
|
|
65
|
+
- test/dummy/config/environment.rb
|
|
66
|
+
- test/dummy/config/environments/development.rb
|
|
67
|
+
- test/dummy/config/environments/production.rb
|
|
68
|
+
- test/dummy/config/environments/test.rb
|
|
69
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
|
70
|
+
- test/dummy/config/initializers/inflections.rb
|
|
71
|
+
- test/dummy/config/initializers/mime_types.rb
|
|
72
|
+
- test/dummy/config/initializers/secret_token.rb
|
|
73
|
+
- test/dummy/config/initializers/session_store.rb
|
|
74
|
+
- test/dummy/config/locales/en.yml
|
|
75
|
+
- test/dummy/config/routes.rb
|
|
76
|
+
- test/dummy/public/404.html
|
|
77
|
+
- test/dummy/public/422.html
|
|
78
|
+
- test/dummy/public/500.html
|
|
79
|
+
- test/dummy/public/favicon.ico
|
|
80
|
+
- test/dummy/public/javascripts/application.js
|
|
81
|
+
- test/dummy/public/javascripts/controls.js
|
|
82
|
+
- test/dummy/public/javascripts/dragdrop.js
|
|
83
|
+
- test/dummy/public/javascripts/effects.js
|
|
84
|
+
- test/dummy/public/javascripts/prototype.js
|
|
85
|
+
- test/dummy/public/javascripts/rails.js
|
|
86
|
+
- test/dummy/public/stylesheets/.gitkeep
|
|
87
|
+
- test/dummy/script/rails
|
|
88
|
+
- test/flagpole_sitta_test.rb
|
|
89
|
+
- test/integration/navigation_test.rb
|
|
90
|
+
- test/support/integration_case.rb
|
|
91
|
+
- test/test_helper.rb
|
|
92
|
+
homepage: https://github.com/rovermicrover/FlagpoleSitta
|
|
93
|
+
licenses: []
|
|
94
|
+
post_install_message:
|
|
95
|
+
rdoc_options: []
|
|
96
|
+
require_paths:
|
|
97
|
+
- lib
|
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
|
+
none: false
|
|
100
|
+
requirements:
|
|
101
|
+
- - ! '>='
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ! '>='
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
requirements: []
|
|
111
|
+
rubyforge_project:
|
|
112
|
+
rubygems_version: 1.8.24
|
|
113
|
+
signing_key:
|
|
114
|
+
specification_version: 3
|
|
115
|
+
summary: FlagpoleSitta a gem for effective dynamic caching
|
|
116
|
+
test_files: []
|