rails_script 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6340ea11a666daf88a4cbbb7908b231f13da4d10
|
4
|
+
data.tar.gz: 1752a7df0e15699e354b187fa6ec06a9c68b658c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bd76926c6e48c5c9d28aba1180739638fc1bd4b08f6793226f1de8a7fa8d7879ce80ae18cd38ac2d3c5cc4c5a301296f3c0a2ef79ea31396220d894f7ac0466
|
7
|
+
data.tar.gz: d6b57d3ceb80ce0117bf705137e0cd8c246af894ad2512b48c847991e0f220e6737b1e1a85d9c91ea7a4f39f7e6f8f14f228bece9db2dd30da43a95ba54e30c7
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ RailsScript is a Rails-centric, object oriented, featherweight framework for wri
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'rails_script', '~> 0.
|
9
|
+
gem 'rails_script', '~> 0.5.0'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -42,15 +42,18 @@ class App.Users extends App.Base
|
|
42
42
|
|
43
43
|
### Controller Specific JavaScript
|
44
44
|
|
45
|
-
Executing some JavaScript to run on all controller actions is just a matter of adding it to the ```
|
45
|
+
Executing some JavaScript to run on all controller actions is just a matter of adding it to the ```beforeAction``` or ```afterAction``` function. ```beforeAction``` is run before all controller action functions and ```afterAction``` is run after all controller action functions. The before and after action functions have an optional argument ```action``` which is string containing the current action name. The example below would print 'before ACTION action' and 'after ACTION action' for each ```Users``` controller action.
|
46
46
|
|
47
47
|
```
|
48
48
|
# app/assets/javascripts/users.js.coffee
|
49
49
|
window.App ||= {}
|
50
50
|
class App.Users extends App.Base
|
51
51
|
|
52
|
-
|
53
|
-
console.log
|
52
|
+
beforeAction: (action) =>
|
53
|
+
console.log "before #{action} action"
|
54
|
+
|
55
|
+
afterAction: (action) =>
|
56
|
+
console.log "after #{action} action"
|
54
57
|
```
|
55
58
|
|
56
59
|
|
@@ -237,8 +240,12 @@ Since the above example includes a namespace, it would generate:
|
|
237
240
|
window.App ||= {}
|
238
241
|
class App.SomeNewController extends App.Base
|
239
242
|
|
240
|
-
|
243
|
+
beforeAction: (action) =>
|
241
244
|
return
|
245
|
+
|
246
|
+
|
247
|
+
afterAction: (action) =>
|
248
|
+
return
|
242
249
|
|
243
250
|
|
244
251
|
index: =>
|
@@ -1,7 +1,11 @@
|
|
1
1
|
window.App ||= {}
|
2
2
|
class App.<%= controller.gsub('::', '') %> extends App.Base
|
3
3
|
|
4
|
-
|
4
|
+
beforeAction: (action) =>
|
5
|
+
return
|
6
|
+
|
7
|
+
|
8
|
+
afterAction: (action) =>
|
5
9
|
return
|
6
10
|
|
7
11
|
|
@@ -18,4 +22,4 @@ class App.<%= controller.gsub('::', '') %> extends App.Base
|
|
18
22
|
|
19
23
|
|
20
24
|
edit: =>
|
21
|
-
return
|
25
|
+
return
|
@@ -8,11 +8,14 @@ Utility.RailsVars = #{@to_javascript.nil? ? '{}' : @to_javascript.to_json};
|
|
8
8
|
|
9
9
|
(function() {
|
10
10
|
window.$this = new (App.#{ controller_path.split(/\/|_/).map(&:capitalize).join('') } || App.Base)();
|
11
|
-
if (typeof $this.
|
12
|
-
$this.
|
11
|
+
if (typeof $this.beforeAction === 'function') {
|
12
|
+
$this.beforeAction("#{action_name}");
|
13
13
|
}
|
14
14
|
if (typeof $this.#{ action_name } === 'function') {
|
15
|
-
$this.#{ action_name }
|
15
|
+
$this.#{ action_name }();
|
16
|
+
}
|
17
|
+
if (typeof $this.afterAction === 'function') {
|
18
|
+
$this.afterAction("#{action_name}");
|
16
19
|
}
|
17
20
|
})();
|
18
21
|
RUBY
|
data/lib/rails_script/version.rb
CHANGED