gon 6.2.0 → 6.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gon might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c19eee4ca6c0cff3ee98d241cec763d760538dde
4
- data.tar.gz: e8a58a191ac62e622c5f172c879a693852fce131
2
+ SHA256:
3
+ metadata.gz: d3011b64184a618203097a39e862d2003267b1cd01174fd10277036bd2bccf76
4
+ data.tar.gz: 4103a6703347a5c5cd35502d9a0655730e3889686346042dc702ba7bebe58dbf
5
5
  SHA512:
6
- metadata.gz: bac0b2f0b276f6e22a0a4f5e1d7820d2789410f980b02f329a6e1a713ace8c18c85e9c1211eab634193b5e54cc0c54c3a2728b47ef7a3568866a5cfa92a5616e
7
- data.tar.gz: 1fdd5df1b97870e96dfc7b357aa5af95406b7e8b574b9c811b7a43d79a8637af1fc9716e8e0ff1e45718b261b718dec8c3a18253a3f59e309b7465490b90c55e
6
+ metadata.gz: df7d4d73cebf80666e8a5f65c04fb8368c83fe53f600976c93f6c8136873add54e9af82df246440b851b18c1254d21f191498d2254cb537734ae8101f5277187
7
+ data.tar.gz: 0af70690d9acd62e3550ce7bea2142ddc9a518b41b921db60b70fa092fdf0344b6758adb24cbe90c7825b56e81edfb0ed987f88f73937c3191f5bd1af0041fb4
data/.travis.yml CHANGED
@@ -1,8 +1,12 @@
1
1
  language: ruby
2
2
  sudo: false
3
+ env:
4
+ - "RABL_GEM=rabl"
5
+ - "RABL_GEM=rabl-rails"
6
+
3
7
  rvm:
4
- - 2.3.3
5
- - 2.4.0
8
+ - 2.2.10
9
+ - 2.3.7
10
+ - 2.4.4
11
+ - 2.5.1
6
12
  - ruby-head
7
- # uncomment this line if your project needs to run something other than `rake`:
8
- # script: bundle exec rspec spec
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in gon.gemspec
4
+ gem ENV['RABL_GEM'] || 'rabl'
5
+
4
6
  gemspec
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2011-2016 gazay
3
+ Copyright (c) 2011-2019 Alexey Gaziev
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
data/README.md CHANGED
@@ -40,7 +40,7 @@ you might be doing something like this:
40
40
  that) - you just use data from this js - OK.
41
41
  4. You can use your data in your js
42
42
 
43
- And everytime when you need to send some data from action to js you do this.
43
+ And every time when you need to send some data from action to js you do this.
44
44
 
45
45
  With gon you configure it firstly - just put in layout one tag, and add
46
46
  gem line to your Gemfile and do the following:
data/gon.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.require_paths = ['lib']
18
- s.required_ruby_version = '> 1.8.7'
18
+ s.required_ruby_version = '>= 2.2.0'
19
19
  s.add_dependency 'actionpack', '>= 3.0'
20
20
  s.add_dependency 'request_store', '>= 1.0'
21
21
  s.add_dependency 'multi_json'
data/lib/gon/base.rb CHANGED
@@ -124,7 +124,7 @@ class Gon
124
124
 
125
125
  def convert_key(key, camelize)
126
126
  cache = RequestStore.store[:gon_keys_cache] ||= {}
127
- cache[key] ||= camelize ? key.to_s.camelize(:lower) : key.to_s
127
+ cache["#{key}_#{camelize}"] ||= camelize ? key.to_s.camelize(:lower) : key.to_s
128
128
  end
129
129
 
130
130
  end
@@ -1,9 +1,10 @@
1
1
  require 'securerandom'
2
2
 
3
3
  class Gon
4
- module GonHelpers
4
+ module ControllerHelpers
5
5
  private
6
6
 
7
+ # override this since ActionDispatch::Request#uuid appears only in Rails 3.2.1
7
8
  def gon_request_uuid
8
9
  @gon_request_uuid ||= SecureRandom.uuid
9
10
  end
data/lib/gon/helpers.rb CHANGED
@@ -52,5 +52,9 @@ class Gon
52
52
  end
53
53
  end
54
54
 
55
- ActionView::Base.send :include, Gon::ViewHelpers
56
- ActionController::Base.send :include, Gon::ControllerHelpers
55
+ ActiveSupport.on_load :action_view do
56
+ ActionView::Base.send :include, Gon::ViewHelpers
57
+ end
58
+ ActiveSupport.on_load :action_controller do
59
+ ActionController::Base.send :include, Gon::ControllerHelpers
60
+ end
@@ -24,7 +24,7 @@ class Gon
24
24
  end
25
25
  end
26
26
 
27
- if defined?(ActionController::TestCase::Behavior)
27
+ if ENV['RAILS_ENV'] == 'test' && defined?(ActionController::TestCase::Behavior)
28
28
  ActionController::TestCase::Behavior.send :include, Gon::SpecHelper::Rails
29
29
  end
30
30
 
data/lib/gon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Gon
2
- VERSION = '6.2.0'
2
+ VERSION = '6.3.1'
3
3
  end
@@ -159,6 +159,16 @@ describe Gon do
159
159
  )
160
160
  end
161
161
 
162
+ it 'outputs correct key with camel_case option set alternately ' do
163
+ Gon.test_hash = 1
164
+ @base.include_gon(camel_case: true)
165
+
166
+ expect(@base.include_gon(camel_case: false)).to eq(
167
+ wrap_script('window.gon={};' +
168
+ 'gon.test_hash=1;')
169
+ )
170
+ end
171
+
162
172
  it 'outputs correct js with an integer and without tag' do
163
173
  Gon.int = 1
164
174
  expect(@base.include_gon(need_tag: false)).to eq( \
@@ -1,9 +1,4 @@
1
1
  describe Gon do
2
-
3
- before(:all) do
4
- ensure_rabl_is_loaded
5
- end
6
-
7
2
  describe '.rabl' do
8
3
 
9
4
  before :each do
data/spec/spec_helper.rb CHANGED
@@ -14,50 +14,6 @@ end
14
14
  require 'gon'
15
15
 
16
16
  require 'jbuilder'
17
- require 'rabl'
18
- require 'rabl-rails'
19
-
20
- # rabl has a conflict with rabl-rails as rabl-rails causes Rails
21
- # to be defined. In order to run all specs at once, we'll need to
22
- # load/unload rabl and rabl-rails whenever we switch from testing
23
- # one to another.
24
- def ensure_rabl_is_loaded
25
- Object.send(:remove_const, :RablRails) if defined? RablRails
26
- Object.send(:remove_const, :Rails) if defined? Rails
27
- unless defined? Rabl
28
- load 'rabl.rb'
29
- load 'rabl/version.rb'
30
- load 'rabl/helpers.rb'
31
- load 'rabl/sources.rb'
32
- load 'rabl/partials.rb'
33
- load 'rabl/multi_builder.rb'
34
- load 'rabl/builder.rb'
35
- load 'rabl/engine.rb'
36
- load 'rabl/configuration.rb'
37
- load 'rabl/renderer.rb'
38
- load 'rabl/cache_engine.rb'
39
- end
40
- end
41
-
42
- # Unloads rabl and loads rabl-rails.
43
- def ensure_rabl_rails_is_loaded
44
- Object.send(:remove_const, :Rabl) if defined? Rabl
45
- unless defined? RablRails
46
- load 'rabl-rails/renderer.rb'
47
- load 'rabl-rails/helpers.rb'
48
- load 'rabl-rails/configuration.rb'
49
- load 'rabl-rails/nodes/node.rb'
50
- load 'rabl-rails/nodes/attribute.rb'
51
- load 'rabl-rails/compiler.rb'
52
- load 'rabl-rails/renderers/hash.rb'
53
- load 'rabl-rails/renderers/json.rb'
54
- load 'rabl-rails/renderers/xml.rb'
55
- load 'rabl-rails/renderers/plist.rb'
56
- load 'rabl-rails.rb'
57
- load 'rabl-rails/template.rb'
58
- load 'rabl-rails/library.rb'
59
- end
60
- end
61
17
 
62
18
  RSpec.configure do |config|
63
19
  config.before(:each) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gon
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.0
4
+ version: 6.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gazay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-04 00:00:00.000000000 Z
11
+ date: 2019-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -189,8 +189,7 @@ files:
189
189
  - spec/gon/basic_spec.rb
190
190
  - spec/gon/global_spec.rb
191
191
  - spec/gon/jbuilder_spec.rb
192
- - spec/gon/rabl_with_rabl_rails_spec.rb
193
- - spec/gon/rabl_with_rabl_spec.rb
192
+ - spec/gon/rabl_spec.rb
194
193
  - spec/gon/templates_spec.rb
195
194
  - spec/gon/thread_spec.rb
196
195
  - spec/gon/watch_spec.rb
@@ -216,17 +215,16 @@ require_paths:
216
215
  - lib
217
216
  required_ruby_version: !ruby/object:Gem::Requirement
218
217
  requirements:
219
- - - ">"
218
+ - - ">="
220
219
  - !ruby/object:Gem::Version
221
- version: 1.8.7
220
+ version: 2.2.0
222
221
  required_rubygems_version: !ruby/object:Gem::Requirement
223
222
  requirements:
224
223
  - - ">="
225
224
  - !ruby/object:Gem::Version
226
225
  version: '0'
227
226
  requirements: []
228
- rubyforge_project:
229
- rubygems_version: 2.5.2.1
227
+ rubygems_version: 3.0.3
230
228
  signing_key:
231
229
  specification_version: 4
232
230
  summary: Get your Rails variables in your JS
@@ -1,63 +0,0 @@
1
- describe Gon do
2
-
3
- before(:all) do
4
- ensure_rabl_rails_is_loaded
5
- RablRails.configuration.cache_templates = false
6
- end
7
-
8
- describe '.rabl with rabl-rails gem' do
9
-
10
- before :each do
11
- Gon.clear
12
- controller.instance_variable_set('@objects', objects)
13
- controller.request = ActionDispatch::TestRequest.create
14
- end
15
-
16
- let(:controller) { ActionController::Base.new }
17
- let(:objects) { [1, 2] }
18
-
19
- context 'render template with deprecation' do
20
- it 'still works' do
21
- Gon.rabl 'spec/test_data/sample_rabl_rails.rabl', :controller => controller
22
- expect(Gon.objects.length).to eq(2)
23
- end
24
- end
25
-
26
- context 'option locals' do
27
- it 'works without locals object properly' do
28
- Gon.rabl(
29
- :template =>'spec/test_data/sample_rabl_rails.rabl',
30
- :controller => controller
31
- )
32
- expect(Gon.objects.map { |it| it['inspect'] }).to eq(%w(1 2))
33
- end
34
-
35
- it 'works with different locals object' do
36
- Gon.rabl(
37
- :template => 'spec/test_data/sample_rabl_rails.rabl',
38
- :controller => controller,
39
- :locals => { :objects => [3, 4] }
40
- )
41
- expect(Gon.objects.map { |it| it['inspect'] }).to eq(%w(3 4))
42
- end
43
- end
44
-
45
- it 'works if rabl-rails is included' do
46
- Gon.rabl :template => 'spec/test_data/sample_rabl_rails.rabl', :controller => controller
47
- expect(Gon.objects.length).to eq(2)
48
- end
49
-
50
- it 'works with ActionView::Helpers' do
51
- Gon.rabl :template =>'spec/test_data/sample_with_helpers_rabl_rails.rabl', :controller => controller
52
- expect(Gon.objects.first['time_ago']).to eq('about 6 hours')
53
- end
54
-
55
- it 'raise exception if rabl or rabl-rails is not included' do
56
- Object.send :remove_const, :RablRails # ensure_rabl_rails_is_loaded method already removed Rabl
57
- expect { Gon.rabl :template => 'spec/test_data/sample.rabl', :controller => controller}.to raise_error(RuntimeError)
58
- ensure_rabl_rails_is_loaded # load up rabl-rails again, we're not done testing
59
- end
60
-
61
- end
62
-
63
- end