paloma 3.0.2 → 4.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.
- data/Changelog.md +8 -0
- data/README.md +151 -63
- data/app/views/paloma/_hook.html.erb +9 -11
- data/lib/paloma.rb +2 -0
- data/lib/paloma/action_controller_extension.rb +84 -15
- data/lib/paloma/controller.rb +38 -0
- data/lib/paloma/utilities.rb +23 -0
- data/paloma.gemspec +1 -1
- data/test_app/app/assets/javascripts/application.js +14 -61
- data/test_app/app/controllers/admin/foos_controller.rb +29 -0
- data/test_app/app/controllers/main_controller.rb +42 -0
- data/test_app/config/routes.rb +4 -6
- data/test_app/spec/integration/advanced_spec.rb +60 -0
- data/test_app/spec/integration/basic_spec.rb +122 -0
- data/test_app/spec/javascripts/router_spec.js +3 -72
- data/test_app/spec/spec_helper.rb +5 -0
- data/test_app/spec/units/controller_spec.rb +109 -0
- data/test_app/spec/units/utilities_spec.rb +114 -0
- data/vendor/assets/javascripts/paloma/engine.js +15 -45
- data/vendor/assets/javascripts/paloma/init.js +17 -1
- data/vendor/assets/javascripts/paloma/paloma.js +8 -6
- data/vendor/assets/javascripts/paloma/router.js +6 -47
- metadata +135 -103
- checksums.yaml +0 -15
- data/test_app/app/controllers/admin/bar_controller.rb +0 -7
- data/test_app/app/controllers/foo_controller.rb +0 -19
- data/test_app/app/controllers/multiple_names_controller.rb +0 -7
- data/test_app/spec/integration/main_spec.rb +0 -108
@@ -1,64 +1,23 @@
|
|
1
1
|
(function(Paloma){
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
var Router = function(config){
|
6
|
-
this.controllers = {};
|
7
|
-
this.redirects = {};
|
8
|
-
|
9
|
-
this.delimiters = {};
|
10
|
-
this.delimiters.namespace = config['namespace'];
|
11
|
-
this.delimiters.action = config['action'];
|
3
|
+
var Router = function(namespaceDelimiter){
|
4
|
+
this.namespaceDelimiter = namespaceDelimiter;
|
12
5
|
};
|
13
6
|
|
14
7
|
|
15
8
|
Router.prototype.parse = function(path){
|
16
|
-
var
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
var actioned = controllerPart.split(this.delimiters.action),
|
21
|
-
controller = actioned[0],
|
22
|
-
action = actioned.length == 1 ? null : actioned.pop();
|
9
|
+
var parts = path.split(this.namespaceDelimiter),
|
10
|
+
controller = parts.pop(),
|
11
|
+
namespaces = parts;
|
23
12
|
|
24
13
|
var controllerPath = namespaces.concat([controller]);
|
25
14
|
|
26
15
|
return {controllerPath: controllerPath,
|
27
16
|
namespaces: namespaces,
|
28
|
-
controller: controller
|
29
|
-
action: action};
|
30
|
-
};
|
31
|
-
|
32
|
-
|
33
|
-
Router.prototype.resource = function(resource, option){
|
34
|
-
option = option || {};
|
35
|
-
this.controllers[resource] = option['controller'] || resource;
|
36
|
-
};
|
37
|
-
|
38
|
-
|
39
|
-
Router.prototype.redirect = function(path, option){
|
40
|
-
option = option || {};
|
41
|
-
this.redirects[path] = this.parse(option['to'] || path);
|
17
|
+
controller: controller};
|
42
18
|
};
|
43
19
|
|
44
20
|
|
45
|
-
Router.prototype.controllerFor = function(resource){
|
46
|
-
return this.controllers[resource] || resource;
|
47
|
-
};
|
48
|
-
|
49
|
-
|
50
|
-
Router.prototype.redirectFor = function(resource, action){
|
51
|
-
var path = resource + this.delimiters.action + action,
|
52
|
-
redirect = this.redirects[path];
|
53
|
-
|
54
|
-
if (!redirect){ return null; }
|
55
|
-
|
56
|
-
return {controller: redirect['controllerPath'].join(this.delimiters.namespace),
|
57
|
-
action: redirect['action']};
|
58
|
-
};
|
59
|
-
|
60
|
-
|
61
|
-
|
62
21
|
Paloma.Router = Router;
|
63
22
|
|
64
23
|
})(window.Paloma);
|
metadata
CHANGED
@@ -1,119 +1,136 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: paloma
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 63
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 4.0.0
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Karl Paragua
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
|
18
|
+
date: 2014-02-15 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
14
22
|
name: jquery-rails
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ! '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
23
|
prerelease: false
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
28
36
|
name: rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ~>
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 3.2.0
|
34
|
-
type: :development
|
35
37
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
38
41
|
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 15
|
44
|
+
segments:
|
45
|
+
- 3
|
46
|
+
- 2
|
47
|
+
- 0
|
40
48
|
version: 3.2.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ! '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
49
|
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rake
|
49
53
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
62
63
|
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: rspec
|
63
67
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '2.0'
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
76
77
|
type: :development
|
78
|
+
version_requirements: *id004
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: rspec-rails
|
77
81
|
prerelease: false
|
78
|
-
|
79
|
-
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
80
85
|
- - ~>
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.0'
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 2
|
90
|
+
- 0
|
91
|
+
version: "2.0"
|
90
92
|
type: :development
|
93
|
+
version_requirements: *id005
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: capybara
|
91
96
|
prerelease: false
|
92
|
-
|
93
|
-
|
97
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
94
100
|
- - ~>
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.4.5
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 15
|
103
|
+
segments:
|
104
|
+
- 1
|
105
|
+
- 0
|
106
|
+
version: "1.0"
|
104
107
|
type: :development
|
108
|
+
version_requirements: *id006
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: jasmine-rails
|
105
111
|
prerelease: false
|
106
|
-
|
107
|
-
|
112
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
108
115
|
- - ~>
|
109
|
-
- !ruby/object:Gem::Version
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 5
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
- 4
|
121
|
+
- 5
|
110
122
|
version: 0.4.5
|
123
|
+
type: :development
|
124
|
+
version_requirements: *id007
|
111
125
|
description: Page-specific javascript for Rails done right
|
112
126
|
email: kb.paragua@gmail.com
|
113
127
|
executables: []
|
128
|
+
|
114
129
|
extensions: []
|
130
|
+
|
115
131
|
extra_rdoc_files: []
|
116
|
-
|
132
|
+
|
133
|
+
files:
|
117
134
|
- .gitignore
|
118
135
|
- Changelog.md
|
119
136
|
- Gemfile
|
@@ -123,7 +140,9 @@ files:
|
|
123
140
|
- app/views/paloma/_hook.html.erb
|
124
141
|
- lib/paloma.rb
|
125
142
|
- lib/paloma/action_controller_extension.rb
|
143
|
+
- lib/paloma/controller.rb
|
126
144
|
- lib/paloma/rails/engine.rb
|
145
|
+
- lib/paloma/utilities.rb
|
127
146
|
- paloma.gemspec
|
128
147
|
- test_app/.gitignore
|
129
148
|
- test_app/.rspec
|
@@ -138,11 +157,9 @@ files:
|
|
138
157
|
- test_app/app/assets/stylesheets/foo.css
|
139
158
|
- test_app/app/assets/stylesheets/main.css
|
140
159
|
- test_app/app/assets/stylesheets/multiple_names.css
|
141
|
-
- test_app/app/controllers/admin/
|
160
|
+
- test_app/app/controllers/admin/foos_controller.rb
|
142
161
|
- test_app/app/controllers/application_controller.rb
|
143
|
-
- test_app/app/controllers/foo_controller.rb
|
144
162
|
- test_app/app/controllers/main_controller.rb
|
145
|
-
- test_app/app/controllers/multiple_names_controller.rb
|
146
163
|
- test_app/app/helpers/admin/bar_helper.rb
|
147
164
|
- test_app/app/helpers/application_helper.rb
|
148
165
|
- test_app/app/helpers/foo_helper.rb
|
@@ -177,11 +194,14 @@ files:
|
|
177
194
|
- test_app/public/favicon.ico
|
178
195
|
- test_app/public/robots.txt
|
179
196
|
- test_app/script/rails
|
180
|
-
- test_app/spec/integration/
|
197
|
+
- test_app/spec/integration/advanced_spec.rb
|
198
|
+
- test_app/spec/integration/basic_spec.rb
|
181
199
|
- test_app/spec/javascripts/controller_builder_spec.js
|
182
200
|
- test_app/spec/javascripts/router_spec.js
|
183
201
|
- test_app/spec/javascripts/support/jasmine.yml
|
184
202
|
- test_app/spec/spec_helper.rb
|
203
|
+
- test_app/spec/units/controller_spec.rb
|
204
|
+
- test_app/spec/units/utilities_spec.rb
|
185
205
|
- test_app/test/fixtures/.gitkeep
|
186
206
|
- test_app/test/functional/.gitkeep
|
187
207
|
- test_app/test/integration/.gitkeep
|
@@ -198,27 +218,39 @@ files:
|
|
198
218
|
- vendor/assets/javascripts/paloma/init.js
|
199
219
|
- vendor/assets/javascripts/paloma/paloma.js
|
200
220
|
- vendor/assets/javascripts/paloma/router.js
|
221
|
+
has_rdoc: true
|
201
222
|
homepage: https://github.com/kbparagua/paloma
|
202
223
|
licenses: []
|
203
|
-
|
224
|
+
|
204
225
|
post_install_message:
|
205
226
|
rdoc_options: []
|
206
|
-
|
227
|
+
|
228
|
+
require_paths:
|
207
229
|
- lib
|
208
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
230
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
231
|
+
none: false
|
232
|
+
requirements:
|
233
|
+
- - ">="
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
hash: 3
|
236
|
+
segments:
|
237
|
+
- 0
|
238
|
+
version: "0"
|
239
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
240
|
+
none: false
|
241
|
+
requirements:
|
242
|
+
- - ">="
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
hash: 3
|
245
|
+
segments:
|
246
|
+
- 0
|
247
|
+
version: "0"
|
218
248
|
requirements: []
|
249
|
+
|
219
250
|
rubyforge_project:
|
220
|
-
rubygems_version:
|
251
|
+
rubygems_version: 1.5.2
|
221
252
|
signing_key:
|
222
|
-
specification_version:
|
253
|
+
specification_version: 3
|
223
254
|
summary: Provides an easy way to execute page-specific javascript for Rails.
|
224
255
|
test_files: []
|
256
|
+
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ZmY5ODBlYWI4YWMwNmI2NDFjZjMwNTUwMWQyYWNkMWVjZjc5MGEyNA==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MTM4NDcyOGIxZWFlNzI3NGUwNDBhN2Y5ZTkxNjA4NTVjN2M5MDU5OQ==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
YWM4MmIzMDI3ODI3MGIyNzFhYzAzN2Y4ZDliYzAxZGQxMTk3MjY0ZGQ1YmQ2
|
10
|
-
ZDU3YWQ0MzM3MTI3ODM5ZWI0ZGZmYWQ2M2JjNTQ4MWEyZjEwOTMyNDU2NTMx
|
11
|
-
ZDhmZDg4ZTkzZWI2OGQ4ZTY4NjhkM2I3ZGU4ODc5YmI3MTM2MGU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDFkN2RjMzk3MWRkZDhiNjI4NmY0MWNjZGQwMmQ1MTk4NThkYjUwNjJkNzNm
|
14
|
-
NDQ5NTUwMDFhZTNkZjg0NzI3ZTM3MGQzMzIzMGNiZmFkODE2MTI3NDNlODAx
|
15
|
-
NTllMDVlODA0YWZhYmM5ZmUzNjA0MzYyYjRlZDMwNTA2MjlkYzc=
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class FooController < ApplicationController
|
2
|
-
|
3
|
-
def index
|
4
|
-
redirect_to main_index_path
|
5
|
-
end
|
6
|
-
|
7
|
-
|
8
|
-
def show
|
9
|
-
js :parameter => 'Parameter From Paloma'
|
10
|
-
render :inline => '<h1>Foo#show</h1>', :layout => 'application'
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
def edit
|
15
|
-
js false
|
16
|
-
render :inline => 'Foo#edit', :layout => 'application'
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
feature 'executing Paloma controller', :js => true do
|
5
|
-
|
6
|
-
describe 'after rendering' do
|
7
|
-
|
8
|
-
it 'executes the corresponding Paloma controller action' do
|
9
|
-
visit foo_path(1)
|
10
|
-
called = page.evaluate_script 'window.called'
|
11
|
-
|
12
|
-
expect(called).to include 'MyFoo#show'
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
context 'coming from a redirect' do
|
17
|
-
before { visit foo_index_path }
|
18
|
-
|
19
|
-
it 'executes first the Paloma action of the first Rails action' do
|
20
|
-
first = page.evaluate_script 'window.called[0]'
|
21
|
-
expect(first).to eq 'MyFoo#index'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'executes next the Paloma action of the last Rails action' do
|
25
|
-
last = page.evaluate_script 'window.called.pop()'
|
26
|
-
expect(last).to eq 'Main#index'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
context 'when js params is passed' do
|
32
|
-
it 'passes the parameters to Paloma controller action' do
|
33
|
-
visit foo_path(1)
|
34
|
-
parameter = page.evaluate_script 'window.parameter'
|
35
|
-
|
36
|
-
expect(parameter).to eq 'Parameter From Paloma'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
context 'from namespaced controller' do
|
42
|
-
it 'executes the corresponding Paloma controller action' do
|
43
|
-
visit admin_bar_path(1)
|
44
|
-
called = page.evaluate_script 'window.called.pop()'
|
45
|
-
|
46
|
-
expect(called).to eq 'Admin/Bar#show'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
context 'when js(false) is triggered' do
|
52
|
-
it 'does not append paloma hook' do
|
53
|
-
visit edit_foo_path(1)
|
54
|
-
|
55
|
-
page.should_not have_selector '.js-paloma-hook'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
context 'when requests from a controller with multiple name' do
|
61
|
-
it 'executes the corresponding Paloma action' do
|
62
|
-
visit multiple_names_path
|
63
|
-
|
64
|
-
called = page.evaluate_script 'window.called.pop()'
|
65
|
-
|
66
|
-
expect(called).to eq 'MultipleNames#index'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
#
|
72
|
-
# [TODO]
|
73
|
-
# Create proper test for the following:
|
74
|
-
#
|
75
|
-
|
76
|
-
context 'when rendering json' do
|
77
|
-
it 'does not execute Paloma' do
|
78
|
-
visit json_response_main_path 1
|
79
|
-
page.should_not have_selector '.js-paloma-hook'
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
context 'when rendering js' do
|
85
|
-
it 'does not execute Paloma' do
|
86
|
-
visit js_response_main_path 1
|
87
|
-
page.should_not have_selector '.js-paloma-hook'
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
context 'when rendering xml' do
|
93
|
-
it 'does not execute Paloma' do
|
94
|
-
visit xml_response_main_path 1
|
95
|
-
page.should_not have_selector '.js-paloma-hook'
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
context 'when rendering a file' do
|
101
|
-
it 'does not execute Paloma' do
|
102
|
-
visit file_response_main_path 1
|
103
|
-
page.should_not have_selector '.js-paloma-hook'
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|