gon 6.4.0 → 6.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -2
  3. data/README.md +1 -5
  4. data/lib/gon/base.rb +6 -3
  5. data/lib/gon/compatibility/old_rails.rb +2 -0
  6. data/lib/gon/env_finder.rb +2 -0
  7. data/lib/gon/escaper.rb +2 -0
  8. data/lib/gon/global.rb +2 -2
  9. data/lib/gon/helpers.rb +2 -0
  10. data/lib/gon/jbuilder/parser.rb +6 -4
  11. data/lib/gon/jbuilder.rb +3 -1
  12. data/lib/gon/json_dumper.rb +2 -0
  13. data/lib/gon/rabl.rb +3 -1
  14. data/lib/gon/request.rb +2 -1
  15. data/lib/gon/spec_helpers.rb +2 -0
  16. data/lib/gon/version.rb +3 -1
  17. data/lib/gon/watch.rb +2 -0
  18. data/lib/gon.rb +2 -0
  19. metadata +3 -62
  20. data/.github/FUNDING.yml +0 -1
  21. data/.gitignore +0 -7
  22. data/.travis.yml +0 -14
  23. data/Gemfile +0 -6
  24. data/Rakefile +0 -10
  25. data/doc/logo.png +0 -0
  26. data/doc/logo_small.png +0 -0
  27. data/doc/top_sample.png +0 -0
  28. data/gon.gemspec +0 -31
  29. data/spec/gon/basic_spec.rb +0 -304
  30. data/spec/gon/global_spec.rb +0 -146
  31. data/spec/gon/jbuilder_spec.rb +0 -75
  32. data/spec/gon/rabl_spec.rb +0 -90
  33. data/spec/gon/templates_spec.rb +0 -36
  34. data/spec/gon/thread_spec.rb +0 -39
  35. data/spec/gon/watch_spec.rb +0 -81
  36. data/spec/spec_helper.rb +0 -36
  37. data/spec/test_data/_sample_partial.json.jbuilder +0 -1
  38. data/spec/test_data/sample.json.jbuilder +0 -1
  39. data/spec/test_data/sample.rabl +0 -2
  40. data/spec/test_data/sample_rabl_rails.rabl +0 -2
  41. data/spec/test_data/sample_url_helpers.json.jbuilder +0 -1
  42. data/spec/test_data/sample_with_controller_method.json.jbuilder +0 -2
  43. data/spec/test_data/sample_with_helpers.json.jbuilder +0 -1
  44. data/spec/test_data/sample_with_helpers.rabl +0 -3
  45. data/spec/test_data/sample_with_helpers_rabl_rails.rabl +0 -3
  46. data/spec/test_data/sample_with_locals.json.jbuilder +0 -2
  47. data/spec/test_data/sample_with_partial.json.jbuilder +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bdd0446070acfd94f0e8ef48b57eb1bfdf82179dca4cdd7a6e230d43ee9551b
4
- data.tar.gz: 3dea439ff1cefa4edef65a9c39f2d0e505114140fcbf1a9effda085f04741e64
3
+ metadata.gz: fb4ea344f74cb962215bfcc4c6607e75e7f5be64f5b75cb4e3ae5a5aa10d6b27
4
+ data.tar.gz: 48336de0a30b405faad2edb277766420f2d06c80b6804092dd4ae7764ec40363
5
5
  SHA512:
6
- metadata.gz: af0597738e9196231399b4c15e77358bb4e3e90cbfe26fefae9da4d70ae5c20982c15c424e34b37ed58cd05cf8e867f6756cfa83f8621eda301df266ab5ff251
7
- data.tar.gz: 37a2e08e06f44c863bfce115e99c9628f798347b2db2579b491d38aa959b5e5ee076b9207ae02405e303b94c8952198becef9f2d24fce8f79bd7a0b5cf001339
6
+ metadata.gz: c7ddd83671c6caf68e29c1b5cde9d179c8b5cf746af9458fde6f8b7cba64e760c728e93fde8fede4ab2242b2b026e83f134318b1c3659636a2e57f89a6ead9b1
7
+ data.tar.gz: ee87e834c70358fd8019f55564039581a4cc7636e62f655b7d123e7254ad0147fb6dfcf1f12de01a28e1c65a2d57c09d6e7cfc510933590386e1ae8152ede5e5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
- ## [Unreleased]
3
+ ## 6.5.0 and later
4
+
5
+ For changes from version 6.5.0 onwards, please check the [GitHub Releases page](https://github.com/gazay/gon/releases).
4
6
 
5
7
  ## [6.4.0] - 2020-09-18
6
8
  ### Security
@@ -230,7 +232,8 @@
230
232
  ### Changed
231
233
  - Don't really remember what was before this version
232
234
 
233
- [Unreleased]: https://github.com/gazay/gon/compare/v6.3.2...master
235
+ [Unreleased]: https://github.com/gazay/gon/compare/v6.4.0...master
236
+ [6.4.0]: https://github.com/gazay/gon/compare/v6.3.2...v6.4.0
234
237
  [6.3.2]: https://github.com/gazay/gon/compare/v6.3.1...v6.3.2
235
238
  [6.3.1]: https://github.com/gazay/gon/compare/v6.2.1...v6.3.1
236
239
  [6.2.1]: https://github.com/gazay/gon/compare/v6.2.0...v6.2.1
data/README.md CHANGED
@@ -1,11 +1,7 @@
1
1
  # Gon gem — get your Rails variables in your js
2
2
 
3
- [![Join the chat at https://gitter.im/gazay/gon](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gazay/gon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
-
5
3
  ![Gon. You should try this. If you look closer - you will see an elephant.](https://github.com/gazay/gon/raw/master/doc/logo_small.png)
6
4
 
7
- [![Build Status](https://travis-ci.org/gazay/gon.svg?branch=master)](https://travis-ci.org/gazay/gon) [![CodeClimate](https://codeclimate.com/github/gazay/gon/badges/gpa.svg)](https://codeclimate.com/github/gazay/gon)
8
-
9
5
  If you need to send some data to your js files and you don't want to do this with long way through views and parsing - use this force!
10
6
 
11
7
  Now you can easily renew data in your variables through ajax with [gon.watch](https://github.com/gazay/gon/wiki/Usage-gon-watch)!
@@ -224,7 +220,7 @@ usage gon.global.
224
220
 
225
221
  ## Speed up Gon
226
222
 
227
- You can use any [JSON Engine](https://github.com/intridea/multi_json#supported-json-engines) you want.
223
+ You can use any [JSON Engine](https://github.com/sferik/multi_json#supported-json-engines) you want.
228
224
  Gon uses `MultiJson` with autodetect mode, so all you need is just require your JSON library.
229
225
 
230
226
  ## Contributors
data/lib/gon/base.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'ostruct'
1
+ # frozen_string_literal: true
2
2
 
3
3
  class Gon
4
4
  module Base
@@ -16,6 +16,9 @@ class Gon
16
16
  nonce: nil
17
17
  }
18
18
 
19
+ Option = Struct.new(:cameled, *VALID_OPTION_DEFAULTS.keys)
20
+ private_constant :Option
21
+
19
22
  class << self
20
23
 
21
24
  def render_data(options = {})
@@ -31,7 +34,7 @@ class Gon
31
34
  private
32
35
 
33
36
  def define_options(options)
34
- _o = OpenStruct.new
37
+ _o = Option.new
35
38
 
36
39
  VALID_OPTION_DEFAULTS.each do |opt_name, default|
37
40
  _o.send("#{opt_name}=", options.fetch(opt_name, default))
@@ -43,7 +46,7 @@ class Gon
43
46
  end
44
47
 
45
48
  def formatted_data(_o)
46
- script = ''
49
+ script = +''
47
50
  before, after = render_wrap(_o)
48
51
  script << before
49
52
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'securerandom'
2
4
 
3
5
  class Gon
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module EnvFinder
3
5
  ENV_CONTROLLER_KEY = 'action_controller.instance'
data/lib/gon/escaper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module Escaper
3
5
  extend ActionView::Helpers::JavaScriptHelper
data/lib/gon/global.rb CHANGED
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  class Global < Gon
3
5
  class << self
4
-
5
6
  def all_variables
6
7
  @global_vars || {}
7
8
  end
@@ -36,7 +37,6 @@ class Gon
36
37
  @global_vars ||= {}
37
38
  @global_vars[name] = value
38
39
  end
39
-
40
40
  end
41
41
  end
42
42
  end
data/lib/gon/helpers.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module ViewHelpers
3
5
  def include_gon(options = {})
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module Jbuilder
3
5
  class Parser
@@ -91,7 +93,7 @@ class Gon
91
93
  end
92
94
 
93
95
  def parse_path(path)
94
- return path if File.exists?(path)
96
+ return path if File.exist?(path)
95
97
  if (splitted = path.split('/')).blank?
96
98
  raise 'Something wrong with partial path in your jbuilder templates'
97
99
  elsif splitted.size == 1
@@ -108,9 +110,9 @@ class Gon
108
110
  end
109
111
 
110
112
  def path_with_ext(path)
111
- return path if File.exists?(path)
112
- return "#{path}.jbuilder" if File.exists?("#{path}.jbuilder")
113
- return "#{path}.json.jbuilder" if File.exists?("#{path}.json.jbuilder")
113
+ return path if File.exist?(path)
114
+ return "#{path}.jbuilder" if File.exist?("#{path}.jbuilder")
115
+ return "#{path}.json.jbuilder" if File.exist?("#{path}.json.jbuilder")
114
116
  end
115
117
 
116
118
  def find_partials(lines = [])
data/lib/gon/jbuilder.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module Jbuilder
3
5
  class << self
@@ -30,7 +32,7 @@ class Gon
30
32
 
31
33
  def parse_options_from(args)
32
34
  if old_api? args
33
- text = "[DEPRECATION] view_path argument is now optional. "
35
+ text = +"[DEPRECATION] view_path argument is now optional. "
34
36
  text << "If you need to specify it, "
35
37
  text << "please use gon.jbuilder(:template => 'path')"
36
38
  warn text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module JsonDumper
3
5
  # Taken from ERB::Util
data/lib/gon/rabl.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'action_view'
2
4
 
3
5
  begin
@@ -63,7 +65,7 @@ class Gon
63
65
  def parse_options_from(args, global)
64
66
  if old_api? args
65
67
  unless global
66
- text = "[DEPRECATION] view_path argument is now optional. "
68
+ text = +"[DEPRECATION] view_path argument is now optional. "
67
69
  text << "If you need to specify it, "
68
70
  text << "please use gon.rabl(:template => 'path')"
69
71
  warn text
data/lib/gon/request.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  class Request
3
5
  attr_reader :env, :gon
@@ -11,6 +13,5 @@ class Gon
11
13
  def clear
12
14
  @gon = {}
13
15
  end
14
-
15
16
  end
16
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module SpecHelper
3
5
  module Rails
data/lib/gon/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
- VERSION = '6.4.0'
4
+ VERSION = '6.6.0'
3
5
  end
data/lib/gon/watch.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  class Watch < Gon
3
5
  class << self
data/lib/gon.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'request_store'
2
4
  require 'action_view'
3
5
  require 'action_controller'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gon
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.0
4
+ version: 6.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gazay
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: actionpack
@@ -66,34 +65,6 @@ dependencies:
66
65
  - - ">="
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rabl
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '='
74
- - !ruby/object:Gem::Version
75
- version: 0.11.3
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '='
81
- - !ruby/object:Gem::Version
82
- version: 0.11.3
83
- - !ruby/object:Gem::Dependency
84
- name: rabl-rails
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
68
  - !ruby/object:Gem::Dependency
98
69
  name: rspec
99
70
  requirement: !ruby/object:Gem::Requirement
@@ -186,19 +157,10 @@ executables: []
186
157
  extensions: []
187
158
  extra_rdoc_files: []
188
159
  files:
189
- - ".github/FUNDING.yml"
190
- - ".gitignore"
191
- - ".travis.yml"
192
160
  - CHANGELOG.md
193
- - Gemfile
194
161
  - LICENSE
195
162
  - README.md
196
- - Rakefile
197
163
  - coffee/watch.coffee
198
- - doc/logo.png
199
- - doc/logo_small.png
200
- - doc/top_sample.png
201
- - gon.gemspec
202
164
  - js/watch.js
203
165
  - lib/gon.rb
204
166
  - lib/gon/base.rb
@@ -215,30 +177,10 @@ files:
215
177
  - lib/gon/spec_helpers.rb
216
178
  - lib/gon/version.rb
217
179
  - lib/gon/watch.rb
218
- - spec/gon/basic_spec.rb
219
- - spec/gon/global_spec.rb
220
- - spec/gon/jbuilder_spec.rb
221
- - spec/gon/rabl_spec.rb
222
- - spec/gon/templates_spec.rb
223
- - spec/gon/thread_spec.rb
224
- - spec/gon/watch_spec.rb
225
- - spec/spec_helper.rb
226
- - spec/test_data/_sample_partial.json.jbuilder
227
- - spec/test_data/sample.json.jbuilder
228
- - spec/test_data/sample.rabl
229
- - spec/test_data/sample_rabl_rails.rabl
230
- - spec/test_data/sample_url_helpers.json.jbuilder
231
- - spec/test_data/sample_with_controller_method.json.jbuilder
232
- - spec/test_data/sample_with_helpers.json.jbuilder
233
- - spec/test_data/sample_with_helpers.rabl
234
- - spec/test_data/sample_with_helpers_rabl_rails.rabl
235
- - spec/test_data/sample_with_locals.json.jbuilder
236
- - spec/test_data/sample_with_partial.json.jbuilder
237
180
  homepage: https://github.com/gazay/gon
238
181
  licenses:
239
182
  - MIT
240
183
  metadata: {}
241
- post_install_message:
242
184
  rdoc_options: []
243
185
  require_paths:
244
186
  - lib
@@ -253,8 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
195
  - !ruby/object:Gem::Version
254
196
  version: '0'
255
197
  requirements: []
256
- rubygems_version: 3.1.2
257
- signing_key:
198
+ rubygems_version: 3.6.9
258
199
  specification_version: 4
259
200
  summary: Get your Rails variables in your JS
260
201
  test_files: []
data/.github/FUNDING.yml DELETED
@@ -1 +0,0 @@
1
- tidelift: "rubygems/gon"
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- tmp/*
6
- .rvmrc
7
- *.idea
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- env:
4
- - "RABL_GEM=rabl"
5
- - "RABL_GEM=rabl-rails"
6
-
7
- rvm:
8
- - 2.2.10
9
- - 2.3.8
10
- - 2.4.10
11
- - 2.5.8
12
- - 2.6.6
13
- - 2.7.1
14
- - ruby-head
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in gon.gemspec
4
- gem ENV['RABL_GEM'] || 'rabl'
5
-
6
- gemspec
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- desc 'Run all tests by default'
5
- task :default => :spec
6
-
7
- require 'rspec/core/rake_task'
8
- RSpec::Core::RakeTask.new do |t|
9
- t.rspec_opts = ["--color", '--format doc', '--require spec_helper']
10
- end
data/doc/logo.png DELETED
Binary file
data/doc/logo_small.png DELETED
Binary file
data/doc/top_sample.png DELETED
Binary file
data/gon.gemspec DELETED
@@ -1,31 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'gon/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'gon'
7
- s.version = Gon::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['gazay']
10
- s.licenses = ['MIT']
11
- s.email = ['alex.gaziev@gmail.com']
12
- s.homepage = 'https://github.com/gazay/gon'
13
- s.summary = %q{Get your Rails variables in your JS}
14
- s.description = %q{If you need to send some data to your js files and you don't want to do this with long way trough views and parsing - use this force!}
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.require_paths = ['lib']
18
- s.required_ruby_version = '>= 2.2.0'
19
- s.add_dependency 'actionpack', '>= 3.0.20'
20
- s.add_dependency 'i18n', '>= 0.7'
21
- s.add_dependency 'request_store', '>= 1.0'
22
- s.add_dependency 'multi_json'
23
- s.add_development_dependency 'rabl', '0.11.3'
24
- s.add_development_dependency 'rabl-rails'
25
- s.add_development_dependency 'rspec', '>= 3.0'
26
- s.add_development_dependency 'jbuilder'
27
- s.add_development_dependency 'railties', '>= 3.0.20'
28
- s.add_development_dependency 'rake'
29
- s.add_development_dependency 'pry'
30
- s.add_development_dependency 'pry-byebug'
31
- end