rails_script 0.7.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +6 -12
- data/lib/generators/rails_script/class/templates/javascript.js.coffee +0 -1
- data/lib/generators/rails_script/controller/templates/javascript.js.coffee +0 -1
- data/lib/generators/rails_script/element/templates/javascript.js.coffee +0 -1
- data/lib/generators/rails_script/install/templates/base.js.coffee +7 -0
- data/lib/generators/rails_script/install/templates/global.js.coffee +0 -1
- data/lib/generators/rails_script/install/templates/rails_script.rb +1 -1
- data/lib/generators/rails_script/utility/templates/javascript.js.coffee +0 -1
- data/lib/rails_script/loader_helper.rb +1 -17
- data/lib/rails_script/version.rb +1 -1
- data/rails_script.gemspec +2 -2
- metadata +4 -5
- data/include_rails_script.js.coffee +0 -9
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTZhZGMyNDM2OWEyZTU5YmE4NjhkZDYxNmE3YmZlZDkxMjY1ZmIwZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmMwMzJlMWVjNjEwZDE5N2U3ZmU0NTE5YWM5NGY1ZTUzYWFiZDYwNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2VhZWFjOWQ4OGViMTI3YzQ1ODU4ZmU2YzdjY2Q5MGUxZDNhMjdjZWRkODA1
|
10
|
+
ZTJhMGQ3MjAzNWNiMjQzOGYyZjgyNmZjYzg4MDFkNGM3OWI2MmU2MmQ2Mzg2
|
11
|
+
NTlkZTJkY2JlM2ViZWQ4ZWQ5YzE1YzYxMDlkMmJkOTBhYzc4MDY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjhmYjQ2NzVmZjE4NjIxZjBhNTg2OWMyYzM3NGQ4OTI2ZWI4MzBiNzJlNDc3
|
14
|
+
OGU3MDlmZDQwNWY2ZDg4MjE1Yzg3NTQxMGViYTIyNTcyMWIyMjVhN2U1MGZh
|
15
|
+
ZTY5ZTFlNzkwNzM1YzIwNDllMWJlY2Q1NDVlYTg1MGFiNjhkZmI=
|
data/README.md
CHANGED
@@ -36,7 +36,6 @@ Your JavaScript class is named after your Controller and there is a method for e
|
|
36
36
|
```coffeescript
|
37
37
|
# app/assets/javascripts/users.js.coffee
|
38
38
|
|
39
|
-
window.App ||= {}
|
40
39
|
class App.Users extends App.Base
|
41
40
|
|
42
41
|
show: =>
|
@@ -51,7 +50,7 @@ Executing some JavaScript to run on all controller actions is just a matter of a
|
|
51
50
|
|
52
51
|
```coffeescript
|
53
52
|
# app/assets/javascripts/users.js.coffee
|
54
|
-
|
53
|
+
|
55
54
|
class App.Users extends App.Base
|
56
55
|
|
57
56
|
beforeAction: (action) =>
|
@@ -68,7 +67,8 @@ Running some JavaScript on every page of an Application is a common need. For e
|
|
68
67
|
|
69
68
|
```coffeescript
|
70
69
|
# app/assets/javascripts/base.js.coffee
|
71
|
-
|
70
|
+
|
71
|
+
...
|
72
72
|
class App.Base
|
73
73
|
|
74
74
|
constructor: ->
|
@@ -82,6 +82,7 @@ class App.Base
|
|
82
82
|
out: ->
|
83
83
|
$(".site-credit a").html("SITE CREDIT")
|
84
84
|
)
|
85
|
+
...
|
85
86
|
```
|
86
87
|
|
87
88
|
In this example we extracted the rollover action into a new function. Doing so will make the class cleaner and easier to maintain as the application grows. Once again note the ```return this``` in the constructor.
|
@@ -94,7 +95,6 @@ Any functions that need to be accessible in the global scope should be defined i
|
|
94
95
|
|
95
96
|
```coffeescript
|
96
97
|
# app/assets/javascripts/global.js.coffee
|
97
|
-
window.App ||= {}
|
98
98
|
|
99
99
|
App.remoteSubmission = ($form) ->
|
100
100
|
return $.ajax
|
@@ -120,7 +120,7 @@ This will create the following in ```/app/assets/javascripts/utilities/modal.js.
|
|
120
120
|
|
121
121
|
```coffeescript
|
122
122
|
# /app/assets/javascripts/utilities/modal.js.coffee
|
123
|
-
|
123
|
+
|
124
124
|
class Utility.Modal
|
125
125
|
|
126
126
|
constructor: ->
|
@@ -131,7 +131,7 @@ Let's add some basic functionality:
|
|
131
131
|
|
132
132
|
```coffeescript
|
133
133
|
# /app/assets/javascripts/utilities/modal.js.coffee
|
134
|
-
|
134
|
+
|
135
135
|
class Utility.Modal
|
136
136
|
isOpen: false
|
137
137
|
|
@@ -162,7 +162,6 @@ Now, here's how we use the utility from ```users#show```
|
|
162
162
|
```coffeescript
|
163
163
|
# app/assets/javascripts/users.js.coffee
|
164
164
|
|
165
|
-
window.App ||= {}
|
166
165
|
class App.Users extends App.Base
|
167
166
|
|
168
167
|
show: ->
|
@@ -185,7 +184,6 @@ This will create the following in ```/app/assets/javascripts/elements/main_menu.
|
|
185
184
|
```coffeescript
|
186
185
|
# /app/assets/javascripts/elements/main_menu.js.coffee```
|
187
186
|
|
188
|
-
window.Element ||= {}
|
189
187
|
class Element.MainMenu
|
190
188
|
|
191
189
|
constructor: ->
|
@@ -197,7 +195,6 @@ We can now add all the logic for the main menu in a separate class and call it o
|
|
197
195
|
```coffeescript
|
198
196
|
# app/assets/javascripts/base.js.coffee
|
199
197
|
|
200
|
-
window.App ||= {}
|
201
198
|
class App.Base
|
202
199
|
|
203
200
|
constructor: ->
|
@@ -218,7 +215,6 @@ Which generates:
|
|
218
215
|
````coffeescript
|
219
216
|
# /app/assets/javascripts/elements/main_menu.js.coffee
|
220
217
|
|
221
|
-
window.Element ||= {}
|
222
218
|
class Element.MainMenu extends Utility.Modal
|
223
219
|
|
224
220
|
constructor: ->
|
@@ -282,7 +278,6 @@ Which generates:
|
|
282
278
|
```coffeescript
|
283
279
|
# /app/assets/javascripts/my/class_name.js.coffee
|
284
280
|
|
285
|
-
window.App ||= {}
|
286
281
|
class App.MyClassName
|
287
282
|
|
288
283
|
constructor: ->
|
@@ -318,7 +313,6 @@ And here's how we print that data to the console on the ```users#index``` action
|
|
318
313
|
```coffeescript
|
319
314
|
# /app/assets/javascripts/users.js.coffee
|
320
315
|
|
321
|
-
window.App ||= {}
|
322
316
|
class App.Users extends App.Base
|
323
317
|
|
324
318
|
index: =>
|
@@ -1,4 +1,11 @@
|
|
1
1
|
window.<%= RailsScript.app_namespace %> ||= {}
|
2
|
+
window.Element ||= {}
|
3
|
+
window.Utility ||= {}
|
4
|
+
|
5
|
+
$(document).on "turbolinks:load.rails_script", ->
|
6
|
+
Utility.RailsVars = $('#rails-script').data('vars')
|
7
|
+
window.$this = new (<%= RailsScript.app_namespace %>["#{$('#rails-script').data('controller')}"] || <%= RailsScript.app_namespace %>.Base)()
|
8
|
+
|
2
9
|
class <%= RailsScript.app_namespace %>.Base
|
3
10
|
|
4
11
|
constructor: ->
|
@@ -1 +0,0 @@
|
|
1
|
-
window.<%= RailsScript.app_namespace %> ||= {}
|
@@ -2,23 +2,7 @@ module RailsScript
|
|
2
2
|
module LoaderHelper
|
3
3
|
|
4
4
|
def include_rails_script
|
5
|
-
|
6
|
-
window.Utility || (window.Utility = {});
|
7
|
-
Utility.RailsVars = #{@to_javascript.nil? ? '{}' : @to_javascript.to_json};
|
8
|
-
|
9
|
-
(function() {
|
10
|
-
window.$this = new (#{RailsScript.app_namespace}.#{ controller_path.split(/\/|_/).map(&:capitalize).join('') } || #{RailsScript.app_namespace}.Base)();
|
11
|
-
if (typeof $this.beforeAction === 'function') {
|
12
|
-
$this.beforeAction("#{action_name}");
|
13
|
-
}
|
14
|
-
if (typeof $this.#{ action_name } === 'function') {
|
15
|
-
$this.#{ action_name }();
|
16
|
-
}
|
17
|
-
if (typeof $this.afterAction === 'function') {
|
18
|
-
$this.afterAction("#{action_name}");
|
19
|
-
}
|
20
|
-
})();
|
21
|
-
RUBY
|
5
|
+
content_tag :div, nil, id: 'rails-script', data: { controller: controller_path.split(/\/|_/).map(&:capitalize).join(''), vars: @to_javascript.to_json }
|
22
6
|
end
|
23
7
|
|
24
8
|
end
|
data/lib/rails_script/version.rb
CHANGED
data/rails_script.gemspec
CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'rails_script'
|
8
8
|
spec.version = RailsScript::VERSION
|
9
9
|
spec.authors = ['Kevin Pheasey']
|
10
|
-
spec.email = ['kevin
|
10
|
+
spec.email = ['kevin@kpheasey.com']
|
11
11
|
spec.summary = %q{A Rails-centric, object oriented, featherweight framework for writting CoffeeScript}
|
12
12
|
spec.description = %q{Rails Script is a Rails-centric, object oriented, featherweight framework for writting CoffeeScript. It is optomized for the Rails Asset Pipeline and is compatible with TurboLinks. Using Rails controller names and actions to call JavaScript, it has never been easier to write clean, concise, and maintanable page specific JavaScript.}
|
13
|
-
spec.homepage = 'https://github.com/
|
13
|
+
spec.homepage = 'https://github.com/kpheasey/rails_script'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\u0000")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Pheasey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -63,7 +63,7 @@ description: Rails Script is a Rails-centric, object oriented, featherweight fra
|
|
63
63
|
with TurboLinks. Using Rails controller names and actions to call JavaScript, it
|
64
64
|
has never been easier to write clean, concise, and maintanable page specific JavaScript.
|
65
65
|
email:
|
66
|
-
- kevin
|
66
|
+
- kevin@kpheasey.com
|
67
67
|
executables: []
|
68
68
|
extensions: []
|
69
69
|
extra_rdoc_files: []
|
@@ -73,7 +73,6 @@ files:
|
|
73
73
|
- LICENSE.txt
|
74
74
|
- README.md
|
75
75
|
- Rakefile
|
76
|
-
- include_rails_script.js.coffee
|
77
76
|
- lib/generators/rails_script/class/USAGE
|
78
77
|
- lib/generators/rails_script/class/class_generator.rb
|
79
78
|
- lib/generators/rails_script/class/templates/javascript.js.coffee
|
@@ -100,7 +99,7 @@ files:
|
|
100
99
|
- lib/rails_script/version.rb
|
101
100
|
- lib/templates/coffee/assets/javascript.js.coffee
|
102
101
|
- rails_script.gemspec
|
103
|
-
homepage: https://github.com/
|
102
|
+
homepage: https://github.com/kpheasey/rails_script
|
104
103
|
licenses:
|
105
104
|
- MIT
|
106
105
|
metadata: {}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
window.Utility || (window.Utility = {});
|
2
|
-
Utility.RailsVars = #{@to_javascript.nil? ? '{}' : @to_javascript.to_json};
|
3
|
-
|
4
|
-
function() {
|
5
|
-
window.$this = new (App.#{ controller_path.split(/\/|_/).map(&:capitalize).join('') } || App.Base)();
|
6
|
-
if (typeof $this.#{ action_name } === 'function') {
|
7
|
-
return $this.#{ action_name }.call();
|
8
|
-
}
|
9
|
-
};
|