skates 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/skates/base/view.rb +1 -0
- data/lib/skates.rb +1 -0
- data/spec/lib/skates/base/view_spec.rb +22 -9
- metadata +36 -7
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
|
13
13
|
gem.add_dependency('eventmachine', ">= 0.12.10")
|
14
14
|
gem.add_dependency('log4r')
|
15
|
-
gem.add_dependency('nokogiri', "
|
15
|
+
gem.add_dependency('nokogiri', "= 1.4.2")
|
16
16
|
gem.add_dependency('utf8cleaner')
|
17
17
|
gem.requirements = ["eventmachine", "yaml", "fileutils", "log4r", "nokogiri", "optparse", "digest/sha1", "base64", "resolv", "utf8cleaner"]
|
18
18
|
gem.executables = "skates"
|
data/lib/skates/base/view.rb
CHANGED
@@ -17,6 +17,7 @@ module Skates
|
|
17
17
|
def render(xml, options = {})
|
18
18
|
# First, we need to identify the partial file path, based on the @view_template path.
|
19
19
|
partial_path = (@view_template.split("/")[0..-2] + options[:partial].split("/")).join("/").gsub(".xml.builder", "") + ".xml.builder"
|
20
|
+
partial_path = Pathname.new(partial_path).cleanpath.to_s
|
20
21
|
raise ViewFileNotFound, "No such file #{partial_path}" unless Skates.views[partial_path]
|
21
22
|
saved_locals = @locals
|
22
23
|
@locals = options[:locals]
|
data/lib/skates.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
2
|
|
3
3
|
describe Skates::Base::View do
|
4
|
-
describe
|
4
|
+
describe :initialize do
|
5
5
|
|
6
6
|
before(:each) do
|
7
|
-
@view = Skates::Base::View.new("/a/path/to/
|
7
|
+
@view = Skates::Base::View.new("/a/path/to/views/file", {:a => "a", :b => 123, :c => {:d => "d", :e => "123"}})
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should assign @view_template to path" do
|
11
|
-
@view.view_template == "/a/path/to/
|
11
|
+
@view.view_template == "/a/path/to/views/file"
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should assign any variable passed in hash" do
|
@@ -18,9 +18,9 @@ describe Skates::Base::View do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
21
|
+
describe :evaluate do
|
22
22
|
before(:each) do
|
23
|
-
@view_template = "/a/path/to/
|
23
|
+
@view_template = "/a/path/to/views/file"
|
24
24
|
@view = Skates::Base::View.new(@view_template, {:a => "a", :b => 123, :c => {:d => "d", :e => "123"}})
|
25
25
|
@xml_string = <<-eoxml
|
26
26
|
xml.message(:to => "you", :from => "me", :type => :chat) do
|
@@ -54,29 +54,38 @@ describe Skates::Base::View do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should be able to access context's variables" do
|
57
|
-
@view = Skates::Base::View.new("/a/path/to/
|
57
|
+
@view = Skates::Base::View.new("/a/path/to/views/file", {:a => "a", :b => 123, :c => {:d => "d", :e => "123"}})
|
58
58
|
@view.instance_variable_get("@a").should == "a"
|
59
59
|
@view.instance_variable_get("@b").should == 123
|
60
60
|
@view.instance_variable_get("@c").should == {:e=>"123", :d=>"d"}
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
describe
|
64
|
+
describe :render do
|
65
65
|
before(:each) do
|
66
|
-
@view_template = "/a/path/to/
|
66
|
+
@view_template = "/a/path/to/views/file"
|
67
67
|
@view = Skates::Base::View.new(@view_template, {:a => "a", :b => 123, :c => {:d => "d", :e => "123"}})
|
68
|
+
|
68
69
|
@xml_string = <<-eoxml
|
69
70
|
xml.message(:to => "you", :from => "me", :type => :chat) do |message|
|
70
71
|
message.body("salut")
|
71
72
|
render(message, {:partial => "partial", :locals => {:subtitle => "bonjour monde"}})
|
73
|
+
render(message, {:partial => "../other_views/partial", :locals => {:subtitle => "bonjour monde", :name => "Joe"}})
|
72
74
|
end
|
73
75
|
eoxml
|
76
|
+
|
74
77
|
@partial_string = <<-eoxml
|
75
78
|
xml.title("hello word")
|
76
79
|
xml.subtitle(subtitle)
|
77
80
|
eoxml
|
81
|
+
|
82
|
+
@partial_in_annother_controller_string = <<-eoxml
|
83
|
+
xml.name(name)
|
84
|
+
eoxml
|
85
|
+
|
78
86
|
Skates.views.stub!(:[]).with(@view_template).and_return(@xml_string)
|
79
|
-
Skates.views.stub!(:[]).with("/a/path/to/
|
87
|
+
Skates.views.stub!(:[]).with("/a/path/to/views/partial.xml.builder").and_return(@partial_string)
|
88
|
+
Skates.views.stub!(:[]).with("/a/path/to/other_views/partial.xml.builder").and_return(@partial_in_annother_controller_string)
|
80
89
|
end
|
81
90
|
|
82
91
|
it "should render the partial in the right context" do
|
@@ -87,6 +96,10 @@ describe Skates::Base::View do
|
|
87
96
|
@view.evaluate.xpath("//message/subtitle").text.should == "bonjour monde"
|
88
97
|
end
|
89
98
|
|
99
|
+
it "should cleanup the path so only canonical paths are used" do
|
100
|
+
@view.evaluate.xpath("//message/name").text.should == "Joe"
|
101
|
+
end
|
102
|
+
|
90
103
|
end
|
91
104
|
|
92
105
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- julien Genestoux
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-08-17 00:00:00 +02:00
|
18
19
|
default_executable: skates
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: eventmachine
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 59
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
- 12
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: log4r
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
41
46
|
segments:
|
42
47
|
- 0
|
43
48
|
version: "0"
|
@@ -47,23 +52,27 @@ dependencies:
|
|
47
52
|
name: nokogiri
|
48
53
|
prerelease: false
|
49
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
50
56
|
requirements:
|
51
|
-
- - "
|
57
|
+
- - "="
|
52
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
53
60
|
segments:
|
54
61
|
- 1
|
55
62
|
- 4
|
56
|
-
-
|
57
|
-
version: 1.4.
|
63
|
+
- 2
|
64
|
+
version: 1.4.2
|
58
65
|
type: :runtime
|
59
66
|
version_requirements: *id003
|
60
67
|
- !ruby/object:Gem::Dependency
|
61
68
|
name: utf8cleaner
|
62
69
|
prerelease: false
|
63
70
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
64
72
|
requirements:
|
65
73
|
- - ">="
|
66
74
|
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
67
76
|
segments:
|
68
77
|
- 0
|
69
78
|
version: "0"
|
@@ -108,6 +117,22 @@ files:
|
|
108
117
|
- templates/skates/log/test.log
|
109
118
|
- templates/skates/script/component
|
110
119
|
- templates/skates/tmp/pids/README
|
120
|
+
- spec/bin/skates_spec.rb
|
121
|
+
- spec/em_mock.rb
|
122
|
+
- spec/lib/skates/base/controller_spec.rb
|
123
|
+
- spec/lib/skates/base/stanza_spec.rb
|
124
|
+
- spec/lib/skates/base/view_spec.rb
|
125
|
+
- spec/lib/skates/client_connection_spec.rb
|
126
|
+
- spec/lib/skates/component_connection_spec.rb
|
127
|
+
- spec/lib/skates/generator_spec.rb
|
128
|
+
- spec/lib/skates/router/dsl_spec.rb
|
129
|
+
- spec/lib/skates/router_spec.rb
|
130
|
+
- spec/lib/skates/runner_spec.rb
|
131
|
+
- spec/lib/skates/xmpp_connection_spec.rb
|
132
|
+
- spec/lib/skates/xmpp_parser_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
- test/skates_test.rb
|
135
|
+
- test/test_helper.rb
|
111
136
|
has_rdoc: true
|
112
137
|
homepage: http://github.com/julien51/skates
|
113
138
|
licenses: []
|
@@ -118,16 +143,20 @@ rdoc_options:
|
|
118
143
|
require_paths:
|
119
144
|
- lib
|
120
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
121
147
|
requirements:
|
122
148
|
- - ">="
|
123
149
|
- !ruby/object:Gem::Version
|
150
|
+
hash: 3
|
124
151
|
segments:
|
125
152
|
- 0
|
126
153
|
version: "0"
|
127
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
128
156
|
requirements:
|
129
157
|
- - ">="
|
130
158
|
- !ruby/object:Gem::Version
|
159
|
+
hash: 3
|
131
160
|
segments:
|
132
161
|
- 0
|
133
162
|
version: "0"
|
@@ -143,7 +172,7 @@ requirements:
|
|
143
172
|
- resolv
|
144
173
|
- utf8cleaner
|
145
174
|
rubyforge_project: skates
|
146
|
-
rubygems_version: 1.3.
|
175
|
+
rubygems_version: 1.3.7
|
147
176
|
signing_key:
|
148
177
|
specification_version: 3
|
149
178
|
summary: Skates is a framework to create EventMachine based XMPP External Components in Ruby.
|