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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56939b6d5cafb1b5aa25b1ac0363202fe9909ca1
4
- data.tar.gz: cfd50462e4f0782e7c1d7bb2994e530501d5f15f
3
+ metadata.gz: 7c1e17931a8513c789f4cea3631185ede1832c9b
4
+ data.tar.gz: 9cfea7e9f46f5c9e11ac0f48465ba21a1bdbdd63
5
5
  SHA512:
6
- metadata.gz: 05a4f54cc54921860ac6b94e77cab2f26fb7e29af8a80420c627691d00b6e316f759f31a6ad89f3f320127e27f0e6568884b3934788dc94f12aa781910a27f2c
7
- data.tar.gz: 5699ca31fe3f1b4d3b23765d49b92420ddcac3b92cd93db8fa5964337dee8cca350e01d73c1095ceaa6551e233379dc23ff5890af2fe8521bfa6c56ef9a2f8e0
6
+ metadata.gz: 5ad14ae2d4ea7126b9c43cb9ab73fc12d113e2aa0f4700b73ab646ae9b969c7f6d319eeccaea6f41f69f7961402b94f86852804d6cee6759ffa27255981a9bb7
7
+ data.tar.gz: d37fe4b6a3f504c67e34bc4015eae257d89cbd5a132a22e4d8f9dd555656448e7c9e5ef842192ae881e15a87052f8046fc1985b8f6f2e85f787f67df69dabd45
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rbenv*
19
+ .rvmrc
@@ -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
 
@@ -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
@@ -18,5 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.name = "tilt-jbuilder"
20
20
  gem.require_paths = ["lib"]
21
- gem.version = '0.4.1'
21
+ gem.version = '0.5.1'
22
22
  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.4.1
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-04-19 00:00:00.000000000 Z
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.3
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
@@ -1,3 +0,0 @@
1
- json.author "Anthony"
2
- json.is_admin admin?
3
- json.last_name @last_name