gon 4.0.3 → 4.1.0

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.

@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.2
5
4
  - 1.9.3
5
+ - 2.0.0
6
6
  - jruby-18mode # JRuby in 1.8 mode
7
7
  - jruby-19mode # JRuby in 1.9 mode
8
8
  - rbx-18mode
@@ -1,9 +1,16 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 4.1.0
4
+
5
+ * Refactored script tag generation (@toothrot)
6
+ * Stop support for MRI 1.8.7
7
+ * Added rabl-rails support (@jtherrell)
8
+ * Accepting locals in jbuilder templates
9
+
3
10
  ## 4.0.3
4
11
 
5
12
  * Added new method `Gon#push` for assign variables through Hash-like
6
- objects (topdev)
13
+ objects (@topdev)
7
14
  * Fixes for 1.8.7 compatibility.
8
15
  * !!!IMPORTANT!!! Last version with compatibility for MRI 1.8.7
9
16
 
data/README.md CHANGED
@@ -8,7 +8,7 @@ If you need to send some data to your js files and you don't want to do this wit
8
8
 
9
9
  Now you can easily renew data in your variables through ajax with [gon.watch](https://github.com/gazay/gon/wiki/Usage-gon-watch)!
10
10
 
11
- With [Jbuilder](https://github.com/rails/jbuilder) and [Rabl](https://github.com/nesquena/rabl) support!
11
+ With [Jbuilder](https://github.com/rails/jbuilder), [Rabl](https://github.com/nesquena/rabl), and [Rabl-Rails](https://github.com/ccocchi/rabl-rails) support!
12
12
 
13
13
  For Sinatra available [gon-sinatra](https://github.com/gazay/gon-sinatra).
14
14
 
@@ -138,6 +138,30 @@ Profit of using Rabl with gon:
138
138
  [Instruction](https://github.com/gazay/gon/wiki/Usage-with-rabl) for
139
139
  usage gon with Rabl.
140
140
 
141
+ ## Usage with Rabl-Rails
142
+ `gon.rabl` works with [rabl-rails](https://github.com/ccocchi/rabl-rails). Learn to write RABL the rabl-rails way [here](https://github.com/ccocchi/rabl-rails).
143
+
144
+ Add gon and rabl-rails to your environment:
145
+ ```ruby
146
+ gem 'gon'
147
+ gem 'rabl-rails'
148
+ ```
149
+ Define a rabl template using rabl-rails syntax:
150
+ ```rabl
151
+ #app/views/users/show.rabl
152
+ object :@user
153
+ attributes :id, :name, :email, :location
154
+ ```
155
+ Call gon.rabl in your controller
156
+
157
+ ```ruby
158
+ #app/controllers/users_controller.rb
159
+ def show
160
+ @user = User.find(params[:id])
161
+ gon.rabl
162
+ end
163
+ ```
164
+
141
165
  ## Usage with Jbuilder
142
166
 
143
167
  Use gon with [Jbuilder](https://github.com/rails/jbuilder) as with [Rabl](https://guthub.com/nesquena/rabl):
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency "actionpack", '>= 2.3.0'
22
22
  s.add_dependency "json"
23
23
  s.add_development_dependency "rabl"
24
+ s.add_development_dependency "rabl-rails"
24
25
  s.add_development_dependency "rspec"
25
26
  s.add_development_dependency "jbuilder"
26
27
  s.add_development_dependency "rake"
data/lib/gon.rb CHANGED
@@ -6,12 +6,8 @@ require 'gon/watch'
6
6
  require 'gon/request'
7
7
  require 'gon/helpers'
8
8
  require 'gon/escaper'
9
- if defined?(Rabl)
10
- require 'gon/rabl'
11
- end
12
- if defined?(Jbuilder)
13
- require 'gon/jbuilder'
14
- end
9
+ require 'gon/rabl'
10
+ require 'gon/jbuilder'
15
11
 
16
12
  class Gon
17
13
  class << self
@@ -61,20 +57,13 @@ class Gon
61
57
  end
62
58
 
63
59
  def rabl(*args)
64
- unless Gon.constants.map(&:to_sym).include?(:Rabl)
65
- raise "Possible wrong require order problem - try to add `gem 'rabl'` before `gem 'gon'` in your Gemfile"
66
- end
67
60
  data, options = Gon::Rabl.handler(args)
68
-
69
61
  store_builder_data 'rabl', data, options
70
62
  end
71
63
 
72
64
  def jbuilder(*args)
73
- unless Gon.constants.map(&:to_sym).include?(:Jbuilder)
74
- raise "Possible wrong require order problem - try to add `gem 'jbuilder'` before `gem 'gon'` in your Gemfile"
75
- end
65
+ ensure_template_handler_is_defined
76
66
  data, options = Gon::Jbuilder.handler(args)
77
-
78
67
  store_builder_data 'jbuilder', data, options
79
68
  end
80
69
 
@@ -106,5 +95,12 @@ class Gon
106
95
  )
107
96
  end
108
97
 
98
+ # JbuilderTemplate will not be defined if jbuilder is required
99
+ # before gon. By loading jbuilder again, JbuilderTemplate will
100
+ # now be defined
101
+ def ensure_template_handler_is_defined
102
+ load 'jbuilder.rb' unless defined?(JbuilderTemplate)
103
+ end
104
+
109
105
  end
110
106
  end
@@ -8,8 +8,7 @@ class Gon
8
8
  data[:global] = Gon.global.all_variables
9
9
  end
10
10
  namespace, tag, cameled, watch = parse_options options
11
- start = "#{tag if tag}window.#{namespace} = {};"
12
- script = ''
11
+ script = "window.#{namespace} = {};"
13
12
 
14
13
  data.each do |key, val|
15
14
  if cameled
@@ -19,9 +18,9 @@ class Gon
19
18
  end
20
19
  end
21
20
 
22
- script = start + Gon::Escaper.escape(script)
23
21
  script << Gon.watch.render if watch and Gon::Watch.all_variables.present?
24
- script << '</script>' if tag
22
+ script = Gon::Escaper.escape_unicode(script)
23
+ script = Gon::Escaper.javascript_tag(script) if tag
25
24
  script.html_safe
26
25
  end
27
26
 
@@ -52,10 +51,9 @@ class Gon
52
51
  def parse_options(options)
53
52
  namespace = options[:namespace] || 'gon'
54
53
  need_tag = options[:need_tag].nil? || options[:need_tag]
55
- need_type = options[:need_type].present? && options[:need_type]
56
54
  cameled = options[:camel_case]
57
55
  watch = options[:watch]
58
- tag = need_tag && (need_type ? '<script type="text/javascript">' : '<script>')
56
+ tag = need_tag
59
57
 
60
58
  [namespace, tag, cameled, watch]
61
59
  end
@@ -1,14 +1,13 @@
1
1
  class Gon
2
2
  module Escaper
3
- class << self
3
+ extend ActionView::Helpers::JavaScriptHelper
4
+ extend ActionView::Helpers::TagHelper
4
5
 
5
- GON_JS_ESCAPE_MAP = {
6
- '</' => '\u003C/'
7
- }
6
+ class << self
8
7
 
9
- def escape(javascript)
8
+ def escape_unicode(javascript)
10
9
  if javascript
11
- result = javascript.gsub(/(<\/)/u) {|match| GON_JS_ESCAPE_MAP[match] }
10
+ result = javascript.gsub(/\342\200\250/u, '&#x2028;')
12
11
  javascript.html_safe? ? result.html_safe : result
13
12
  else
14
13
  ''
@@ -15,20 +15,13 @@ class Gon
15
15
  end
16
16
 
17
17
  def rabl(*args)
18
- unless Gon.constants.include?(:Rabl)
19
- raise "Possible wrong require order problem - try to add `gem 'rabl'` before `gem 'gon'` in your Gemfile"
20
- end
21
18
  data, options = Gon::Rabl.handler(args, true)
22
-
23
19
  store_builder_data 'rabl', data, options
24
20
  end
25
21
 
26
22
  def jbuilder(*args)
27
- unless Gon.constants.include?(:Jbuilder)
28
- raise "Possible wrong require order problem - try to add `gem 'jbuilder'` before `gem 'gon'` in your Gemfile"
29
- end
23
+ ensure_template_handler_is_defined
30
24
  data, options = Gon::Jbuilder.handler(args, true)
31
-
32
25
  store_builder_data 'jbuilder', data, options
33
26
  end
34
27
 
@@ -14,7 +14,8 @@ class Gon
14
14
 
15
15
  data = parse_jbuilder \
16
16
  Gon::Base.get_template_path(options,'jbuilder'),
17
- controller
17
+ controller,
18
+ options[:locals]
18
19
 
19
20
  [data, options]
20
21
  end
@@ -50,12 +51,16 @@ class Gon
50
51
  args.first.is_a? Hash
51
52
  end
52
53
 
53
- def parse_jbuilder(jbuilder_path, controller)
54
+ def parse_jbuilder(jbuilder_path, controller, locals)
54
55
  controller.instance_variables.each do |name|
55
56
  self.instance_variable_set \
56
57
  name,
57
58
  controller.instance_variable_get(name)
58
59
  end
60
+ locals ||= {}
61
+ locals.each do |name, value|
62
+ eval "def #{name}; return #{value}; end"
63
+ end
59
64
  lines = find_partials File.readlines(jbuilder_path)
60
65
  source = lines.join('')
61
66
 
@@ -1,5 +1,13 @@
1
1
  require 'action_view'
2
- require 'rabl'
2
+
3
+ begin
4
+ require 'rabl' # use rabl gem if it's available
5
+ rescue LoadError
6
+ end
7
+ begin
8
+ require 'rabl-rails' # use rabl-rails gem if it's available
9
+ rescue LoadError
10
+ end
3
11
 
4
12
  class Gon
5
13
  module Rabl
@@ -11,8 +19,6 @@ class Gon
11
19
  raise 'You should provide :template when use rabl with global variables'
12
20
  end
13
21
 
14
- include_helpers
15
-
16
22
  data = parse_rabl \
17
23
  Gon::Base.get_template_path(options, 'rabl'),
18
24
  Gon::Base.get_controller(options),
@@ -24,12 +30,33 @@ class Gon
24
30
  private
25
31
 
26
32
  def parse_rabl(rabl_path, controller, locals)
33
+ if defined? ::Rabl
34
+ parse_with_rabl rabl_path, controller, locals
35
+ elsif defined? ::RablRails
36
+ parse_with_rabl_rails rabl_path, controller, locals
37
+ else
38
+ raise 'rabl or rabl-rails must be required in order to use gon.rabl'
39
+ end
40
+ end
41
+
42
+ def parse_with_rabl(rabl_path, controller, locals)
27
43
  locals ||= {}
28
44
  source = File.read(rabl_path)
45
+ include_helpers
29
46
  rabl_engine = ::Rabl::Engine.new(source, :format => 'json')
30
-
31
47
  output = rabl_engine.render(controller, locals)
48
+ JSON.parse(output)
49
+ end
32
50
 
51
+ def parse_with_rabl_rails(rabl_path, controller, locals)
52
+ locals ||= {}
53
+ source = File.read(rabl_path)
54
+ original_formats = controller.formats
55
+ controller.formats = [:json]
56
+ view_context = controller.view_context
57
+ locals.each { |k, v| view_context.assigns[k.to_s] = v }
58
+ output = RablRails::Library.instance.get_rendered_template(source, view_context)
59
+ controller.formats = original_formats
33
60
  JSON.parse(output)
34
61
  end
35
62
 
@@ -1,3 +1,3 @@
1
1
  class Gon
2
- VERSION = '4.0.3'
2
+ VERSION = '4.1.0'
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'gon'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Gon do
4
4
 
@@ -51,7 +51,7 @@ describe Gon do
51
51
  Gon.clear
52
52
 
53
53
  Gon.push({ :int => 1, :string => 'string' })
54
- Gon.all_variables.should == { :int => 1, :string => 'string' }
54
+ Gon.all_variables.should == { 'int' => 1, 'string' => 'string' }
55
55
  end
56
56
 
57
57
  it 'push with wrong object' do
@@ -79,30 +79,42 @@ describe Gon do
79
79
 
80
80
  it 'outputs correct js with an integer' do
81
81
  Gon.int = 1
82
- @base.include_gon.should == '<script>window.gon = {};' +
82
+ @base.include_gon.should == '<script type="text/javascript">' +
83
+ "\n//<![CDATA[\n" +
84
+ 'window.gon = {};' +
83
85
  'gon.int=1;' +
86
+ "\n//]]>\n" +
84
87
  '</script>'
85
88
  end
86
89
 
87
90
  it 'outputs correct js with a string' do
88
91
  Gon.str = %q(a'b"c)
89
- @base.include_gon.should == '<script>window.gon = {};' +
92
+ @base.include_gon.should == '<script type="text/javascript">' +
93
+ "\n//<![CDATA[\n" +
94
+ 'window.gon = {};' +
90
95
  %q(gon.str="a'b\"c";) +
96
+ "\n//]]>\n" +
91
97
  '</script>'
92
98
  end
93
99
 
94
100
  it 'outputs correct js with a script string' do
95
101
  Gon.str = %q(</script><script>alert('!')</script>)
96
- @base.include_gon.should == '<script>window.gon = {};' +
97
- %q(gon.str="\\u003C/script><script>alert('!')\\u003C/script>";) +
102
+ @base.include_gon.should == '<script type="text/javascript">' +
103
+ "\n//<![CDATA[\n" +
104
+ 'window.gon = {};' +
105
+ %q(gon.str="</script><script>alert('!')</script>";) +
106
+ "\n//]]>\n" +
98
107
  '</script>'
99
108
  end
100
109
 
101
110
  it 'outputs correct js with an integer, camel-case and namespace' do
102
111
  Gon.int_cased = 1
103
112
  @base.include_gon(camel_case: true, namespace: 'camel_cased').should == \
104
- '<script>window.camel_cased = {};' +
113
+ '<script type="text/javascript">' +
114
+ "\n//<![CDATA[\n" +
115
+ 'window.camel_cased = {};' +
105
116
  'camel_cased.intCased=1;' +
117
+ "\n//]]>\n" +
106
118
  '</script>'
107
119
  end
108
120
 
@@ -136,7 +148,9 @@ describe Gon do
136
148
  it 'outputs correct js with type text/javascript' do
137
149
  @base.include_gon(need_type: true, init: true).should == \
138
150
  '<script type="text/javascript">' +
151
+ "\n//<![CDATA[\n" +
139
152
  'window.gon = {};'\
153
+ "\n//]]>\n" +
140
154
  '</script>'
141
155
  end
142
156
 
@@ -1,4 +1,4 @@
1
- require 'gon'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Gon::Global do
4
4
 
@@ -45,8 +45,11 @@ describe Gon::Global do
45
45
 
46
46
  it 'outputs correct js with an integer' do
47
47
  Gon.global.int = 1
48
- @base.include_gon.should == "<script>window.gon = {};" +
48
+ @base.include_gon.should == "<script type=\"text/javascript\">" +
49
+ "\n//<![CDATA[\n" +
50
+ "window.gon = {};" +
49
51
  "gon.global={\"int\":1};" +
52
+ "\n//]]>\n" +
50
53
  "</script>"
51
54
  end
52
55
 
@@ -56,23 +59,42 @@ describe Gon::Global do
56
59
  Gon::Request.env = {}
57
60
  Gon.int = 1
58
61
  Gon.global.int = 1
59
- @base.include_gon.should == "<script>window.gon = {};" +
62
+ @base.include_gon.should == "<script type=\"text/javascript\">" +
63
+ "\n//<![CDATA[\n" +
64
+ "window.gon = {};" +
60
65
  "gon.int=1;" +
61
66
  "gon.global={\"int\":1};" +
67
+ "\n//]]>\n" +
62
68
  "</script>"
63
69
  end
64
70
 
65
71
  it 'outputs correct js with a string' do
66
72
  Gon.global.str = %q(a'b"c)
67
- @base.include_gon.should == "<script>window.gon = {};" +
73
+ @base.include_gon.should == "<script type=\"text/javascript\">" +
74
+ "\n//<![CDATA[\n" +
75
+ "window.gon = {};" +
68
76
  "gon.global={\"str\":\"a'b\\\"c\"};" +
77
+ "\n//]]>\n" +
69
78
  "</script>"
70
79
  end
71
80
 
72
81
  it 'outputs correct js with a script string' do
73
82
  Gon.global.str = %q(</script><script>alert('!')</script>)
74
- @base.include_gon.should == "<script>window.gon = {};" +
75
- "gon.global={\"str\":\"\\u003C/script><script>alert('!')\\u003C/script>\"};" +
83
+ @base.include_gon.should == "<script type=\"text/javascript\">" +
84
+ "\n//<![CDATA[\n" +
85
+ "window.gon = {};" +
86
+ "gon.global={\"str\":\"</script><script>alert('!')</script>\"};" +
87
+ "\n//]]>\n" +
88
+ "</script>"
89
+ end
90
+
91
+ it 'outputs correct js with a unicode line separator' do
92
+ Gon.global.str = "\u2028"
93
+ @base.include_gon.should == "<script type=\"text/javascript\">" +
94
+ "\n//<![CDATA[\n" +
95
+ "window.gon = {};" +
96
+ "gon.global={\"str\":\"&#x2028;\"};" +
97
+ "\n//]]>\n" +
76
98
  "</script>"
77
99
  end
78
100
 
@@ -1,5 +1,4 @@
1
- # rabl_spec_rb
2
- require 'gon'
1
+ require 'spec_helper'
3
2
 
4
3
  describe Gon do
5
4
 
@@ -7,9 +6,6 @@ describe Gon do
7
6
  Gon::Request.env = {}
8
7
  end
9
8
 
10
- require 'jbuilder'
11
- require 'gon/jbuilder'
12
-
13
9
  describe '.jbuilder' do
14
10
  context 'render jbuilder templates' do
15
11
 
@@ -26,11 +22,29 @@ describe Gon do
26
22
  Gon.objects.length.should == 2
27
23
  end
28
24
 
29
- it 'render json from jbuilder template with helpers' do
25
+ it 'render json from jbuilder template with locals' do
26
+ Gon.jbuilder 'spec/test_data/sample_with_locals.json.jbuilder', :controller => controller, :locals => { :some_local => 1234 }
27
+ Gon.some_local.should == 1234
28
+ end
29
+
30
+ it 'render json from jbuilder template with locals' do
30
31
  Gon.jbuilder 'spec/test_data/sample_with_helpers.json.jbuilder', :controller => controller
31
32
  Gon.date.should == 'about 6 hours'
32
33
  end
33
34
 
35
+ it 'render json from jbuilder template with controller methods' do
36
+ pending
37
+ controller.instance_eval {
38
+ def private_controller_method
39
+ puts 'gon test helper works'
40
+ end
41
+ private :private_controller_method
42
+ }
43
+
44
+ Gon.jbuilder 'spec/test_data/sample_with_controller_method.json.jbuilder', :controller => controller
45
+ Gon.date.should == 'about 6 hours'
46
+ end
47
+
34
48
  it 'render json from jbuilder template with a partial' do
35
49
  controller.view_paths << 'spec/test_data'
36
50
  Gon.jbuilder 'spec/test_data/sample_with_partial.json.jbuilder', :controller => controller
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gon do
4
+
5
+ before(:all) do
6
+ ensure_rabl_rails_is_loaded
7
+ end
8
+
9
+ before(:each) do
10
+ Gon::Request.env = {}
11
+ end
12
+
13
+ describe '.rabl with rabl-rails gem' do
14
+
15
+ before :each do
16
+ Gon.clear
17
+ controller.instance_variable_set('@objects', objects)
18
+ controller.request = ActionDispatch::TestRequest.new
19
+ end
20
+
21
+ let(:controller) { ActionController::Base.new }
22
+ let(:objects) { [1,2] }
23
+
24
+ context 'render template with deprecation' do
25
+ it 'still works' do
26
+ Gon.rabl 'spec/test_data/sample_rabl_rails.rabl', :controller => controller
27
+ Gon.objects.length.should == 2
28
+ end
29
+ end
30
+
31
+ context 'option locals' do
32
+ it 'works without locals object properly' do
33
+ Gon.rabl(
34
+ :template =>'spec/test_data/sample_rabl_rails.rabl',
35
+ :controller => controller
36
+ )
37
+ Gon.objects.map { |it| it['inspect'] }.should == ['1', '2']
38
+ end
39
+
40
+ it 'works with different locals object' do
41
+ Gon.rabl(
42
+ :template =>'spec/test_data/sample_rabl_rails.rabl',
43
+ :controller => controller,
44
+ :locals => { :objects => [3, 4] }
45
+ )
46
+ Gon.objects.map { |it| it['inspect'] }.should == ['3', '4']
47
+ end
48
+ end
49
+
50
+ it 'works if rabl-rails is included' do
51
+ Gon.rabl :template =>'spec/test_data/sample_rabl_rails.rabl', :controller => controller
52
+ Gon.objects.length.should == 2
53
+ end
54
+
55
+ it 'works with ActionView::Helpers' do
56
+ Gon.rabl :template =>'spec/test_data/sample_with_helpers_rabl_rails.rabl', :controller => controller
57
+ Gon.objects.first['time_ago'].should == 'about 6 hours'
58
+ end
59
+
60
+ it 'raise exception if rabl or rabl-rails is not included' do
61
+ Object.send :remove_const, :RablRails # ensure_rabl_rails_is_loaded method already removed Rabl
62
+ expect { Gon.rabl :template =>'spec/test_data/sample.rabl', :controller => controller}.to raise_error
63
+ ensure_rabl_rails_is_loaded # load up rabl-rails again, we're not done testing
64
+ end
65
+
66
+ end
67
+
68
+ end
@@ -1,7 +1,10 @@
1
- # rabl_spec_rb
2
- require 'gon'
1
+ require 'spec_helper'
3
2
 
4
3
  describe Gon do
4
+
5
+ before(:all) do
6
+ ensure_rabl_is_loaded
7
+ end
5
8
 
6
9
  before(:each) do
7
10
  Gon::Request.env = {}
@@ -9,9 +12,6 @@ describe Gon do
9
12
 
10
13
  describe '.rabl' do
11
14
 
12
- require 'rabl'
13
- require 'gon/rabl'
14
-
15
15
  before :each do
16
16
  Gon.clear
17
17
  controller.instance_variable_set('@objects', objects)
@@ -1,5 +1,4 @@
1
- # rabl_spec_rb
2
- require 'gon'
1
+ require 'spec_helper'
3
2
 
4
3
  describe Gon do
5
4
 
@@ -7,11 +6,6 @@ describe Gon do
7
6
  Gon::Request.env = {}
8
7
  end
9
8
 
10
- require 'jbuilder'
11
- require 'gon/jbuilder'
12
- require 'rabl'
13
- require 'gon/rabl'
14
-
15
9
  describe '.get_template_path' do
16
10
  context 'template is specified' do
17
11
 
@@ -1,4 +1,4 @@
1
- require 'gon'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Gon::Watch do
4
4
 
@@ -0,0 +1,39 @@
1
+ require 'gon'
2
+ require 'jbuilder'
3
+ require 'rabl'
4
+ require 'rabl-rails'
5
+
6
+ # rabl has a conflict with rabl-rails as rabl-rails causes Rails
7
+ # to be defined. In order to run all specs at once, we'll need to
8
+ # load/unload rabl and rabl-rails whenever we switch from testing
9
+ # one to another.
10
+ def ensure_rabl_is_loaded
11
+ Object.send(:remove_const, :RablRails) if defined? RablRails
12
+ Object.send(:remove_const, :Rails) if defined? Rails
13
+ unless defined? Rabl
14
+ load 'rabl.rb'
15
+ load 'rabl/version.rb'
16
+ load 'rabl/helpers.rb'
17
+ load 'rabl/partials.rb'
18
+ load 'rabl/engine.rb'
19
+ load 'rabl/builder.rb'
20
+ load 'rabl/configuration.rb'
21
+ load 'rabl/renderer.rb'
22
+ load 'rabl/cache_engine.rb'
23
+ end
24
+ end
25
+
26
+ # Unloads rabl and loads rabl-rails.
27
+ def ensure_rabl_rails_is_loaded
28
+ Object.send(:remove_const, :Rabl) if defined? Rabl
29
+ unless defined? RablRails
30
+ load 'rabl-rails/template.rb'
31
+ load 'rabl-rails/condition.rb'
32
+ load 'rabl-rails/compiler.rb'
33
+ load 'rabl-rails/renderers/base.rb'
34
+ load 'rabl-rails/renderers/json.rb'
35
+ load 'rabl-rails/renderer.rb'
36
+ load 'rabl-rails/library.rb'
37
+ load 'rabl-rails.rb'
38
+ end
39
+ end
@@ -0,0 +1,2 @@
1
+ collection :@objects => 'objects'
2
+ attributes :inspect
@@ -0,0 +1 @@
1
+ json.objects @objects
@@ -0,0 +1,3 @@
1
+ collection :@objects => 'objects'
2
+ attributes :inspect
3
+ node(:time_ago) { distance_of_time_in_words(20000) }
@@ -0,0 +1 @@
1
+ json.some_local some_local
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gon
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-14 00:00:00.000000000 Z
12
+ date: 2013-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rabl-rails
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: rspec
64
80
  requirement: !ruby/object:Gem::Requirement
@@ -140,14 +156,20 @@ files:
140
156
  - spec/gon/basic_spec.rb
141
157
  - spec/gon/global_spec.rb
142
158
  - spec/gon/jbuilder_spec.rb
143
- - spec/gon/rabl_spec.rb
159
+ - spec/gon/rabl_with_rabl_rails_spec.rb
160
+ - spec/gon/rabl_with_rabl_spec.rb
144
161
  - spec/gon/templates_spec.rb
145
162
  - spec/gon/watch_spec.rb
163
+ - spec/spec_helper.rb
146
164
  - spec/test_data/_sample_partial.json.jbuilder
147
165
  - spec/test_data/sample.json.jbuilder
148
166
  - spec/test_data/sample.rabl
167
+ - spec/test_data/sample_rabl_rails.rabl
168
+ - spec/test_data/sample_with_controller_method.json.jbuilder
149
169
  - spec/test_data/sample_with_helpers.json.jbuilder
150
170
  - spec/test_data/sample_with_helpers.rabl
171
+ - spec/test_data/sample_with_helpers_rabl_rails.rabl
172
+ - spec/test_data/sample_with_locals.json.jbuilder
151
173
  - spec/test_data/sample_with_partial.json.jbuilder
152
174
  homepage: https://github.com/gazay/gon
153
175
  licenses: []
@@ -177,12 +199,18 @@ test_files:
177
199
  - spec/gon/basic_spec.rb
178
200
  - spec/gon/global_spec.rb
179
201
  - spec/gon/jbuilder_spec.rb
180
- - spec/gon/rabl_spec.rb
202
+ - spec/gon/rabl_with_rabl_rails_spec.rb
203
+ - spec/gon/rabl_with_rabl_spec.rb
181
204
  - spec/gon/templates_spec.rb
182
205
  - spec/gon/watch_spec.rb
206
+ - spec/spec_helper.rb
183
207
  - spec/test_data/_sample_partial.json.jbuilder
184
208
  - spec/test_data/sample.json.jbuilder
185
209
  - spec/test_data/sample.rabl
210
+ - spec/test_data/sample_rabl_rails.rabl
211
+ - spec/test_data/sample_with_controller_method.json.jbuilder
186
212
  - spec/test_data/sample_with_helpers.json.jbuilder
187
213
  - spec/test_data/sample_with_helpers.rabl
214
+ - spec/test_data/sample_with_helpers_rabl_rails.rabl
215
+ - spec/test_data/sample_with_locals.json.jbuilder
188
216
  - spec/test_data/sample_with_partial.json.jbuilder