gon 2.3.0 → 3.0.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.

@@ -0,0 +1,3 @@
1
+ collection @objects => 'objects'
2
+ attributes :id
3
+ node(:time_ago) { |_| distance_of_time_in_words(20000) }
metadata CHANGED
@@ -1,120 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gon
3
- version: !ruby/object:Gem::Version
4
- hash: 3
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 3
9
- - 0
10
- version: 2.3.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - gazay
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-04-03 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-04-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: actionpack
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70115770420460 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 2
31
- - 3
32
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 2.3.0
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: json
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70115770420460
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &70115770419320 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
48
33
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: rabl
52
34
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70115770419320
36
+ - !ruby/object:Gem::Dependency
37
+ name: rabl
38
+ requirement: &70115770417920 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
62
44
  type: :development
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: rspec
66
45
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70115770417920
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70115770393760 !ruby/object:Gem::Requirement
68
50
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
76
55
  type: :development
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
79
- name: jbuilder
80
56
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70115770393760
58
+ - !ruby/object:Gem::Dependency
59
+ name: jbuilder
60
+ requirement: &70115770399640 !ruby/object:Gem::Requirement
82
61
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
90
66
  type: :development
91
- version_requirements: *id005
92
- - !ruby/object:Gem::Dependency
93
- name: rake
94
67
  prerelease: false
95
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *70115770399640
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &70115770398500 !ruby/object:Gem::Requirement
96
72
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
104
77
  type: :development
105
- version_requirements: *id006
106
- description: 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!
107
- email:
78
+ prerelease: false
79
+ version_requirements: *70115770398500
80
+ description: If you need to send some data to your js files and you don't want to
81
+ do this with long way trough views and parsing - use this force!
82
+ email:
108
83
  - alex.gaziev@gmail.com
109
84
  executables: []
110
-
111
85
  extensions: []
112
-
113
86
  extra_rdoc_files: []
114
-
115
- files:
87
+ files:
116
88
  - .gitignore
117
89
  - .travis.yml
90
+ - CHANGELOG.md
118
91
  - Gemfile
119
92
  - README.md
120
93
  - Rakefile
@@ -122,52 +95,56 @@ files:
122
95
  - doc/logo_small.png
123
96
  - gon.gemspec
124
97
  - lib/gon.rb
98
+ - lib/gon/base.rb
125
99
  - lib/gon/escaper.rb
100
+ - lib/gon/global.rb
126
101
  - lib/gon/helpers.rb
127
102
  - lib/gon/jbuilder.rb
128
103
  - lib/gon/rabl.rb
104
+ - lib/gon/request.rb
129
105
  - lib/gon/version.rb
130
- - spec/gon/gon_spec.rb
106
+ - spec/gon/basic_spec.rb
107
+ - spec/gon/global_spec.rb
108
+ - spec/gon/jbuilder_spec.rb
109
+ - spec/gon/rabl_spec.rb
110
+ - spec/gon/templates_spec.rb
131
111
  - spec/test_data/_sample_partial.json.jbuilder
132
112
  - spec/test_data/sample.json.jbuilder
133
113
  - spec/test_data/sample.rabl
114
+ - spec/test_data/sample_with_helpers.rabl
134
115
  - spec/test_data/sample_with_partial.json.jbuilder
135
116
  homepage: https://github.com/gazay/gon
136
117
  licenses: []
137
-
138
118
  post_install_message:
139
119
  rdoc_options: []
140
-
141
- require_paths:
120
+ require_paths:
142
121
  - lib
143
- required_ruby_version: !ruby/object:Gem::Requirement
122
+ required_ruby_version: !ruby/object:Gem::Requirement
144
123
  none: false
145
- requirements:
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- hash: 3
149
- segments:
150
- - 0
151
- version: "0"
152
- required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
129
  none: false
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- hash: 3
158
- segments:
159
- - 0
160
- version: "0"
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
161
134
  requirements: []
162
-
163
135
  rubyforge_project: gon
164
- rubygems_version: 1.8.15
136
+ rubygems_version: 1.8.17
165
137
  signing_key:
166
138
  specification_version: 3
167
139
  summary: Get your Rails variables in your JS
168
- test_files:
169
- - spec/gon/gon_spec.rb
140
+ test_files:
141
+ - spec/gon/basic_spec.rb
142
+ - spec/gon/global_spec.rb
143
+ - spec/gon/jbuilder_spec.rb
144
+ - spec/gon/rabl_spec.rb
145
+ - spec/gon/templates_spec.rb
170
146
  - spec/test_data/_sample_partial.json.jbuilder
171
147
  - spec/test_data/sample.json.jbuilder
172
148
  - spec/test_data/sample.rabl
149
+ - spec/test_data/sample_with_helpers.rabl
173
150
  - spec/test_data/sample_with_partial.json.jbuilder
@@ -1,215 +0,0 @@
1
- # gon_spec_rb
2
- require 'gon'
3
-
4
- describe Gon do
5
-
6
- before(:each) do
7
- Gon.request_env = {}
8
- end
9
-
10
- describe '#all_variables' do
11
-
12
- it 'returns all variables in hash' do
13
- Gon.a = 1
14
- Gon.b = 2
15
- Gon.c = Gon.a + Gon.b
16
- Gon.c.should == 3
17
- Gon.all_variables.should == {'a' => 1, 'b' => 2, 'c' => 3}
18
- end
19
-
20
- it 'supports all data types' do
21
- Gon.clear
22
- Gon.int = 1
23
- Gon.float = 1.1
24
- Gon.string = 'string'
25
- Gon.array = [ 1, 'string' ]
26
- Gon.hash_var = { :a => 1, :b => '2'}
27
- Gon.hash_w_array = { :a => [ 2, 3 ] }
28
- Gon.klass = Hash
29
- end
30
-
31
- end
32
-
33
- describe '#include_gon' do
34
-
35
- before(:each) do
36
- Gon.clear
37
- Gon.instance_variable_set(:@request_id, request.object_id)
38
- ActionView::Base.instance_methods.map(&:to_s).include?('include_gon').should == true
39
- @base = ActionView::Base.new
40
- @base.request = request
41
- end
42
-
43
- it 'outputs correct js with an integer' do
44
- Gon.int = 1
45
- @base.include_gon.should == '<script>window.gon = {};' +
46
- 'gon.int=1;' +
47
- '</script>'
48
- end
49
-
50
- it 'outputs correct js with a string' do
51
- Gon.str = %q(a'b"c)
52
- @base.include_gon.should == '<script>window.gon = {};' +
53
- %q(gon.str="a'b\"c";) +
54
- '</script>'
55
- end
56
-
57
- it 'outputs correct js with a script string' do
58
- Gon.str = %q(</script><script>alert('!')</script>)
59
- @base.include_gon.should == '<script>window.gon = {};' +
60
- %q(gon.str="<\\/script><script>alert('!')<\\/script>";) +
61
- '</script>'
62
- end
63
-
64
- end
65
-
66
- it 'returns exception if try to set public method as variable' do
67
- Gon.clear
68
- lambda { Gon.all_variables = 123 }.should raise_error
69
- lambda { Gon.rabl = 123 }.should raise_error
70
- lambda { Gon.request = 123 }.should raise_error
71
- end
72
-
73
- describe '.rabl' do
74
-
75
- require 'rabl'
76
- require 'gon/rabl'
77
-
78
- before :each do
79
- Gon.clear
80
- controller.instance_variable_set('@objects', objects)
81
- end
82
-
83
- let(:controller) { ActionController::Base.new }
84
- let(:objects) { [1,2] }
85
-
86
- context 'render template with deprecation' do
87
- it 'still works' do
88
- Gon.rabl 'spec/test_data/sample.rabl', :controller => controller
89
- Gon.objects.length.should == 2
90
- end
91
- end
92
-
93
- it 'works if rabl is included' do
94
- Gon.rabl :template =>'spec/test_data/sample.rabl', :controller => controller
95
- Gon.objects.length.should == 2
96
- end
97
-
98
- it 'raise exception if rabl is not included' do
99
- Gon.send :remove_const, 'Rabl'
100
- expect { Gon.rabl :template =>'spec/test_data/sample.rabl', :controller => controller}.to raise_error
101
- load 'rabl.rb'
102
- load 'gon/rabl.rb'
103
- end
104
-
105
- context '.get_template_path' do
106
- context 'template is specified' do
107
-
108
- it 'add the extension if not included in the template name' do
109
- Gon.send(:get_template_path, { :template => 'spec/test_data/sample'}, 'rabl').should eql('spec/test_data/sample.rabl')
110
- end
111
-
112
- it 'return the specified template' do
113
- Gon.send(:get_template_path, { :template => 'spec/test_data/sample.rabl'}, 'rabl').should eql('spec/test_data/sample.rabl')
114
- end
115
-
116
- end
117
-
118
- context 'template is not specified' do
119
-
120
- before do
121
- Gon.clear
122
- controller.instance_variable_set('@objects', objects)
123
- controller.action_name = 'show'
124
- end
125
-
126
- let(:controller) { ActionController::Base.new }
127
- let(:objects) { [1,2] }
128
-
129
- context 'the action doesn as a template at a different format' do
130
- it 'return the same template as the action with rabl extension' do
131
- Gon.send(:get_template_path, {:controller => controller}, 'rabl').should eql('app/views/action_controller/base/show.json.rabl')
132
- end
133
- end
134
-
135
- end
136
- end
137
-
138
- end
139
-
140
- require 'jbuilder'
141
- require 'gon/jbuilder'
142
-
143
- describe '.jbuilder' do
144
- context 'render jbuilder templates' do
145
-
146
- before do
147
- Gon.clear
148
- controller.instance_variable_set('@objects', objects)
149
- end
150
-
151
- let(:controller) { ActionController::Base.new }
152
- let(:objects) { [1,2] }
153
-
154
- it 'render json from jbuilder template' do
155
- Gon.jbuilder 'spec/test_data/sample.json.jbuilder', :controller => controller
156
- Gon.objects.length.should == 2
157
- end
158
-
159
- it 'render json from jbuilder template with a partial' do
160
- controller.view_paths << 'spec/test_data'
161
- Gon.jbuilder 'spec/test_data/sample_with_partial.json.jbuilder', :controller => controller
162
- Gon.objects.length.should == 2
163
- end
164
-
165
- end
166
-
167
- it 'should raise error if you use gon.jbuilder without requiring jbuilder gem' do
168
- Gon.send(:remove_const, :Jbuilder)
169
-
170
- expect { Gon.jbuilder 'some_path' }.to raise_error(NoMethodError, /Gemfile/)
171
- load 'jbuilder.rb'
172
- load 'gon/jbuilder.rb'
173
- end
174
-
175
- end
176
-
177
- describe '.get_template_path' do
178
- context 'template is specified' do
179
-
180
- it 'add the extension if not included in the template name' do
181
- Gon.send(:get_template_path, { :template => 'spec/test_data/sample'}, 'jbuilder').should eql('spec/test_data/sample.jbuilder')
182
- end
183
-
184
- it 'return the specified template' do
185
- Gon.send(:get_template_path, { :template => 'spec/test_data/sample.jbuilder'}, 'jbuilder').should eql('spec/test_data/sample.jbuilder')
186
- end
187
-
188
- end
189
-
190
- context 'template is not specified' do
191
-
192
- before do
193
- Gon.clear
194
- controller.instance_variable_set('@objects', objects)
195
- controller.action_name = 'show'
196
- end
197
-
198
- let(:controller) { ActionController::Base.new }
199
- let(:objects) { [1,2] }
200
-
201
- context 'the action doesn as a template at a different format' do
202
- it 'return the same template as the action with rabl extension' do
203
- Gon.send(:get_template_path, {:controller => controller}, 'jbuilder').should eql('app/views/action_controller/base/show.json.jbuilder')
204
- end
205
- end
206
-
207
- end
208
- end
209
-
210
-
211
- def request
212
- @request ||= double 'request', :env => {}
213
- end
214
-
215
- end