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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWIxY2ZiNzBjYjVkMTU4MGMzZmIyN2Q5ZGVmZTgzNjE5NGRmOGFlMg==
4
+ ZTZhZGMyNDM2OWEyZTU5YmE4NjhkZDYxNmE3YmZlZDkxMjY1ZmIwZQ==
5
5
  data.tar.gz: !binary |-
6
- MjQ2M2VkZjY5NDgxNjk1ZTE2OGFhMjMwZmI1YjU1MzE2M2MzNTRhMA==
6
+ ZmMwMzJlMWVjNjEwZDE5N2U3ZmU0NTE5YWM5NGY1ZTUzYWFiZDYwNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2M4NmI0NDc5Y2Q3ZjRiNGVjZWRmODg4NzQ2OWQ2Yjk1ZTZiMDk1Yzg3MTBl
10
- ZjI5NTA1NWExMmQ2OGY5NDAzNjAxOWFhMWY4ZmFmN2ZmYTk2ZDlmN2QxNDdl
11
- Y2U3ZDE0M2M2NGEwMTc0MDZkYTlmMjc4Y2U1Zjc4ZmQyYjk2NWM=
9
+ N2VhZWFjOWQ4OGViMTI3YzQ1ODU4ZmU2YzdjY2Q5MGUxZDNhMjdjZWRkODA1
10
+ ZTJhMGQ3MjAzNWNiMjQzOGYyZjgyNmZjYzg4MDFkNGM3OWI2MmU2MmQ2Mzg2
11
+ NTlkZTJkY2JlM2ViZWQ4ZWQ5YzE1YzYxMDlkMmJkOTBhYzc4MDY=
12
12
  data.tar.gz: !binary |-
13
- ZWJlYTZlNGIyNjdhYTMzNWNhMGQxNzNlYTM0MWViYWNiZjEwMTRkZjA4Zjgw
14
- ZmMyMDU0ODBjMWJmNmQ0ZTU1ZjdkYTJkOGZlNGY1N2E4ODJkZjhiNDFkY2E0
15
- OWY4ZmE4OTJiZGMyMDgxOTI2NzhhYjU5YmQyZTRiZjUzZTQ5YTE=
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
- window.App ||= {}
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
- window.App ||= {}
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
- window.Utility ||= {}
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
- window.Utility ||= {}
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,3 @@
1
- window.<%= RailsScript.app_namespace %> ||= {}
2
1
  class <%= RailsScript.app_namespace %>.<%= class_name.gsub('::', '') %>
3
2
 
4
3
  constructor: ->
@@ -1,4 +1,3 @@
1
- window.<%= RailsScript.app_namespace %> ||= {}
2
1
  class <%= RailsScript.app_namespace %>.<%= controller.gsub('::', '') %> extends <%= RailsScript.app_namespace %>.Base
3
2
 
4
3
  beforeAction: (action) =>
@@ -1,4 +1,3 @@
1
- window.Element ||= {}
2
1
  class Element.<%= element_name.gsub('::', '') %> <%= "extends Utility.#{utility.gsub('::', '')}" unless utility.blank? %>
3
2
 
4
3
  constructor: ->
@@ -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 %> ||= {}
@@ -1,4 +1,4 @@
1
1
  RailsScript.config do |c|
2
2
  # Configure name that will be used to namespace the javascript classes
3
- c.app_namespace = "App"
3
+ c.app_namespace = 'App'
4
4
  end
@@ -1,4 +1,3 @@
1
- window.Utility ||= {}
2
1
  class Utility.<%= utility_name.gsub('::', '') %>
3
2
 
4
3
  constructor: ->
@@ -2,23 +2,7 @@ module RailsScript
2
2
  module LoaderHelper
3
3
 
4
4
  def include_rails_script
5
- javascript_tag <<-RUBY
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
@@ -1,3 +1,3 @@
1
1
  module RailsScript
2
- VERSION = '0.7.0'
2
+ VERSION = '1.0.0'
3
3
  end
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.pheasey@gmail.com']
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/gemgento/rails_script'
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.7.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-03-10 00:00:00.000000000 Z
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.pheasey@gmail.com
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/gemgento/rails_script
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
- };