petroglyph 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -81,8 +81,12 @@ module Petroglyph
81
81
  merge scope.value
82
82
  end
83
83
 
84
+ def respond_to?(method)
85
+ super || local?(method)
86
+ end
87
+
84
88
  def method_missing(method, *args, &block)
85
- if @locals and @locals.has_key?(method)
89
+ if local?(method)
86
90
  @locals[method]
87
91
  elsif @context.respond_to?(method)
88
92
  @context.send(method, *args)
@@ -91,5 +95,11 @@ module Petroglyph
91
95
  end
92
96
  end
93
97
 
98
+ private
99
+
100
+ def local?(method)
101
+ @locals and @locals.has_key?(method)
102
+ end
103
+
94
104
  end
95
105
  end
@@ -1,3 +1,3 @@
1
1
  module Petroglyph
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/spec/scope_spec.rb CHANGED
@@ -92,15 +92,29 @@ describe Petroglyph::Scope do
92
92
  end
93
93
 
94
94
  context "with locals" do
95
- it "resolves values" do
96
- scope = Petroglyph::Scope.new(nil, {:thing => 'stuff'})
95
+ let(:scope) { Petroglyph::Scope.new(nil, {:thing => 'stuff'}) }
97
96
 
97
+ before(:each) do
98
98
  scope.instance_eval do
99
99
  node :thing => thing
100
100
  end
101
+ end
101
102
 
103
+ it "resolves values" do
102
104
  scope.value.should eq({:thing => 'stuff'})
103
105
  end
106
+
107
+ it "responds to existing locals" do
108
+ scope.respond_to?(:thing).should == true
109
+ end
110
+
111
+ it "doesn't respond to missing locals" do
112
+ scope.respond_to?(:not_a_thing).should == false
113
+ end
114
+
115
+ it "doesn't clobber :respond_to?" do
116
+ scope.respond_to?(:value).should == true
117
+ end
104
118
  end
105
119
 
106
120
  describe "within a context" do
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-22 00:00:00.000000000 Z
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tilt
16
- requirement: &70117439374320 !ruby/object:Gem::Requirement
16
+ requirement: &70098128602560 !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: *70117439374320
24
+ version_requirements: *70098128602560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70117439367780 !ruby/object:Gem::Requirement
27
+ requirement: &70098128601740 !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: *70117439367780
35
+ version_requirements: *70098128601740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sinatra
38
- requirement: &70117439367160 !ruby/object:Gem::Requirement
38
+ requirement: &70098128707940 !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: *70117439367160
46
+ version_requirements: *70098128707940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack-test
49
- requirement: &70117439366500 !ruby/object:Gem::Requirement
49
+ requirement: &70098128707020 !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: *70117439366500
57
+ version_requirements: *70098128707020
58
58
  description: A simple, terse, and unsurprising ruby dsl to create json views.
59
59
  email:
60
60
  - katrina.owen@gmail.com
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project: petroglyph
116
- rubygems_version: 1.8.10
116
+ rubygems_version: 1.8.15
117
117
  signing_key:
118
118
  specification_version: 3
119
119
  summary: A simple, terse, and unsurprising ruby dsl to create json views.