rabl 0.11.4 → 0.11.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 653e59826616815f5be896620c6e11bfde575596
4
- data.tar.gz: e3cf65575ec7aa5698a24119e761c0959433aefb
3
+ metadata.gz: 8e537c7beaab5536e66f93405989bf5cee8eb01c
4
+ data.tar.gz: ba40dd0c56d79991be8348f316012fe7d0642653
5
5
  SHA512:
6
- metadata.gz: 6ff1aa2e4f4b7f7f91d70210d8faec3063dabe58a06d9d313e9c9ab195177296ee40ffbd0e8873ff65258fca4f4f32d9132d0ce74424a3f6c7a036ff411037e3
7
- data.tar.gz: e3112ccd7ff15031956053833d59c49bacf908db0998352015fe975d500570b2f5395c9f972cca25b52864c3e1d5170ef97f0c6ce45c3bdafe56196bc4befc97
6
+ metadata.gz: 9120f78fa8c6c01522b56df715e95fa5fdf23851f0d6ce485a797c43a82d182b9141fa5bbd58884a484dce88619bc591e4d3ea9a25d41df5b184b84aa58671e5
7
+ data.tar.gz: 7b8cae3fed1ef957e4ef39b6b4af16366e4444eb2d591a8bb1320426cabf4af16d3beda7344600efa53abd8929ab54989602e8a25326fcc75a379bb0419a5432
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.11.5 (December 5th)
4
+
5
+ * Check if context_scope includes ".settings.views" for Sinatra (@LTe)
6
+ * Fix view path issue for partials (@LTe)
7
+
3
8
  ## 0.11.4 (November 7th)
4
9
 
5
10
  * FIX Get MultiBuilder to behave properly around nil engines (@DouweM)
data/lib/rabl/partials.rb CHANGED
@@ -7,7 +7,7 @@ module Rabl
7
7
  raise ArgumentError, "Must provide an :object option to render a partial" unless options.has_key?(:object)
8
8
 
9
9
  object = options.delete(:object)
10
- view_path = options[:view_path] || view_path
10
+ view_path = options[:view_path] || self.view_path
11
11
 
12
12
  source, location = fetch_source(file, :view_path => view_path)
13
13
 
data/lib/rabl/sources.rb CHANGED
@@ -14,7 +14,7 @@ module Rabl
14
14
  elsif defined?(Rails) && context_scope.respond_to?(:view_paths)
15
15
  _view_paths = view_paths + Array(context_scope.view_paths.to_a)
16
16
  fetch_rails_source(file, options) || fetch_manual_template(_view_paths, file)
17
- elsif defined?(Sinatra) && context_scope.respond_to?(:settings)
17
+ elsif defined?(Sinatra) && context_scope.respond_to?(:settings) && context_scope.settings.respond_to?(:views)
18
18
  fetch_sinatra_source(file, options)
19
19
  else # generic template resolution
20
20
  fetch_manual_template(view_paths, file)
data/lib/rabl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rabl
2
- VERSION = "0.11.4"
2
+ VERSION = "0.11.5"
3
3
  end
@@ -89,6 +89,26 @@ context "Rabl::Partials" do
89
89
  end
90
90
  end
91
91
 
92
+ context "partial_as_engine using configured view paths" do
93
+ helper(:tmp_path) { @tmp_path ||= Pathname.new(Dir.mktmpdir) }
94
+
95
+ setup do
96
+ File.open(tmp_path + "_test.rabl", "w")
97
+ engine = Rabl::Engine.new('', :view_path => tmp_path)
98
+ end
99
+
100
+ asserts('returns new engine with given view_path') do
101
+ topic.partial_as_engine('test', :object => {}).view_path
102
+ end.equals do
103
+ tmp_path
104
+ end
105
+
106
+ teardown do
107
+ Rabl.configuration.view_paths = []
108
+ end
109
+ end
110
+
111
+
92
112
  context "fetch source with custom scope" do
93
113
  context "when Padrino is defined" do
94
114
  helper(:tmp_path) { @tmp_path ||= Pathname.new(Dir.mktmpdir) }
@@ -113,6 +133,30 @@ context "Rabl::Partials" do
113
133
 
114
134
  teardown { Object.send(:remove_const, :Padrino) }
115
135
  end
136
+
137
+ context "when Sinatra is defined" do
138
+ helper(:tmp_path) { @tmp_path ||= Pathname.new(Dir.mktmpdir) }
139
+
140
+ setup do
141
+ ::Sinatra = stub(Class.new)
142
+ Rabl.configuration.cache_sources = false
143
+ @it = TestPartial.new
144
+
145
+ def @it.context_scope; @context_scope ||= Object.new; end
146
+ context_scope = @it.context_scope
147
+ def context_scope.settings; @settings ||= Object.new end
148
+
149
+ File.open(tmp_path + "test.json.rabl", "w") { |f| f.puts "content" }
150
+ end
151
+
152
+ asserts('Sinatra constant dont break manual lookup') do
153
+ @it.fetch_source((tmp_path + "test").to_s)
154
+ end.equals do
155
+ ["content\n", "/" + (tmp_path + "test.json.rabl").to_s ]
156
+ end
157
+
158
+ teardown { Object.send(:remove_const, :Sinatra) }
159
+ end
116
160
  end
117
161
 
118
162
  context "fetch source with Rails" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.4
4
+ version: 0.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-08 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport