tilt-jbuilder 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -0
- data/README.md +1 -1
- data/lib/tilt/jbuilder.rb +1 -1
- data/spec/sinatra_integration_spec.rb +9 -35
- data/spec/spec_helper.rb +23 -0
- data/spec/support/sinatra_integration_test_methods.rb +20 -0
- data/spec/{views → support/views}/_partial_with_helper_method.jbuilder +0 -0
- data/spec/{views → support/views}/_partial_with_instance_variable.jbuilder +0 -0
- data/spec/{views → support/views}/_partial_with_local_variable.jbuilder +0 -0
- data/spec/{views → support/views}/hello.jbuilder +0 -0
- data/spec/tilt-jbuilder_spec.rb +1 -2
- data/tilt-jbuilder.gemspec +1 -5
- metadata +14 -67
- data/README.rdoc +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbad149dd5adf4648e16316d17748b3b959b9690
|
4
|
+
data.tar.gz: b19aa84f1aaa2c6b3c9c3215efb9cf7ead889e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe4111cedf0babbfc9e93e3032fbf28ca1266823753f6d5a5c3158a3a3e157f1161074c137fa907538b721e19845a0fbe243ac7bdd9c569b5bba21d26d161d29
|
7
|
+
data.tar.gz: 6de5c2d2df203eb5c91970b317ca373c42b1bd5a46d6b3f66095354067531860e383223a0a6ff9d185077e842a841194603bb962a29234416764080f21133bb9
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Adds support for rendering Jbuilder templates using Tilt.
|
4
4
|
|
5
|
-
[![Build Status](https://secure.travis-ci.org/anthonator/tilt-jbuilder.png)](http://travis-ci.org/anthonator/tilt-jbuilder)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/tilt-jbuilder.png)](http://badge.fury.io/rb/tilt-jbuilder) [![Build Status](https://secure.travis-ci.org/anthonator/tilt-jbuilder.png)](http://travis-ci.org/anthonator/tilt-jbuilder) [![Dependency Status](https://gemnasium.com/anthonator/tilt-jbuilder.png)](https://gemnasium.com/anthonator/tilt-jbuilder) [![Coverage Status](https://coveralls.io/repos/anthonator/tilt-jbuilder/badge.png?branch=master)](https://coveralls.io/r/anthonator/tilt-jbuilder?branch=master) [![Code Climate](https://codeclimate.com/github/anthonator/tilt-jbuilder.png)](https://codeclimate.com/github/anthonator/tilt-jbuilder)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
data/lib/tilt/jbuilder.rb
CHANGED
@@ -67,7 +67,7 @@ module Tilt
|
|
67
67
|
|
68
68
|
private
|
69
69
|
def set_locals(locals, scope, context)
|
70
|
-
view_path = options
|
70
|
+
view_path = options[:view_path]
|
71
71
|
scope.send(:instance_variable_set, '@_jbuilder_view_path', view_path)
|
72
72
|
scope.send(:instance_variable_set, '@_jbuilder_locals', locals)
|
73
73
|
scope.send(:instance_variable_set, '@_tilt_data', data)
|
@@ -1,38 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require "tilt/jbuilder"
|
3
|
-
require "sinatra/jbuilder"
|
4
|
-
|
5
|
-
require "rack/test"
|
6
|
-
require "sinatra/base"
|
7
|
-
|
8
|
-
ENV['RACK_ENV'] ||= "test"
|
9
|
-
Sinatra::Base.set :environment, :test
|
10
|
-
|
11
|
-
module SinatraIntegrationTestMethods
|
12
|
-
def jbuilder_app(&block)
|
13
|
-
@app = Sinatra.new(Sinatra::Base) do
|
14
|
-
set :views, File.dirname(__FILE__) + "/views"
|
15
|
-
helpers do
|
16
|
-
def admin?; false end
|
17
|
-
end
|
18
|
-
get("/", &block)
|
19
|
-
end
|
20
|
-
get "/"
|
21
|
-
end
|
22
|
-
|
23
|
-
def app
|
24
|
-
Rack::Lint.new(@app)
|
25
|
-
end
|
26
|
-
|
27
|
-
def body
|
28
|
-
last_response.body.to_s
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
RSpec.configure do |config|
|
33
|
-
config.include Rack::Test::Methods
|
34
|
-
config.include SinatraIntegrationTestMethods
|
35
|
-
end
|
1
|
+
require 'spec_helper'
|
36
2
|
|
37
3
|
describe "Sinatra Integration" do
|
38
4
|
it "renders inline jbuilder strings" do
|
@@ -74,4 +40,12 @@ describe "Sinatra Integration" do
|
|
74
40
|
jbuilder_app { jbuilder "json.partial! :partial_with_local_variable, last_name: \"Smith\"", :scope => Object.new }
|
75
41
|
body.should == "{\"last_name\":\"Smith\"}"
|
76
42
|
end
|
43
|
+
|
44
|
+
it "renders partials multiple times" do
|
45
|
+
lambda do
|
46
|
+
2.times do
|
47
|
+
jbuilder_app { jbuilder "json.partial! :partial_with_local_variable, last_name: \"Smith\"" }
|
48
|
+
end
|
49
|
+
end.should_not raise_error ArgumentError
|
50
|
+
end
|
77
51
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
4
|
+
SimpleCov::Formatter::HTMLFormatter,
|
5
|
+
Coveralls::SimpleCov::Formatter
|
6
|
+
]
|
7
|
+
SimpleCov.start
|
8
|
+
|
9
|
+
ENV['RACK_ENV'] ||= "test"
|
10
|
+
|
11
|
+
require 'tilt/jbuilder'
|
12
|
+
require 'sinatra/jbuilder'
|
13
|
+
require 'rack/test'
|
14
|
+
require 'sinatra/base'
|
15
|
+
|
16
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
17
|
+
|
18
|
+
Sinatra::Base.set :environment, :test
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.include Rack::Test::Methods
|
22
|
+
config.include SinatraIntegrationTestMethods
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SinatraIntegrationTestMethods
|
2
|
+
def jbuilder_app(&block)
|
3
|
+
@app = Sinatra.new(Sinatra::Base) do
|
4
|
+
set :views, File.dirname(__FILE__) + "/views"
|
5
|
+
helpers do
|
6
|
+
def admin?; false end
|
7
|
+
end
|
8
|
+
get("/", &block)
|
9
|
+
end
|
10
|
+
get "/"
|
11
|
+
end
|
12
|
+
|
13
|
+
def app
|
14
|
+
Rack::Lint.new(@app)
|
15
|
+
end
|
16
|
+
|
17
|
+
def body
|
18
|
+
last_response.body.to_s
|
19
|
+
end
|
20
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/tilt-jbuilder_spec.rb
CHANGED
data/tilt-jbuilder.gemspec
CHANGED
@@ -8,15 +8,11 @@ Gem::Specification.new do |gem|
|
|
8
8
|
|
9
9
|
gem.add_dependency 'tilt'
|
10
10
|
gem.add_dependency 'jbuilder'
|
11
|
-
gem.add_development_dependency 'rake'
|
12
|
-
gem.add_development_dependency 'rspec'
|
13
|
-
gem.add_development_dependency 'rack-test'
|
14
|
-
gem.add_development_dependency 'sinatra'
|
15
11
|
|
16
12
|
gem.files = `git ls-files`.split($\)
|
17
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
15
|
gem.name = "tilt-jbuilder"
|
20
16
|
gem.require_paths = ["lib"]
|
21
|
-
gem.version = '0.5.
|
17
|
+
gem.version = '0.5.2'
|
22
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tilt-jbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|
@@ -38,62 +38,6 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rack-test
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: sinatra
|
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
41
|
description: Jbuilder support for Tilt
|
98
42
|
email:
|
99
43
|
- anthony@sticksnleaves.com
|
@@ -106,17 +50,18 @@ files:
|
|
106
50
|
- Gemfile
|
107
51
|
- LICENSE
|
108
52
|
- README.md
|
109
|
-
- README.rdoc
|
110
53
|
- Rakefile
|
111
54
|
- lib/sinatra/jbuilder.rb
|
112
55
|
- lib/tilt/jbuilder.rb
|
113
56
|
- spec/_partial.json.jbuilder
|
114
57
|
- spec/sinatra_integration_spec.rb
|
58
|
+
- spec/spec_helper.rb
|
59
|
+
- spec/support/sinatra_integration_test_methods.rb
|
60
|
+
- spec/support/views/_partial_with_helper_method.jbuilder
|
61
|
+
- spec/support/views/_partial_with_instance_variable.jbuilder
|
62
|
+
- spec/support/views/_partial_with_local_variable.jbuilder
|
63
|
+
- spec/support/views/hello.jbuilder
|
115
64
|
- spec/tilt-jbuilder_spec.rb
|
116
|
-
- spec/views/_partial_with_helper_method.jbuilder
|
117
|
-
- spec/views/_partial_with_instance_variable.jbuilder
|
118
|
-
- spec/views/_partial_with_local_variable.jbuilder
|
119
|
-
- spec/views/hello.jbuilder
|
120
65
|
- tilt-jbuilder.gemspec
|
121
66
|
homepage: https://github.com/anthonator/tilt-jbuilder
|
122
67
|
licenses: []
|
@@ -144,8 +89,10 @@ summary: Adds support for rendering Jbuilder templates in Tilt.
|
|
144
89
|
test_files:
|
145
90
|
- spec/_partial.json.jbuilder
|
146
91
|
- spec/sinatra_integration_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
- spec/support/sinatra_integration_test_methods.rb
|
94
|
+
- spec/support/views/_partial_with_helper_method.jbuilder
|
95
|
+
- spec/support/views/_partial_with_instance_variable.jbuilder
|
96
|
+
- spec/support/views/_partial_with_local_variable.jbuilder
|
97
|
+
- spec/support/views/hello.jbuilder
|
147
98
|
- spec/tilt-jbuilder_spec.rb
|
148
|
-
- spec/views/_partial_with_helper_method.jbuilder
|
149
|
-
- spec/views/_partial_with_instance_variable.jbuilder
|
150
|
-
- spec/views/_partial_with_local_variable.jbuilder
|
151
|
-
- spec/views/hello.jbuilder
|
data/README.rdoc
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
= tilt-jbuilder
|
2
|
-
|
3
|
-
Adds support for rendering Jbuilder templates using Tilt.
|
4
|
-
|
5
|
-
== Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'tilt-jbuilder'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install tilt-jbuilder
|
18
|
-
|
19
|
-
== Usage
|
20
|
-
|
21
|
-
require 'tilt/jbuilder.rb'
|
22
|
-
|
23
|
-
template = Tilt::JbuilderTemplate.new("templates/awesomeness.json.jbuilder")
|
24
|
-
teplate.render
|
25
|
-
|
26
|
-
# With locals
|
27
|
-
template = Tilt::JbuilderTemplate.new { "json.author name" }
|
28
|
-
template.render(nil, :name => 'Anthony')
|
29
|
-
|
30
|
-
# With scope
|
31
|
-
template = Tilt::JbuilderTemplate.new { "json.author @name" }
|
32
|
-
scope = Object.new
|
33
|
-
scope.instance_variable_set :@name, 'Anthony'
|
34
|
-
template.render(scope)
|
35
|
-
|
36
|
-
# Block style
|
37
|
-
template = Tilt::JbuilderTemplate.new do |t|
|
38
|
-
lambda { |json| json.author 'Anthony'; json.target! }
|
39
|
-
end
|
40
|
-
template.render
|
41
|
-
|
42
|
-
== Contributing
|
43
|
-
|
44
|
-
1. Fork it
|
45
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
47
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
-
5. Create new Pull Request
|