rails_script 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -21
- data/lib/generators/rails_script/install/install_generator.rb +2 -19
- data/lib/rails_script/loader_helper.rb +16 -0
- data/lib/rails_script/railtie.rb +4 -0
- data/lib/rails_script/version.rb +1 -1
- data/lib/rails_script.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74674fb169fb1798caf69614bdacee3df6d39d2f
|
4
|
+
data.tar.gz: e6c987739e6ae8fc3fd2b129fbc3f2a78432165f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daa009dcada287f2e959bac9a0752cbb307944436740392eb05e4dafd76a9bc64ef72df589ad9e94b846f6b67955d0c0876f5b0799c0b108eb2d233d061317e8
|
7
|
+
data.tar.gz: 7ea7f35d25860c84ab242adc12c7910d53d6ef9861457e51074565d1d5cababaa7e869acaa9d6a1d68bccaaab6c528a5f108ae832d27e74ea7f50e1d3e0cfcf7
|
data/README.md
CHANGED
@@ -16,29 +16,10 @@ After bundling you need to run the initial installation generator:
|
|
16
16
|
|
17
17
|
$ rails g rails_script:install
|
18
18
|
|
19
|
-
After the generator finishes, you will be prompted to add
|
19
|
+
After the generator finishes, you will be prompted to add helper call to your application layout. The generated code is responsible for initializing and call the action specific JavaScript. This helper shouyld be called before the closing body tag.
|
20
20
|
|
21
|
-
For ERB:
|
22
21
|
```
|
23
|
-
|
24
|
-
jQuery(function() {
|
25
|
-
window.$this = new (App.<%= controller_path.split(/\/|_/).map(&:capitalize).join('') %> || App.Base)();
|
26
|
-
if (typeof $this.<%= action_name %> === 'function') {
|
27
|
-
return $this.<%= action_name%>.call();
|
28
|
-
}
|
29
|
-
});
|
30
|
-
</script>
|
31
|
-
```
|
32
|
-
|
33
|
-
For HAML:
|
34
|
-
```
|
35
|
-
:javascript
|
36
|
-
jQuery(function() {
|
37
|
-
window.$this = new (App.#{controller_path.split(/\/|_/).map(&:capitalize).join('')} || App.Base)();
|
38
|
-
if (typeof $this.#{action_name} === 'function') {
|
39
|
-
return $this.#{action_name}.call();
|
40
|
-
}
|
41
|
-
});
|
22
|
+
<%= include_rails_script %>
|
42
23
|
```
|
43
24
|
|
44
25
|
## Usage
|
@@ -22,26 +22,9 @@ module RailsScript
|
|
22
22
|
|
23
23
|
def insert_layout_javascript
|
24
24
|
say <<-RUBY
|
25
|
-
In order to complete installation, you must
|
25
|
+
In order to complete installation, you must include the following helper BEFORE the closing body tag in the application layout:
|
26
26
|
|
27
|
-
|
28
|
-
<script>
|
29
|
-
jQuery(function() {
|
30
|
-
window.$this = new (App.<%= controller_path.split(/\\/|_/).map(&:capitalize).join('') %> || App.Base)();
|
31
|
-
if (typeof $this.<%= action_name %> === 'function') {
|
32
|
-
return $this.<%= action_name%>.call();
|
33
|
-
}
|
34
|
-
});
|
35
|
-
</script>
|
36
|
-
|
37
|
-
HAML:
|
38
|
-
:javascript
|
39
|
-
jQuery(function() {
|
40
|
-
window.$this = new (App.\#{controller_path.split(/\\/|_/).map(&:capitalize).join('')} || App.Base)();
|
41
|
-
if (typeof $this.\#{action_name} === 'function') {
|
42
|
-
return $this.\#{action_name}.call();
|
43
|
-
}
|
44
|
-
});
|
27
|
+
<%= include_rails_script %>
|
45
28
|
RUBY
|
46
29
|
end
|
47
30
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RailsScript
|
2
|
+
module LoaderHelper
|
3
|
+
|
4
|
+
def include_rails_script
|
5
|
+
javascript_tag <<-RUBY
|
6
|
+
jQuery(function() {
|
7
|
+
window.$this = new (App.#{ controller_path.split(/\/|_/).map(&:capitalize).join('') } || App.Base)();
|
8
|
+
if (typeof $this.#{ action_name } === 'function') {
|
9
|
+
return $this.#{ action_name }.call();
|
10
|
+
}
|
11
|
+
});
|
12
|
+
RUBY
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/rails_script/railtie.rb
CHANGED
data/lib/rails_script/version.rb
CHANGED
data/lib/rails_script.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Pheasey
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/generators/rails_script/install/templates/base.js.coffee
|
82
82
|
- lib/generators/rails_script/install/templates/global.js.coffee
|
83
83
|
- lib/rails_script.rb
|
84
|
+
- lib/rails_script/loader_helper.rb
|
84
85
|
- lib/rails_script/railtie.rb
|
85
86
|
- lib/rails_script/version.rb
|
86
87
|
- lib/templates/coffee/assets/javascript.js.coffee
|