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: a9366216ecd08633b2fb945a1179b274ee61afdd
4
- data.tar.gz: 39d2113ccc01fd63af0819ea6cd876e8895fd6f4
3
+ metadata.gz: 6340ea11a666daf88a4cbbb7908b231f13da4d10
4
+ data.tar.gz: 1752a7df0e15699e354b187fa6ec06a9c68b658c
5
5
  SHA512:
6
- metadata.gz: bff7f4ef8443eae001baf920c046ee73e770c1a6134c35325ec7fd12ed0279bef745612c18bf145e8424fcf24da476d42e297e5eab0770dce9aa5cc9db1dc3d5
7
- data.tar.gz: 78bcd83907daa4cc47ced13db26154733a5be5185a982d218cb662a3937a6a1dd8a037b52ddb83970b1ea08de8e35ea1bd283f8f7eb21c96841a254464f8e8d7
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.4.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 ```all``` function. This is run before the action specific method. The example below would print 'users' for each ```Users``` controller action.
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
- all: =>
53
- console.log 'users'
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
- all: =>
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
- all: =>
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.all === 'function') {
12
- $this.all.call();
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 }.call();
15
+ $this.#{ action_name }();
16
+ }
17
+ if (typeof $this.afterAction === 'function') {
18
+ $this.afterAction("#{action_name}");
16
19
  }
17
20
  })();
18
21
  RUBY
@@ -1,3 +1,3 @@
1
1
  module RailsScript
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -1,9 +1,12 @@
1
1
  window.App ||= {}
2
2
  class App.<%= class_name %> extends App.Base
3
3
 
4
- constructor: ->
5
- super
6
- return this
4
+ beforeAction: (action) =>
5
+ return
6
+
7
+
8
+ afterAction: (action) =>
9
+ return
7
10
 
8
11
 
9
12
  index: =>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_script
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Pheasey