petroglyph 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/petroglyph/scope.rb +3 -1
- data/lib/petroglyph/version.rb +1 -1
- data/spec/scope_spec.rb +11 -0
- data/spec/sinatra_integration_spec.rb +3 -4
- metadata +9 -9
data/lib/petroglyph/scope.rb
CHANGED
@@ -74,7 +74,9 @@ module Petroglyph
|
|
74
74
|
merge fragment
|
75
75
|
end
|
76
76
|
|
77
|
-
def partial(name, locals =
|
77
|
+
def partial(name, locals = nil)
|
78
|
+
locals ||= {name => send(name)} if respond_to?(name)
|
79
|
+
locals ||= {}
|
78
80
|
data = Petroglyph.partial(name, file)
|
79
81
|
scope = Scope.new(@context, locals, file)
|
80
82
|
scope.instance_eval(data.to_s)
|
data/lib/petroglyph/version.rb
CHANGED
data/spec/scope_spec.rb
CHANGED
@@ -240,6 +240,17 @@ describe Petroglyph::Scope do
|
|
240
240
|
scope.value.should eq({:partial => {:drink => 'tea'}})
|
241
241
|
end
|
242
242
|
|
243
|
+
it "defaults locals to match the name of the partial" do
|
244
|
+
Petroglyph.stub(:partial) { 'node :drink => drink' }
|
245
|
+
|
246
|
+
scope = Petroglyph::Scope.new(nil, {:drink => 'coffee'})
|
247
|
+
scope.node :drinks do
|
248
|
+
partial :drink
|
249
|
+
end
|
250
|
+
|
251
|
+
scope.value.should eq({:drinks => {:drink => 'coffee'}})
|
252
|
+
end
|
253
|
+
|
243
254
|
it "finds the partial" do
|
244
255
|
scope = Petroglyph::Scope.new
|
245
256
|
scope.file = "spec/fixtures/views/some_template.pg"
|
@@ -33,9 +33,8 @@ describe "Sinatra integration" do
|
|
33
33
|
it "overshadows the controller methods" do
|
34
34
|
# look at /views/fixtures/post.pg
|
35
35
|
# and line 18 of this file
|
36
|
-
pending "right now if you refer to a local var 'post' in the template, you will accidentally call sinatra's post method"
|
37
|
-
|
38
|
-
|
39
|
-
end
|
36
|
+
pending "right now if you refer to a local var 'post' in the template, you will accidentally call sinatra's post method"
|
37
|
+
post '/'
|
38
|
+
last_response.body.should eq "{\"post\":\"a post\"}"
|
40
39
|
end
|
41
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: petroglyph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-09-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tilt
|
16
|
-
requirement: &
|
16
|
+
requirement: &70270581389760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70270581389760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70270581388680 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70270581388680
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sinatra
|
38
|
-
requirement: &
|
38
|
+
requirement: &70270581387860 !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: *
|
46
|
+
version_requirements: *70270581387860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rack-test
|
49
|
-
requirement: &
|
49
|
+
requirement: &70270581387260 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70270581387260
|
58
58
|
description: A simple, terse, and unsurprising ruby dsl to create json views.
|
59
59
|
email:
|
60
60
|
- katrina.owen@gmail.com
|