jsonify-rails 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  pkg/
2
+ Gemfile*.lock
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 1.9.2
4
+ - 1.8.7
5
+ - jruby
6
+ - rbx-2.0
7
+ env:
8
+ - RAILS_VERSION='~>3.0.0'
9
+ - RAILS_VERSION='>=3.1.0'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Jsonify-Rails — Jsonify templates for Rails views
1
+ # Jsonify-Rails — Jsonify templates for Rails views [![Build Status](https://secure.travis-ci.org/bsiggelkow/jsonify-rails.png)](http://travis-ci.org/bsiggelkow/jsonify-rails)
2
2
 
3
3
  [Jsonify](https://github.com/bsiggelkow/jsonify) is to JSON as [Builder](https://github.com/jimweirich/builder) is to XML.
4
4
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  ## Usage
10
10
 
11
- Jsonify-rails provides a Rails 3 template handler allowing you to create
11
+ Jsonify-Rails provides a Rails 3 template handler allowing you to create
12
12
  view templates using Jsonify. Any template with a `.jsonify` will be handled by Rails.
13
13
 
14
14
  The Jsonify template handler exposes a `Jsonify::Builder` instance to your template with the `json` variable:
@@ -18,10 +18,12 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_dependency 'jsonify'
21
- s.add_dependency "actionpack", ">= 3.0.0"
21
+ s.add_dependency "actionpack"
22
22
 
23
23
  s.add_development_dependency 'bundler'
24
24
  s.add_development_dependency 'rake'
25
25
  s.add_development_dependency 'rspec'
26
- s.add_development_dependency 'autotest'
26
+ s.add_development_dependency 'json' unless RUBY_VERSION =~ /^1.9/
27
+ s.add_development_dependency 'rails', ENV["RAILS_VERSION"] || ">= 3.1.0"
28
+
27
29
  end
@@ -1,4 +1,4 @@
1
1
  module JsonifyRails
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
4
4
 
@@ -0,0 +1 @@
1
+ json.hello 'world'
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Jsonify template handler' do
4
+
5
+ Handler = ActionView::Template::Handlers::JsonifyBuilder
6
+ ViewTemplate = Struct.new(:source)
7
+
8
+ let( :handler ) { Handler.new }
9
+
10
+ let( :template ) do
11
+ ViewTemplate.new("json.hello 'world'")
12
+ end
13
+
14
+ context "#{Rails.version}" do
15
+ before do
16
+ Rails.stub_chain(:application, :config, :jsonify_format).and_return( :plain )
17
+ end
18
+
19
+ it 'should use JSON as its default output format' do
20
+ handler.default_format.should == Mime::JSON
21
+ end
22
+
23
+ it 'should compile to JSON' do
24
+ result = eval( Handler.call template )
25
+ result.should == '{"hello":"world"}'
26
+ end
27
+
28
+ describe 'when configured with ' do
29
+ def expect_format(format)
30
+ Jsonify::Builder.should_receive(:new).with({:format => format}).and_return( double("json").as_null_object )
31
+ end
32
+
33
+ describe 'pretty' do
34
+ before do
35
+ Rails.stub_chain(:application, :config, :jsonify_format).and_return( :pretty )
36
+ end
37
+
38
+ it 'should pass pretty to the builder' do
39
+ expect_format :pretty
40
+ eval( Handler.call template )
41
+ end
42
+ end
43
+
44
+ describe 'plain' do
45
+ before do
46
+ Rails.stub_chain(:application, :config, :jsonify_format).and_return( :plain )
47
+ end
48
+
49
+ it 'should pass plain to the builder' do
50
+ expect_format :plain
51
+ eval( Handler.call template )
52
+ end
53
+ end
54
+
55
+ describe 'nothing' do
56
+ before do
57
+ Rails.stub_chain(:application, :config)
58
+ end
59
+
60
+ it 'should pass plain to the builder' do
61
+ expect_format :plain
62
+ eval( Handler.call template )
63
+ end
64
+ end
65
+
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ require 'bundler/setup'
3
+ require 'rails'
4
+ require 'jsonify'
5
+ require 'jsonify-rails'
6
+
7
+ RSpec.configure do |config|
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonify-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-24 00:00:00.000000000Z
12
+ date: 2011-09-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonify
16
- requirement: &70364471270120 !ruby/object:Gem::Requirement
16
+ requirement: &70305339425400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70364471270120
24
+ version_requirements: *70305339425400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: actionpack
27
- requirement: &70364471268940 !ruby/object:Gem::Requirement
27
+ requirement: &70305339422980 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 3.0.0
32
+ version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70364471268940
35
+ version_requirements: *70305339422980
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70364471267240 !ruby/object:Gem::Requirement
38
+ requirement: &70305339420840 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70364471267240
46
+ version_requirements: *70305339420840
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70364471266000 !ruby/object:Gem::Requirement
49
+ requirement: &70305339418960 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70364471266000
57
+ version_requirements: *70305339418960
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70364471264500 !ruby/object:Gem::Requirement
60
+ requirement: &70305339417380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,18 +65,18 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70364471264500
68
+ version_requirements: *70305339417380
69
69
  - !ruby/object:Gem::Dependency
70
- name: autotest
71
- requirement: &70364471263320 !ruby/object:Gem::Requirement
70
+ name: rails
71
+ requirement: &70305339413680 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: 3.1.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70364471263320
79
+ version_requirements: *70305339413680
80
80
  description: Use Jsonify for Rails View templates
81
81
  email:
82
82
  - bsiggelkow@me.com
@@ -85,8 +85,8 @@ extensions: []
85
85
  extra_rdoc_files: []
86
86
  files:
87
87
  - .gitignore
88
+ - .travis.yml
88
89
  - Gemfile
89
- - Gemfile.lock
90
90
  - LICENSE
91
91
  - README.md
92
92
  - Rakefile
@@ -94,6 +94,9 @@ files:
94
94
  - lib/jsonify-rails.rb
95
95
  - lib/jsonify-rails/jsonify_builder.rb
96
96
  - lib/jsonify-rails/version.rb
97
+ - spec/fixtures/views/simple_test.jsonify
98
+ - spec/jsonify_builder_spec.rb
99
+ - spec/spec_helper.rb
97
100
  homepage: http://github.com/bsiggelkow/jsonify-rails
98
101
  licenses: []
99
102
  post_install_message:
@@ -108,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
111
  version: '0'
109
112
  segments:
110
113
  - 0
111
- hash: -608692392966390194
114
+ hash: 739529915353472655
112
115
  required_rubygems_version: !ruby/object:Gem::Requirement
113
116
  none: false
114
117
  requirements:
@@ -117,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
120
  version: '0'
118
121
  segments:
119
122
  - 0
120
- hash: -608692392966390194
123
+ hash: 739529915353472655
121
124
  requirements: []
122
125
  rubyforge_project: jsonify-rails
123
126
  rubygems_version: 1.8.6
data/Gemfile.lock DELETED
@@ -1,63 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- jsonify-rails (0.1.0)
5
- actionpack (>= 3.0.0)
6
- jsonify
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- ZenTest (4.6.0)
12
- abstract (1.0.0)
13
- actionpack (3.0.9)
14
- activemodel (= 3.0.9)
15
- activesupport (= 3.0.9)
16
- builder (~> 2.1.2)
17
- erubis (~> 2.6.6)
18
- i18n (~> 0.5.0)
19
- rack (~> 1.2.1)
20
- rack-mount (~> 0.6.14)
21
- rack-test (~> 0.5.7)
22
- tzinfo (~> 0.3.23)
23
- activemodel (3.0.9)
24
- activesupport (= 3.0.9)
25
- builder (~> 2.1.2)
26
- i18n (~> 0.5.0)
27
- activesupport (3.0.9)
28
- autotest (4.4.6)
29
- ZenTest (>= 4.4.1)
30
- builder (2.1.2)
31
- diff-lcs (1.1.2)
32
- erubis (2.6.6)
33
- abstract (>= 1.0.0)
34
- i18n (0.5.0)
35
- json (1.5.3)
36
- jsonify (0.0.4)
37
- actionpack (~> 3.0.0)
38
- json
39
- rack (1.2.3)
40
- rack-mount (0.6.14)
41
- rack (>= 1.0.0)
42
- rack-test (0.5.7)
43
- rack (>= 1.0)
44
- rake (0.9.2)
45
- rspec (2.6.0)
46
- rspec-core (~> 2.6.0)
47
- rspec-expectations (~> 2.6.0)
48
- rspec-mocks (~> 2.6.0)
49
- rspec-core (2.6.4)
50
- rspec-expectations (2.6.0)
51
- diff-lcs (~> 1.1.2)
52
- rspec-mocks (2.6.0)
53
- tzinfo (0.3.29)
54
-
55
- PLATFORMS
56
- ruby
57
-
58
- DEPENDENCIES
59
- autotest
60
- bundler
61
- jsonify-rails!
62
- rake
63
- rspec