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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42da47403244af3f7022e32f31a41c67d525fdce
4
- data.tar.gz: 3b2997d390db2520b960d7e292e7c1fa98ba6e62
3
+ metadata.gz: 74674fb169fb1798caf69614bdacee3df6d39d2f
4
+ data.tar.gz: e6c987739e6ae8fc3fd2b129fbc3f2a78432165f
5
5
  SHA512:
6
- metadata.gz: a6259364d8b6cc1ff284c5d27e89b740ea3f1b5c40cf182e8324c41bc74e413f4ee0cd3efdf2440c6a45fde288211e378d65cb7f6fb8ff83234c42f2643a2d59
7
- data.tar.gz: 7a62b691ae316b692452bc8fa136d831a8b6e242f03fed4c2946d1e5feef3ea370a6f94d5ca3f707f9c3b3ff93ffc17f161a022648af3ac0a464bc4649d673e6
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 some JavaScript to your application layout. The code is responsible for initializing and call the action specific JavaScript. This snippet should be added before the closing body tag.
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
- <script>
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 add the following JavaScript snippet before the CLOSING body tag in your application layout.
25
+ In order to complete installation, you must include the following helper BEFORE the closing body tag in the application layout:
26
26
 
27
- ERB:
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
@@ -3,5 +3,9 @@ module RailsScript
3
3
  config.app_generators do |g|
4
4
  g.templates.unshift File::expand_path('../../templates', __FILE__)
5
5
  end
6
+
7
+ initializer 'rails_Script.loader_helper' do
8
+ ActionView::Base.send :include, LoaderHelper
9
+ end
6
10
  end
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module RailsScript
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/rails_script.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rails_script/version'
2
+ require 'rails_script/loader_helper'
2
3
  require 'rails_script/railtie' if defined?(Rails)
3
4
 
4
5
  module RailsScript
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.2
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