gon 5.2.1 → 5.2.2
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/gon/jbuilder.rb +17 -9
- data/lib/gon/version.rb +1 -1
- data/spec/gon/jbuilder_spec.rb +5 -5
- data/spec/gon/rabl_with_rabl_rails_spec.rb +3 -2
- data/spec/spec_helper.rb +11 -6
- data/spec/test_data/sample_with_controller_method.json.jbuilder +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb56c6f655c420fb5f2b19813f08d6ffa9be49eb
|
4
|
+
data.tar.gz: ac393884fd947158ffa948191d261c2f3f3f3739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e7693c1b853436ebfa220a91a77ab49d34fad3b9deba29fc8f6c3aa1e4bfcfefa1ba6a2472218462bece617d5cd99c06cabab9c67eafa395dd8c7955276074e
|
7
|
+
data.tar.gz: 34c336d1e7851168c7f3284f230f10967bbaa3368b900978547e3965ffe143b5d793085b6503f51f13dd821e713b422b7dab646ea833fc9ceb2791e238c1fb88
|
data/CHANGELOG.md
CHANGED
data/lib/gon/jbuilder.rb
CHANGED
@@ -57,7 +57,15 @@ class Gon
|
|
57
57
|
name,
|
58
58
|
controller.instance_variable_get(name)
|
59
59
|
end
|
60
|
+
controller._helper_methods.each do |meth|
|
61
|
+
self.class.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1
|
62
|
+
def #{meth}(*args, &blk) # def current_user(*args, &blk)
|
63
|
+
__controller.send(%(#{meth}), *args, &blk) # controller.send(:current_user, *args, &blk)
|
64
|
+
end # end
|
65
|
+
ruby_eval
|
66
|
+
end
|
60
67
|
locals ||= {}
|
68
|
+
locals['__controller'] = controller
|
61
69
|
locals.each do |name, value|
|
62
70
|
self.class.class_eval do
|
63
71
|
define_method "#{name}" do
|
@@ -97,20 +105,20 @@ class Gon
|
|
97
105
|
end
|
98
106
|
|
99
107
|
def parse_path(path)
|
100
|
-
return path if File.exists?(path)
|
101
|
-
if (splitted = path.split('/')).blank?
|
108
|
+
return path if File.exists?(path)
|
109
|
+
if (splitted = path.split('/')).blank?
|
102
110
|
raise 'Something wrong with partial path in your jbuilder templates'
|
103
|
-
elsif splitted.size == 1
|
104
|
-
splitted.shift(@_controller_name)
|
105
|
-
end
|
106
|
-
construct_path(splitted)
|
111
|
+
elsif splitted.size == 1
|
112
|
+
splitted.shift(@_controller_name)
|
113
|
+
end
|
114
|
+
construct_path(splitted)
|
107
115
|
end
|
108
116
|
|
109
117
|
def construct_path(args)
|
110
|
-
last_arg = args.pop
|
111
|
-
tmp_path = 'app/views/' + args.join('/')
|
118
|
+
last_arg = args.pop
|
119
|
+
tmp_path = 'app/views/' + args.join('/')
|
112
120
|
path = path_with_ext(tmp_path + "/_#{last_arg}")
|
113
|
-
path || path_with_ext(tmp_path + "/#{last_arg}")
|
121
|
+
path || path_with_ext(tmp_path + "/#{last_arg}")
|
114
122
|
end
|
115
123
|
|
116
124
|
def path_with_ext(path)
|
data/lib/gon/version.rb
CHANGED
data/spec/gon/jbuilder_spec.rb
CHANGED
@@ -32,16 +32,16 @@ describe Gon do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'render json from jbuilder template with controller methods' do
|
35
|
-
|
36
|
-
controller.instance_eval {
|
35
|
+
class << controller
|
37
36
|
def private_controller_method
|
38
|
-
|
37
|
+
'gon test helper works'
|
39
38
|
end
|
39
|
+
helper_method :private_controller_method
|
40
40
|
private :private_controller_method
|
41
|
-
|
41
|
+
end
|
42
42
|
|
43
43
|
Gon.jbuilder 'spec/test_data/sample_with_controller_method.json.jbuilder', :controller => controller
|
44
|
-
expect(Gon.
|
44
|
+
expect(Gon.data_from_method).to eq('gon test helper works')
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'render json from jbuilder template with a partial' do
|
@@ -4,6 +4,7 @@ describe Gon do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
ensure_rabl_rails_is_loaded
|
7
|
+
RablRails.configuration.cache_templates = false
|
7
8
|
end
|
8
9
|
|
9
10
|
describe '.rabl with rabl-rails gem' do
|
@@ -16,7 +17,7 @@ describe Gon do
|
|
16
17
|
|
17
18
|
let(:controller) { ActionController::Base.new }
|
18
19
|
let(:objects) { [1, 2] }
|
19
|
-
|
20
|
+
|
20
21
|
context 'render template with deprecation' do
|
21
22
|
it 'still works' do
|
22
23
|
Gon.rabl 'spec/test_data/sample_rabl_rails.rabl', :controller => controller
|
@@ -32,7 +33,7 @@ describe Gon do
|
|
32
33
|
)
|
33
34
|
expect(Gon.objects.map { |it| it['inspect'] }).to eq(%w(1 2))
|
34
35
|
end
|
35
|
-
|
36
|
+
|
36
37
|
it 'works with different locals object' do
|
37
38
|
Gon.rabl(
|
38
39
|
:template => 'spec/test_data/sample_rabl_rails.rabl',
|
data/spec/spec_helper.rb
CHANGED
@@ -23,9 +23,11 @@ def ensure_rabl_is_loaded
|
|
23
23
|
load 'rabl.rb'
|
24
24
|
load 'rabl/version.rb'
|
25
25
|
load 'rabl/helpers.rb'
|
26
|
+
load 'rabl/sources.rb'
|
26
27
|
load 'rabl/partials.rb'
|
27
|
-
load 'rabl/
|
28
|
+
load 'rabl/multi_builder.rb'
|
28
29
|
load 'rabl/builder.rb'
|
30
|
+
load 'rabl/engine.rb'
|
29
31
|
load 'rabl/configuration.rb'
|
30
32
|
load 'rabl/renderer.rb'
|
31
33
|
load 'rabl/cache_engine.rb'
|
@@ -36,14 +38,17 @@ end
|
|
36
38
|
def ensure_rabl_rails_is_loaded
|
37
39
|
Object.send(:remove_const, :Rabl) if defined? Rabl
|
38
40
|
unless defined? RablRails
|
39
|
-
load 'rabl-rails/
|
40
|
-
load 'rabl-rails/
|
41
|
+
load 'rabl-rails/renderer.rb'
|
42
|
+
load 'rabl-rails/helpers.rb'
|
43
|
+
load 'rabl-rails/configuration.rb'
|
44
|
+
load 'rabl-rails/nodes/node.rb'
|
45
|
+
load 'rabl-rails/nodes/attribute.rb'
|
41
46
|
load 'rabl-rails/compiler.rb'
|
42
|
-
load 'rabl-rails/renderers/
|
47
|
+
load 'rabl-rails/renderers/hash.rb'
|
43
48
|
load 'rabl-rails/renderers/json.rb'
|
44
|
-
load 'rabl-rails/renderer.rb'
|
45
|
-
load 'rabl-rails/library.rb'
|
46
49
|
load 'rabl-rails.rb'
|
50
|
+
load 'rabl-rails/template.rb'
|
51
|
+
load 'rabl-rails/library.rb'
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
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: 5.2.
|
4
|
+
version: 5.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gazay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|