rails-js 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +41 -43
- data/README.md +11 -7
- data/VERSION +1 -0
- data/app/assets/javascripts/rails.js +26 -25
- data/lib/rails/js/version.rb +1 -1
- data/rails-js.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86b7da8b9fa0f2625715bf5f3f8d12a0787db532
|
4
|
+
data.tar.gz: 2b8c703e25250fb05a26764b74231f91186074dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 842ee769ced2bc2287870556218fe6c1c5fe6c26dbb50b148d15cc97670ddec18fdfadec30b5559c4053a40657f99b6adbcc8a92203dfef1e6a2028f491ffc68
|
7
|
+
data.tar.gz: 68ffb370e5f535cb2d307e7af75482effe4ae276c81f9d86b6ccbfe3dfa2b97b427f952fc03f7eace1707af806eb41d3494077426acf1f5f858cd6bf94481e1e
|
data/Gemfile.lock
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails-js (0.0
|
4
|
+
rails-js (0.1.0)
|
5
5
|
rails (~> 4)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionmailer (4.1.
|
11
|
-
actionpack (= 4.1.
|
12
|
-
actionview (= 4.1.
|
10
|
+
actionmailer (4.1.8)
|
11
|
+
actionpack (= 4.1.8)
|
12
|
+
actionview (= 4.1.8)
|
13
13
|
mail (~> 2.5, >= 2.5.4)
|
14
|
-
actionpack (4.1.
|
15
|
-
actionview (= 4.1.
|
16
|
-
activesupport (= 4.1.
|
14
|
+
actionpack (4.1.8)
|
15
|
+
actionview (= 4.1.8)
|
16
|
+
activesupport (= 4.1.8)
|
17
17
|
rack (~> 1.5.2)
|
18
18
|
rack-test (~> 0.6.2)
|
19
|
-
actionview (4.1.
|
20
|
-
activesupport (= 4.1.
|
19
|
+
actionview (4.1.8)
|
20
|
+
activesupport (= 4.1.8)
|
21
21
|
builder (~> 3.1)
|
22
22
|
erubis (~> 2.7.0)
|
23
|
-
activemodel (4.1.
|
24
|
-
activesupport (= 4.1.
|
23
|
+
activemodel (4.1.8)
|
24
|
+
activesupport (= 4.1.8)
|
25
25
|
builder (~> 3.1)
|
26
|
-
activerecord (4.1.
|
27
|
-
activemodel (= 4.1.
|
28
|
-
activesupport (= 4.1.
|
26
|
+
activerecord (4.1.8)
|
27
|
+
activemodel (= 4.1.8)
|
28
|
+
activesupport (= 4.1.8)
|
29
29
|
arel (~> 5.0.0)
|
30
|
-
activesupport (4.1.
|
30
|
+
activesupport (4.1.8)
|
31
31
|
i18n (~> 0.6, >= 0.6.9)
|
32
32
|
json (~> 1.7, >= 1.7.7)
|
33
33
|
minitest (~> 5.1)
|
@@ -42,12 +42,12 @@ GEM
|
|
42
42
|
rack-test (>= 0.5.4)
|
43
43
|
xpath (~> 2.0)
|
44
44
|
cliver (0.3.2)
|
45
|
-
coveralls (0.7.
|
45
|
+
coveralls (0.7.2)
|
46
46
|
multi_json (~> 1.3)
|
47
|
-
rest-client
|
47
|
+
rest-client (= 1.6.7)
|
48
48
|
simplecov (>= 0.7)
|
49
|
-
term-ansicolor
|
50
|
-
thor
|
49
|
+
term-ansicolor (= 1.2.2)
|
50
|
+
thor (= 0.18.1)
|
51
51
|
docile (1.1.5)
|
52
52
|
erubis (2.7.0)
|
53
53
|
hike (1.2.3)
|
@@ -56,12 +56,11 @@ GEM
|
|
56
56
|
mail (2.6.3)
|
57
57
|
mime-types (>= 1.16, < 3)
|
58
58
|
mime-types (2.4.3)
|
59
|
-
mini_portile (0.6.
|
60
|
-
minitest (5.4.
|
59
|
+
mini_portile (0.6.1)
|
60
|
+
minitest (5.4.3)
|
61
61
|
multi_json (1.10.1)
|
62
|
-
|
63
|
-
|
64
|
-
mini_portile (= 0.6.0)
|
62
|
+
nokogiri (1.6.4.1)
|
63
|
+
mini_portile (~> 0.6.0)
|
65
64
|
poltergeist (1.5.1)
|
66
65
|
capybara (~> 2.1)
|
67
66
|
cliver (~> 0.3.1)
|
@@ -70,25 +69,24 @@ GEM
|
|
70
69
|
rack (1.5.2)
|
71
70
|
rack-test (0.6.2)
|
72
71
|
rack (>= 1.0)
|
73
|
-
rails (4.1.
|
74
|
-
actionmailer (= 4.1.
|
75
|
-
actionpack (= 4.1.
|
76
|
-
actionview (= 4.1.
|
77
|
-
activemodel (= 4.1.
|
78
|
-
activerecord (= 4.1.
|
79
|
-
activesupport (= 4.1.
|
72
|
+
rails (4.1.8)
|
73
|
+
actionmailer (= 4.1.8)
|
74
|
+
actionpack (= 4.1.8)
|
75
|
+
actionview (= 4.1.8)
|
76
|
+
activemodel (= 4.1.8)
|
77
|
+
activerecord (= 4.1.8)
|
78
|
+
activesupport (= 4.1.8)
|
80
79
|
bundler (>= 1.3.0, < 2.0)
|
81
|
-
railties (= 4.1.
|
80
|
+
railties (= 4.1.8)
|
82
81
|
sprockets-rails (~> 2.0)
|
83
|
-
railties (4.1.
|
84
|
-
actionpack (= 4.1.
|
85
|
-
activesupport (= 4.1.
|
82
|
+
railties (4.1.8)
|
83
|
+
actionpack (= 4.1.8)
|
84
|
+
activesupport (= 4.1.8)
|
86
85
|
rake (>= 0.8.7)
|
87
86
|
thor (>= 0.18.1, < 2.0)
|
88
87
|
rake (10.3.2)
|
89
|
-
rest-client (1.7
|
90
|
-
mime-types (>= 1.16
|
91
|
-
netrc (~> 0.7)
|
88
|
+
rest-client (1.6.7)
|
89
|
+
mime-types (>= 1.16)
|
92
90
|
simplecov (0.9.1)
|
93
91
|
docile (~> 1.1.0)
|
94
92
|
multi_json (~> 1.0)
|
@@ -106,15 +104,15 @@ GEM
|
|
106
104
|
sqlite3 (1.3.10)
|
107
105
|
teaspoon (0.8.0)
|
108
106
|
railties (>= 3.2.5, < 5)
|
109
|
-
term-ansicolor (1.
|
110
|
-
tins (~>
|
111
|
-
thor (0.
|
107
|
+
term-ansicolor (1.2.2)
|
108
|
+
tins (~> 0.8)
|
109
|
+
thor (0.18.1)
|
112
110
|
thread_safe (0.3.4)
|
113
111
|
tilt (1.4.1)
|
114
|
-
tins (
|
112
|
+
tins (0.13.2)
|
115
113
|
tzinfo (1.2.2)
|
116
114
|
thread_safe (~> 0.1)
|
117
|
-
websocket-driver (0.
|
115
|
+
websocket-driver (0.4.0)
|
118
116
|
xpath (2.0.0)
|
119
117
|
nokogiri (~> 1.3)
|
120
118
|
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ I came up with the conclusion to organize the javascript code like the ruby code
|
|
27
27
|
/*
|
28
28
|
* app/assets/javascripts/application.js
|
29
29
|
*/
|
30
|
-
|
30
|
+
|
31
31
|
Rails.app({
|
32
32
|
// Define global helpers here
|
33
33
|
helper: function() {
|
@@ -57,7 +57,7 @@ Rails.controller('users', {
|
|
57
57
|
// execute helper
|
58
58
|
h.awesomeHelper();
|
59
59
|
},
|
60
|
-
|
60
|
+
|
61
61
|
index: function(h) {
|
62
62
|
// Do the same as in new()
|
63
63
|
this.index(h);
|
@@ -78,17 +78,17 @@ Rails.controller('users', {
|
|
78
78
|
/*
|
79
79
|
* app/assets/javascripts/controllers/admin/users.js
|
80
80
|
*/
|
81
|
-
|
81
|
+
|
82
82
|
Rails.controller('admin/users', {
|
83
83
|
new: function(h) {
|
84
84
|
// Execute action of foreign controller
|
85
85
|
R.action('users#new');
|
86
86
|
},
|
87
|
-
|
87
|
+
|
88
88
|
index: function(h) {
|
89
89
|
// Execute foreign helper with arguments
|
90
90
|
R.helper('users', 'awesomeHelper', 1, 2, 3);
|
91
|
-
|
91
|
+
|
92
92
|
// Execute global helper with arguments
|
93
93
|
R.global('helper', 1, 2, 3);
|
94
94
|
}
|
@@ -118,7 +118,7 @@ console.log(R('a.global.variable'));
|
|
118
118
|
/*
|
119
119
|
* app/assets/javascripts/namespaces/admin.js
|
120
120
|
*/
|
121
|
-
|
121
|
+
|
122
122
|
Rails.namespace('admin', function() {
|
123
123
|
// Will be executed on all admin routes (e.g. admin/users#new)
|
124
124
|
console.log('Hello Mr. Admin');
|
@@ -126,7 +126,7 @@ Rails.namespace('admin', function() {
|
|
126
126
|
```
|
127
127
|
|
128
128
|
#### For more info...
|
129
|
-
...just read in ``app/assets/javascripts/rails.js``. I tried my best and documented nearly every line of code :)
|
129
|
+
...just read in ``app/assets/javascripts/rails.js``. I tried my best and documented nearly every line of code :)
|
130
130
|
|
131
131
|
Installing
|
132
132
|
==========
|
@@ -152,3 +152,7 @@ Contributing
|
|
152
152
|
============
|
153
153
|
|
154
154
|
[Fork](https://github.com/tonekk/rails-js/fork) -> Commit -> Pull Request
|
155
|
+
|
156
|
+
This project uses the [Airbnb Styleguide](https://github.com/airbnb/javascript) as our coding guideline.
|
157
|
+
We think this is a good piece of work and worth spreading.
|
158
|
+
In case of any doubts refer to the style used around.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -49,7 +49,7 @@
|
|
49
49
|
*/
|
50
50
|
listener = function(event) {
|
51
51
|
|
52
|
-
if(Rails.config && Rails.config.test) {
|
52
|
+
if (Rails.config && Rails.config.test) {
|
53
53
|
return;
|
54
54
|
}
|
55
55
|
|
@@ -61,8 +61,8 @@
|
|
61
61
|
/*
|
62
62
|
* Add support to Turbolinks page changes
|
63
63
|
*/
|
64
|
-
if(typeof Turbolinks !== 'undefined') {
|
65
|
-
document.addEventListener(
|
64
|
+
if (typeof Turbolinks !== 'undefined') {
|
65
|
+
document.addEventListener('page:load', listener);
|
66
66
|
}
|
67
67
|
};
|
68
68
|
|
@@ -83,7 +83,7 @@
|
|
83
83
|
/*
|
84
84
|
* Should not be able to define controller (and helpers) twice
|
85
85
|
*/
|
86
|
-
if(controllers[name]) {
|
86
|
+
if (controllers[name]) {
|
87
87
|
throw ['Controller \'', name,
|
88
88
|
'\' is already defined! Please use a namespace'].join('');
|
89
89
|
}
|
@@ -105,34 +105,34 @@
|
|
105
105
|
/*
|
106
106
|
* Make sure rails.js has been properly added to the layout
|
107
107
|
*/
|
108
|
-
if(!(this.config && this.config.controller && this.config.action)) {
|
108
|
+
if (!(this.config && this.config.controller && this.config.action)) {
|
109
109
|
|
110
110
|
throw ['No action or controller given.',
|
111
111
|
'It seems like you forgot to add rails.js to your layouts\' header.'].join(' ');
|
112
112
|
}
|
113
113
|
|
114
|
-
var controller,
|
114
|
+
var controllerName = this.config.controller,
|
115
115
|
namespaceHook,
|
116
|
-
|
116
|
+
controller;
|
117
117
|
|
118
118
|
/*
|
119
119
|
* Execute beforeAll() hook if defined
|
120
120
|
*/
|
121
|
-
if(beforeAll && typeof(beforeAll) == 'function') {
|
121
|
+
if (beforeAll && typeof(beforeAll) == 'function') {
|
122
122
|
beforeAll();
|
123
123
|
}
|
124
124
|
|
125
125
|
/*
|
126
126
|
* Take care of namespace (e.g. admin/users)
|
127
127
|
*/
|
128
|
-
if(this.config.namespace) {
|
128
|
+
if (this.config.namespace) {
|
129
129
|
controllerName = this.config.namespace + '/' + controllerName;
|
130
130
|
|
131
131
|
/*
|
132
132
|
* Execute namespace hook if we defined one
|
133
133
|
*/
|
134
134
|
namespaceHook = namespaceHooks[this.config.namespace];
|
135
|
-
if(namespaceHook && typeof(namespaceHook) == 'function') {
|
135
|
+
if (namespaceHook && typeof(namespaceHook) == 'function') {
|
136
136
|
namespaceHook();
|
137
137
|
}
|
138
138
|
}
|
@@ -141,7 +141,7 @@
|
|
141
141
|
* Find controller and execute method
|
142
142
|
*/
|
143
143
|
var controller = controllers[controllerName];
|
144
|
-
if(controller && controller[this.config.action] &&
|
144
|
+
if (controller && controller[this.config.action] &&
|
145
145
|
typeof(controller[this.config.action]) == 'function') {
|
146
146
|
|
147
147
|
controller[this.config.action](controller.helpers);
|
@@ -162,7 +162,7 @@
|
|
162
162
|
/*
|
163
163
|
* Should not be able to define controller (and helpers) twice
|
164
164
|
*/
|
165
|
-
if(namespaceHooks[name]) {
|
165
|
+
if (namespaceHooks[name]) {
|
166
166
|
throw ['Namespace \'', name, '\' is already defined!'].join('');
|
167
167
|
}
|
168
168
|
|
@@ -192,11 +192,12 @@
|
|
192
192
|
*
|
193
193
|
*/
|
194
194
|
var steps = key.split('.'),
|
195
|
-
step = data
|
195
|
+
step = data,
|
196
|
+
i;
|
196
197
|
|
197
|
-
if(arguments.length == 2) {
|
198
|
-
for(
|
199
|
-
if(!step[steps[i]]) {
|
198
|
+
if (arguments.length == 2) {
|
199
|
+
for (i = 0; i < steps.length-1; i++) {
|
200
|
+
if (!step[steps[i]]) {
|
200
201
|
step[steps[i]] = {};
|
201
202
|
}
|
202
203
|
|
@@ -206,9 +207,9 @@
|
|
206
207
|
step[steps[steps.length -1]] = val;
|
207
208
|
|
208
209
|
} else {
|
209
|
-
for(
|
210
|
+
for (i = 0; i < steps.length; i++) {
|
210
211
|
step = step[steps[i]];
|
211
|
-
if(!step) {
|
212
|
+
if (!step) {
|
212
213
|
break;
|
213
214
|
}
|
214
215
|
|
@@ -235,14 +236,14 @@
|
|
235
236
|
/*
|
236
237
|
* Treat 3rd argument as arguments for helper if it is an Array
|
237
238
|
*/
|
238
|
-
if(args.length == 1 && args[0] instanceof Array) {
|
239
|
+
if (args.length == 1 && args[0] instanceof Array) {
|
239
240
|
args = args[0];
|
240
241
|
}
|
241
242
|
|
242
243
|
/*
|
243
244
|
* Choose global helper if controllerName is not given
|
244
245
|
*/
|
245
|
-
if(controllerName) {
|
246
|
+
if (controllerName) {
|
246
247
|
controller = controllers[controllerName];
|
247
248
|
helper = controller.helpers[helperName];
|
248
249
|
} else {
|
@@ -252,8 +253,8 @@
|
|
252
253
|
/*
|
253
254
|
* Make sure our helper exists
|
254
255
|
*/
|
255
|
-
if(!(helper && typeof(helper) == 'function')) {
|
256
|
-
if(controllerName) {
|
256
|
+
if (!(helper && typeof(helper) == 'function')) {
|
257
|
+
if (controllerName) {
|
257
258
|
throw ['Helper \'', helperName, '\' not defined for controller \'',
|
258
259
|
controllerName, '\''].join('');
|
259
260
|
} else {
|
@@ -299,7 +300,7 @@
|
|
299
300
|
controllerName = arguments[0],
|
300
301
|
actionName = arguments[1];
|
301
302
|
|
302
|
-
if(action.indexOf('#') !== -1) {
|
303
|
+
if (action.indexOf('#') !== -1) {
|
303
304
|
controllerName = action.split('#')[0];
|
304
305
|
actionName = action.split('#')[1];
|
305
306
|
}
|
@@ -309,10 +310,10 @@
|
|
309
310
|
*/
|
310
311
|
controller = controllers[controllerName];
|
311
312
|
|
312
|
-
if(!controller) {
|
313
|
+
if (!controller) {
|
313
314
|
throw ['Attempting to call action \'', controllerName, '#', actionName,
|
314
315
|
'\', but Controller \'', controllerName, '\' is not defined!'].join('');
|
315
|
-
} else if(!controller[actionName] || !(typeof(controller[actionName]) == 'function')) {
|
316
|
+
} else if (!controller[actionName] || !(typeof(controller[actionName]) == 'function')) {
|
316
317
|
throw ['Attempting to call action \'', controllerName, '#', actionName,
|
317
318
|
'\', but Action \'', actionName, '\' is not defined!'].join('');
|
318
319
|
}
|
data/lib/rails/js/version.rb
CHANGED
data/rails-js.gemspec
CHANGED
@@ -6,7 +6,7 @@ require "rails/js/version"
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'rails-js'
|
8
8
|
s.version = Rails::JS::VERSION
|
9
|
-
s.date =
|
9
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
10
10
|
s.summary = "A new approach to structure your javascript in non single-page Rails apps"
|
11
11
|
s.description = "Divide your javascript like you divide your ruby code. Put it in controllers and actions and write clean, scalable code."
|
12
12
|
s.authors = ["Finn-Lenanrt Heemeyer"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Finn-Lenanrt Heemeyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- MIT-LICENSE
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
|
+
- VERSION
|
97
98
|
- app/assets/javascripts/rails.js
|
98
99
|
- lib/rails/js.rb
|
99
100
|
- lib/rails/js/engine.rb
|
@@ -171,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
172
|
version: '0'
|
172
173
|
requirements: []
|
173
174
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.0.14
|
175
176
|
signing_key:
|
176
177
|
specification_version: 4
|
177
178
|
summary: A new approach to structure your javascript in non single-page Rails apps
|