tilt-jbuilder 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/sinatra/jbuilder.rb +10 -0
- data/lib/tilt/jbuilder.rb +1 -6
- data/spec/sinatra_integration_spec.rb +5 -0
- data/tilt-jbuilder.gemspec +1 -1
- metadata +3 -6
- data/.rvmrc +0 -48
- data/spec/views/_hello.jbuilder +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c1e17931a8513c789f4cea3631185ede1832c9b
|
4
|
+
data.tar.gz: 9cfea7e9f46f5c9e11ac0f48465ba21a1bdbdd63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ad14ae2d4ea7126b9c43cb9ab73fc12d113e2aa0f4700b73ab646ae9b969c7f6d319eeccaea6f41f69f7961402b94f86852804d6cee6759ffa27255981a9bb7
|
7
|
+
data.tar.gz: d37fe4b6a3f504c67e34bc4015eae257d89cbd5a132a22e4d8f9dd555656448e7c9e5ef842192ae881e15a87052f8046fc1985b8f6f2e85f787f67df69dabd45
|
data/.gitignore
CHANGED
data/lib/sinatra/jbuilder.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
require "tilt/jbuilder"
|
2
|
+
require "sinatra/base"
|
2
3
|
|
3
4
|
module Sinatra
|
4
5
|
module Templates
|
5
6
|
def jbuilder(template, options={}, locals={})
|
6
7
|
render :jbuilder, template, options, locals
|
7
8
|
end
|
9
|
+
|
10
|
+
def render_with_view_path_support(engine, data, options = {}, locals = {}, &block)
|
11
|
+
# Same as `views` extraction in the original method.
|
12
|
+
options[:view_path] = options[:views] || settings.views || "./views" \
|
13
|
+
if engine.to_s.downcase == "jbuilder"
|
14
|
+
render_without_view_path_support(engine, data, options, locals, &block)
|
15
|
+
end
|
16
|
+
alias_method :render_without_view_path_support, :render
|
17
|
+
alias_method :render, :render_with_view_path_support
|
8
18
|
end
|
9
19
|
end
|
10
20
|
|
data/lib/tilt/jbuilder.rb
CHANGED
@@ -17,12 +17,7 @@ module Tilt
|
|
17
17
|
|
18
18
|
private
|
19
19
|
def fetch_partial_path(file, view_path)
|
20
|
-
view_path ||=
|
21
|
-
if defined?(::Sinatra) && @scope.respond_to?(:settings)
|
22
|
-
@scope.settings.views
|
23
|
-
else
|
24
|
-
::Dir.pwd
|
25
|
-
end
|
20
|
+
view_path ||= ::Dir.pwd
|
26
21
|
::Dir[::File.join(view_path, partialized(file) + ".{*.,}jbuilder")].first
|
27
22
|
end
|
28
23
|
|
@@ -69,4 +69,9 @@ describe "Sinatra Integration" do
|
|
69
69
|
jbuilder_app { jbuilder "json.partial! :partial_with_helper_method" }
|
70
70
|
body.should == "{\"is_admin\":false}"
|
71
71
|
end
|
72
|
+
|
73
|
+
it "renders partials with local variables and non-Sinatra-application scope" do
|
74
|
+
jbuilder_app { jbuilder "json.partial! :partial_with_local_variable, last_name: \"Smith\"", :scope => Object.new }
|
75
|
+
body.should == "{\"last_name\":\"Smith\"}"
|
76
|
+
end
|
72
77
|
end
|
data/tilt-jbuilder.gemspec
CHANGED
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.
|
4
|
+
version: 0.5.1
|
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-
|
11
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|
@@ -102,7 +102,6 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- .gitignore
|
105
|
-
- .rvmrc
|
106
105
|
- .travis.yml
|
107
106
|
- Gemfile
|
108
107
|
- LICENSE
|
@@ -114,7 +113,6 @@ files:
|
|
114
113
|
- spec/_partial.json.jbuilder
|
115
114
|
- spec/sinatra_integration_spec.rb
|
116
115
|
- spec/tilt-jbuilder_spec.rb
|
117
|
-
- spec/views/_hello.jbuilder
|
118
116
|
- spec/views/_partial_with_helper_method.jbuilder
|
119
117
|
- spec/views/_partial_with_instance_variable.jbuilder
|
120
118
|
- spec/views/_partial_with_local_variable.jbuilder
|
@@ -139,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
137
|
version: '0'
|
140
138
|
requirements: []
|
141
139
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.0.
|
140
|
+
rubygems_version: 2.0.0
|
143
141
|
signing_key:
|
144
142
|
specification_version: 4
|
145
143
|
summary: Adds support for rendering Jbuilder templates in Tilt.
|
@@ -147,7 +145,6 @@ test_files:
|
|
147
145
|
- spec/_partial.json.jbuilder
|
148
146
|
- spec/sinatra_integration_spec.rb
|
149
147
|
- spec/tilt-jbuilder_spec.rb
|
150
|
-
- spec/views/_hello.jbuilder
|
151
148
|
- spec/views/_partial_with_helper_method.jbuilder
|
152
149
|
- spec/views/_partial_with_instance_variable.jbuilder
|
153
150
|
- spec/views/_partial_with_local_variable.jbuilder
|
data/.rvmrc
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
-
# Only full ruby name is supported here, for short names use:
|
8
|
-
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
-
environment_id="ruby-1.9.3-p194@tilt-jbuilder"
|
10
|
-
|
11
|
-
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
-
# rvmrc_rvm_version="1.14.1 (stable)" # 1.10.1 seams as a safe start
|
13
|
-
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
-
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
-
# return 1
|
16
|
-
# }
|
17
|
-
|
18
|
-
# First we attempt to load the desired environment directly from the environment
|
19
|
-
# file. This is very fast and efficient compared to running through the entire
|
20
|
-
# CLI and selector. If you want feedback on which environment was used then
|
21
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
-
then
|
25
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
-
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
-
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
-
else
|
29
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
-
rvm --create "$environment_id" || {
|
31
|
-
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
-
return 1
|
33
|
-
}
|
34
|
-
fi
|
35
|
-
|
36
|
-
# If you use bundler, this might be useful to you:
|
37
|
-
# if [[ -s Gemfile ]] && {
|
38
|
-
# ! builtin command -v bundle >/dev/null ||
|
39
|
-
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
-
# }
|
41
|
-
# then
|
42
|
-
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
-
# gem install bundler
|
44
|
-
# fi
|
45
|
-
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
-
# then
|
47
|
-
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
-
# fi
|
data/spec/views/_hello.jbuilder
DELETED