pluggable_js 2.0.4 → 2.1.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: 2cc20f0627f664082c987b6d5e70bd6571aae063
4
- data.tar.gz: 8171d7cf58b584808136c99d206acea4d7baa565
3
+ metadata.gz: 042a86301eb3629ddde7da5e4601b20bc1bbf8a2
4
+ data.tar.gz: ce6aee1cd8a3d65d9c89e9f46a98e6e1f0a545d9
5
5
  SHA512:
6
- metadata.gz: 5cf93f00b0f6ca8cd7a7bde116202ee1a836196eaa2d3ad9263932f3a0824bf2c46c4319b6cd3d9d4ba1d0932392c99918ce8a66ffc957f711f240745fe8d123
7
- data.tar.gz: d29e8a146abf41b85889b16a8761ce6043bd15bbc17ef45d388fefdad89a3a6b5b96604a675e4f0e0179b017f6e2c8c138d8db66f4a5903d709aeaad86b020bb
6
+ metadata.gz: 96c4ee114de5a06a5d576dbb5390c6899bef8b43144cb7cd76c51fd718517cada5e68b9d6a8940a10f9593d63b0f5a34817ff5a7844c715c31f560ea23b2c4c1
7
+ data.tar.gz: 3c1a316e6125e8754cc6789be4a2c1fe68a46631112f9dacdbecde1c8a18ab9e1815ed24944d3f1841dd58585eeebd6e55c23eed968f2f8ae58d74ec7c3ea9a9
data/CHANGELOG.md CHANGED
@@ -61,3 +61,9 @@
61
61
  ## v2.0.4
62
62
 
63
63
  * nested resources related bugfix
64
+
65
+ ## v2.1.0
66
+
67
+ * removed jquery and coffee from core dependency
68
+ * removed unused generator
69
+ * simplified main helper
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # PluggableJs
1
+ # PluggableJs
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/pluggable_js.svg)](http://badge.fury.io/rb/pluggable_js)
4
4
 
@@ -6,8 +6,8 @@ This gem provides simple functionality of loading page specific javascript and a
6
6
 
7
7
  ## Installation
8
8
 
9
- 1. Add `gem 'pluggable_js', '~> 2.0.4'` to Gemfile and run `bundle` command to install it
10
- 2. Add `<%= javascript_pluggable_tag %>` helper to application layout file after `<%= javascript_include_tag 'application' %>` line (if you use turbolinks paste it above the closing `</body>` tag)
9
+ 1. Add `gem 'pluggable_js', '~> 2.1.0'` to Gemfile and run `bundle` command to install it
10
+ 2. Add `<%= javascript_pluggable_tag %>` helper to application layout file above the closing `</body>` tag
11
11
 
12
12
  ## Usage
13
13
 
@@ -67,6 +67,7 @@ If you are passing data, move `pluggable_js` helper into a separate private meth
67
67
 
68
68
  * [from <= v0.0.6 to v1.0.0](https://github.com/peresleguine/pluggable_js/wiki/Upgrade-from-v0.0.6-or-less-to-v1.0.0)
69
69
  * [from v1.0 to v2.0](https://github.com/peresleguine/pluggable_js/wiki/Upgrade-from-v1.0-to-v2.0)
70
+ * [from v2.0 to v2.1](https://github.com/peresleguine/pluggable_js/wiki/Upgrade-from-v2.0-to-v2.1)
70
71
 
71
72
  ## Sublime Text Snippet
72
73
 
@@ -75,7 +76,8 @@ Go to `Sublime Text > Preferences > Browse Packages...` and save under `User` di
75
76
  ```xml
76
77
  <snippet>
77
78
  <content><![CDATA[
78
- @['${0}#'] = (data) ->
79
+ @['$1#$2'] = (data) ->
80
+ $0
79
81
  ]]></content>
80
82
  <tabTrigger>pjs</tabTrigger>
81
83
  <scope>source.coffee</scope>
@@ -21,5 +21,4 @@ Feature: PluggableJs
21
21
  Scenario: New Post
22
22
  When I go to new post
23
23
  Then I should see 'You wanna piece of me, boy?'
24
- And I should see 'Fire it up.'
25
24
  And I should not see 'My life for aiur.'
@@ -3,8 +3,8 @@ module PluggableJs
3
3
  DEFAULT_PAIR_ACTIONS = { 'create' => 'new', 'update' => 'edit' }
4
4
 
5
5
  class << self
6
- def pair_actions=(hash = {})
7
- @pair_actions = DEFAULT_PAIR_ACTIONS.merge hash
6
+ def pair_actions=(actions = {})
7
+ @pair_actions = DEFAULT_PAIR_ACTIONS.merge(actions)
8
8
  end
9
9
 
10
10
  def pair_actions
@@ -13,4 +13,4 @@ module PluggableJs
13
13
  end
14
14
 
15
15
  end
16
- end
16
+ end
@@ -5,26 +5,13 @@ module PluggableJs
5
5
  def javascript_pluggable_tag
6
6
  controller = params[:controller]
7
7
  action = define_pair_action
8
- sc_var_name = "__should_call_#{controller.gsub(/\//, '__')}_#{action}"
9
8
 
10
- ''.tap do |content|
11
- content << (javascript_tag "
12
- (function() {
13
- var function_name = '#{controller}##{action}';
14
- var #{sc_var_name} = true;
15
- if (typeof(this[function_name]) == 'function' && #{sc_var_name}) {
16
- $(function() {
17
- #{sc_var_name} = false;
18
- return window[function_name](#{@pluggable_js_data});
19
- });
20
- }
21
- }).call(window);"
22
- )
23
-
24
- if File.exist?(Rails.root + "app/assets/javascripts/pluggable/#{controller}/#{action}.js.coffee")
25
- content << (javascript_include_tag "pluggable/#{controller}/#{action}")
26
- end
27
- end.html_safe
9
+ javascript_tag(
10
+ "(function() {
11
+ var pluggableFunction = window['#{controller}##{action}'];
12
+ if (typeof(pluggableFunction) === 'function') { pluggableFunction(#{@pluggable_js_data}); }
13
+ }).call();"
14
+ )
28
15
  end
29
16
 
30
17
  private
@@ -41,8 +28,8 @@ module PluggableJs
41
28
  end
42
29
 
43
30
  module Controller
44
- def pluggable_js(hash)
45
- @pluggable_js_data = hash.to_json
31
+ def pluggable_js(data)
32
+ @pluggable_js_data = data.to_json
46
33
  end
47
34
  alias_method :pjs, :pluggable_js
48
35
  end
@@ -1,3 +1,3 @@
1
1
  module PluggableJs
2
- VERSION = "2.0.4"
2
+ VERSION = '2.1.0'
3
3
  end
data/pluggable_js.gemspec CHANGED
@@ -18,12 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'coffee-rails'
22
- spec.add_dependency 'jquery-rails'
23
21
  spec.add_dependency 'rails', '>= 3.1'
24
22
 
25
23
  spec.add_development_dependency 'bundler', '~> 1.3'
26
24
  spec.add_development_dependency 'cucumber-rails'
27
25
  spec.add_development_dependency 'rspec'
28
26
  spec.add_development_dependency 'capybara-webkit'
27
+ spec.add_development_dependency 'turbolinks'
28
+ spec.add_development_dependency 'jquery-rails'
29
+ spec.add_development_dependency 'coffee-rails'
29
30
  end
@@ -11,4 +11,5 @@
11
11
  // about supported directives.
12
12
  //
13
13
  //= require jquery
14
+ //= require turbolinks
14
15
  //= require_directory
@@ -2,12 +2,12 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", media: "all" %>
6
- <%= javascript_include_tag "application" %>
7
- <%= javascript_pluggable_tag %>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
8
7
  <%= csrf_meta_tags %>
9
8
  </head>
10
9
  <body>
11
10
  <%= yield %>
11
+ <%= javascript_pluggable_tag %>
12
12
  </body>
13
13
  </html>
@@ -1,2 +1,4 @@
1
1
  <div class='protoss-quotes'></div>
2
2
  <div class='terran-quotes'></div>
3
+
4
+ <%= link_to 'New post', new_pluggable_js_post_path %>
@@ -1,2 +1,4 @@
1
1
  <div class='protoss-quotes'></div>
2
2
  <div class='terran-quotes'></div>
3
+
4
+ <%= link_to 'Posts', root_path %>
@@ -6,6 +6,7 @@ require 'sprockets/railtie'
6
6
  Bundler.require(*Rails.groups)
7
7
  require 'pluggable_js'
8
8
  require 'jquery-rails'
9
+ require 'turbolinks'
9
10
 
10
11
  module Dummy
11
12
  class Application < Rails::Application
metadata CHANGED
@@ -1,37 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluggable_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Peresleguine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: coffee-rails
14
+ name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: jquery-rails
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cucumber-rails
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
- type: :runtime
48
+ type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
@@ -39,35 +53,35 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rails
56
+ name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '3.1'
48
- type: :runtime
61
+ version: '0'
62
+ type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '3.1'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: bundler
70
+ name: capybara-webkit
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '1.3'
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '1.3'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: cucumber-rails
84
+ name: turbolinks
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -81,7 +95,7 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: rspec
98
+ name: jquery-rails
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -95,7 +109,7 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: capybara-webkit
112
+ name: coffee-rails
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -125,9 +139,6 @@ files:
125
139
  - features/pluggable_js.feature
126
140
  - features/step_definitions/pluggable_js_steps.rb
127
141
  - features/support/env.rb
128
- - lib/generators/pluggable_js/USAGE
129
- - lib/generators/pluggable_js/pluggable_js_generator.rb
130
- - lib/generators/pluggable_js/templates/large_piece_of_code.js.coffee
131
142
  - lib/pluggable_js.rb
132
143
  - lib/pluggable_js/config.rb
133
144
  - lib/pluggable_js/helpers.rb
@@ -138,7 +149,6 @@ files:
138
149
  - test/dummy/Rakefile
139
150
  - test/dummy/app/assets/images/.keep
140
151
  - test/dummy/app/assets/javascripts/application.js
141
- - test/dummy/app/assets/javascripts/pluggable/pluggable_js/posts/new.js.coffee
142
152
  - test/dummy/app/assets/javascripts/posts.js.coffee
143
153
  - test/dummy/app/assets/stylesheets/application.css
144
154
  - test/dummy/app/controllers/application_controller.rb
@@ -196,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
206
  version: '0'
197
207
  requirements: []
198
208
  rubyforge_project:
199
- rubygems_version: 2.2.2
209
+ rubygems_version: 2.4.8
200
210
  signing_key:
201
211
  specification_version: 4
202
212
  summary: Page-specific javascript for Rails.
@@ -208,7 +218,6 @@ test_files:
208
218
  - test/dummy/Rakefile
209
219
  - test/dummy/app/assets/images/.keep
210
220
  - test/dummy/app/assets/javascripts/application.js
211
- - test/dummy/app/assets/javascripts/pluggable/pluggable_js/posts/new.js.coffee
212
221
  - test/dummy/app/assets/javascripts/posts.js.coffee
213
222
  - test/dummy/app/assets/stylesheets/application.css
214
223
  - test/dummy/app/controllers/application_controller.rb
@@ -1,8 +0,0 @@
1
- Description:
2
- Creates coffeescript files based on controller and action parameters.
3
-
4
- Example:
5
- $ rails generate pluggable_js Posts index new
6
-
7
- create app/assets/javascripts/pluggable/posts/index.js.coffee
8
- create app/assets/javascripts/pluggable/posts/show.js.coffee
@@ -1,19 +0,0 @@
1
- class PluggableJsGenerator < Rails::Generators::Base
2
- source_root File.expand_path('../templates', __FILE__)
3
- argument :controller, type: :string
4
- argument :actions, type: :array, default: [], banner: 'action action'
5
-
6
- def create_pluggable_js_files
7
- actions.each do |action|
8
- @action = action
9
- template 'large_piece_of_code.js.coffee', File.join('app/assets/javascripts/pluggable', controller_name, "#{action}.js.coffee")
10
- end
11
- end
12
-
13
- private
14
-
15
- def controller_name
16
- controller.tableize
17
- end
18
-
19
- end
@@ -1,9 +0,0 @@
1
- # This file is used only for large piece of js code that you
2
- # don't want to define as a function in controller related js file.
3
-
4
- # Add pluggable/* to assets precompile configuration in production.rb (and staging.rb if you have one),
5
- # e.g.: config.assets.precompile += %w(pluggable/*)
6
- # Be sure that pluggable folder is out of require_tree statement in application.js
7
-
8
- # jQuery ->
9
- # # your code goes here
@@ -1,5 +0,0 @@
1
- # This file is used only for a large piece of js code that you
2
- # don't want to define as a function in controller related js file.
3
-
4
- jQuery ->
5
- $('.terran-quotes').append('<p>Fire it up.</p>')