asir 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/README.textile +2 -6
- data/Rakefile +0 -11
- data/asir.gemspec +0 -1
- data/lib/asir/transport/tcp_socket.rb +1 -1
- data/lib/asir/uri_config.rb +10 -6
- data/lib/asir/version.rb +1 -1
- metadata +4 -22
- data/spec/xml_spec.rb +0 -144
data/ChangeLog
CHANGED
data/README.textile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
h1. Abstracting Services in Ruby
|
2
2
|
|
3
3
|
* Kurt Stephens
|
4
|
-
*
|
4
|
+
* 2012/12/11
|
5
5
|
* Slides -- "http://kurtstephens.com/pub/abstracting_services_in_ruby/asir.slides/":http://kurtstephens.com/pub/abstracting_services_in_ruby/asir.slides/
|
6
6
|
* Code -- "http://kurtstephens.com/pub/abstracting_services_in_ruby/":http://kurtstephens.com/pub/abstracting_services_in_ruby/
|
7
7
|
* Git -- "http://github.com/kstephens/abstractiing_services_in_ruby":http://github.com/kstephens/abstractiing_services_in_ruby
|
@@ -36,7 +36,7 @@ h3. Features
|
|
36
36
|
** Time-decaying retry and polling logic.
|
37
37
|
* Support for multiple encodings:
|
38
38
|
** Marshal.
|
39
|
-
** XML.
|
39
|
+
** XML. (gem asir_xml)
|
40
40
|
** JSON.
|
41
41
|
** YAML.
|
42
42
|
** Base64.
|
@@ -51,7 +51,3 @@ h2. Platform support
|
|
51
51
|
* CRuby 2.0-head
|
52
52
|
* JRuby 1.6.x (with JRUBY_OPTS=--1.9) IN-PROGRESS
|
53
53
|
|
54
|
-
h2. Dependencies
|
55
|
-
|
56
|
-
* Requires install of libxml, libxslt for XML support: rake prereq.
|
57
|
-
|
data/Rakefile
CHANGED
@@ -51,17 +51,6 @@ end
|
|
51
51
|
|
52
52
|
######################################################################
|
53
53
|
|
54
|
-
desc "Install system prerequites"
|
55
|
-
task :prereq do
|
56
|
-
case RUBY_PLATFORM
|
57
|
-
when /darwin/i
|
58
|
-
sh "sudo port install libxml libxslt"
|
59
|
-
when /linux/i
|
60
|
-
sh "sudo apt-get install libxml2-dev libxslt1-dev"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
######################################################################
|
65
54
|
desc "Create slides."
|
66
55
|
task :slides =>
|
67
56
|
[
|
data/asir.gemspec
CHANGED
data/lib/asir/uri_config.rb
CHANGED
@@ -11,7 +11,8 @@ module ASIR
|
|
11
11
|
alias :address= :host=
|
12
12
|
|
13
13
|
def uri
|
14
|
-
@uri ||=
|
14
|
+
@uri ||=
|
15
|
+
"#{scheme}://#{host}:#{port}#{path}".freeze
|
15
16
|
end
|
16
17
|
|
17
18
|
def _uri
|
@@ -22,7 +23,7 @@ module ASIR
|
|
22
23
|
def scheme
|
23
24
|
@scheme ||=
|
24
25
|
(@uri && _uri.scheme) ||
|
25
|
-
|
26
|
+
scheme_default ||
|
26
27
|
S_TCP
|
27
28
|
end
|
28
29
|
S_TCP = 'tcp'.freeze
|
@@ -30,7 +31,7 @@ module ASIR
|
|
30
31
|
def host
|
31
32
|
@host ||=
|
32
33
|
(@uri && _uri.host) ||
|
33
|
-
|
34
|
+
host_default ||
|
34
35
|
S_LOCALHOST
|
35
36
|
end
|
36
37
|
S_LOCALHOST = '127.0.0.1'.freeze
|
@@ -38,14 +39,17 @@ module ASIR
|
|
38
39
|
def port
|
39
40
|
@port ||=
|
40
41
|
(@uri && _uri.port) ||
|
41
|
-
|
42
|
+
port_default ||
|
42
43
|
(raise Error, "#{self.class}: port not set.")
|
43
44
|
end
|
44
45
|
|
45
46
|
def path
|
46
47
|
@path ||=
|
47
|
-
(@uri &&
|
48
|
-
|
48
|
+
(@uri && (
|
49
|
+
p = _uri.path
|
50
|
+
p = nil if p.empty?
|
51
|
+
p)) ||
|
52
|
+
path_default
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
data/lib/asir/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: uuid
|
@@ -43,22 +43,6 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 2.3.0
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: libxml-ruby
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 2.3.3
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.3.3
|
62
46
|
- !ruby/object:Gem::Dependency
|
63
47
|
name: rack
|
64
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -296,7 +280,6 @@ files:
|
|
296
280
|
- spec/thread_pool_spec.rb
|
297
281
|
- spec/thread_variable_spec.rb
|
298
282
|
- spec/transport_spec.rb
|
299
|
-
- spec/xml_spec.rb
|
300
283
|
- spec/yaml_spec.rb
|
301
284
|
- stylesheets/slides.css
|
302
285
|
homepage: http://github.com/kstephens/abstracting_services_in_ruby
|
@@ -314,7 +297,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
314
297
|
version: '0'
|
315
298
|
segments:
|
316
299
|
- 0
|
317
|
-
hash:
|
300
|
+
hash: -3323359045445920418
|
318
301
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
319
302
|
none: false
|
320
303
|
requirements:
|
@@ -323,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
323
306
|
version: '0'
|
324
307
|
segments:
|
325
308
|
- 0
|
326
|
-
hash:
|
309
|
+
hash: -3323359045445920418
|
327
310
|
requirements: []
|
328
311
|
rubyforge_project:
|
329
312
|
rubygems_version: 1.8.24
|
@@ -342,5 +325,4 @@ test_files:
|
|
342
325
|
- spec/thread_pool_spec.rb
|
343
326
|
- spec/thread_variable_spec.rb
|
344
327
|
- spec/transport_spec.rb
|
345
|
-
- spec/xml_spec.rb
|
346
328
|
- spec/yaml_spec.rb
|
data/spec/xml_spec.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
require 'asir/coder/xml'
|
3
|
-
|
4
|
-
describe "ASIR::Coder::XML" do
|
5
|
-
before(:each) do
|
6
|
-
@enc = ASIR::Coder::XML.new
|
7
|
-
@dec = @enc.dup
|
8
|
-
end
|
9
|
-
|
10
|
-
basic_objs = [ ]
|
11
|
-
|
12
|
-
[
|
13
|
-
nil,
|
14
|
-
true,
|
15
|
-
false,
|
16
|
-
].each do | x |
|
17
|
-
basic_objs << x
|
18
|
-
it "should handle #{x.inspect}" do
|
19
|
-
xml = @enc.prepare.encode(x)
|
20
|
-
xml.should == "<#{x.class.name} />"
|
21
|
-
@dec.prepare.decode(xml).should == x
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
[
|
26
|
-
1234,
|
27
|
-
1.234,
|
28
|
-
].each do | x |
|
29
|
-
basic_objs << x
|
30
|
-
it "should handle #{x.inspect}" do
|
31
|
-
xml = @enc.prepare.encode(x)
|
32
|
-
xml.should == "<#{x.class.name} v=\"#{x.to_s}\" />"
|
33
|
-
@dec.prepare.decode(xml).should == x
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
[
|
38
|
-
:symbol,
|
39
|
-
].each do | x |
|
40
|
-
basic_objs << x
|
41
|
-
it "should handle #{x.inspect}" do
|
42
|
-
xml = @enc.prepare.encode(x)
|
43
|
-
xml.should == "<#{x.class.name} >#{x.to_s}</#{x.class.name}>"
|
44
|
-
@dec.prepare.decode(xml).should == x
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
[
|
49
|
-
'String',
|
50
|
-
].each do | x |
|
51
|
-
basic_objs << x
|
52
|
-
it "should handle #{x.inspect}" do
|
53
|
-
xml = @enc.prepare.encode(x)
|
54
|
-
xml.should == "<#{x.class.name} id=\"1\" >#{x.to_s}</#{x.class.name}>"
|
55
|
-
@dec.prepare.decode(xml).should == x
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should handle empty Array" do
|
60
|
-
x = [ ]
|
61
|
-
xml = @enc.prepare.encode(x)
|
62
|
-
xml.should == "<#{x.class.name} id=\"1\" ></#{x.class.name}>"
|
63
|
-
@dec.prepare.decode(xml).should == x
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should handle Array" do
|
67
|
-
x = [ *basic_objs ]
|
68
|
-
xml = @enc.prepare.encode(x)
|
69
|
-
xml.should =~ %r{\A<#{x.class.name} id=\"1\" ><NilClass /><TrueClass /><FalseClass /><Fixnum v="1234" /><Float v="1.234" /><Symbol >symbol</Symbol><String id=\"[^"]+\" >String</String></#{x.class.name}>\Z} # " emacs
|
70
|
-
@dec.prepare.decode(xml).should == x
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should handle empty Hash" do
|
74
|
-
x = { }
|
75
|
-
xml = @enc.prepare.encode(x)
|
76
|
-
xml.should == "<#{x.class.name} id=\"1\" ></#{x.class.name}>"
|
77
|
-
@dec.prepare.decode(xml).should == x
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should handle Hash" do
|
81
|
-
x = Hash[ *basic_objs.map{|e| e.inspect}.zip(basic_objs).flatten ]
|
82
|
-
xml = @enc.prepare.encode(x)
|
83
|
-
xml.should =~ %r{\A<#{x.class.name} id=\"1\" >}
|
84
|
-
xml.should =~ %r{</#{x.class.name}>\Z}
|
85
|
-
basic_objs.each do | v |
|
86
|
-
vx = @enc.dup.encode(v)
|
87
|
-
vx = vx.gsub(/id="[^"]+"/, 'id="\d+"')
|
88
|
-
xml.should =~ Regexp.new(vx)
|
89
|
-
xml.should =~ %r{ >#{v.inspect}</String>}
|
90
|
-
end
|
91
|
-
@dec.prepare.decode(xml).should == x
|
92
|
-
end
|
93
|
-
|
94
|
-
class ASIR::Coder::XML::Test
|
95
|
-
attr_accessor :a, :h, :o
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should handle deep objects" do
|
99
|
-
x = ASIR::Coder::XML::Test.new
|
100
|
-
x.a = [ *basic_objs ]
|
101
|
-
x.h = Hash[ *basic_objs.map{|e| e.inspect}.zip(basic_objs).flatten ]
|
102
|
-
x.o = ASIR::Coder::XML::Test.new
|
103
|
-
x.o.a = 123
|
104
|
-
xml = @enc.prepare.encode(x)
|
105
|
-
xml.should =~ %r{<#{x.class.name.gsub('::', '.')} id=\"1\" >}
|
106
|
-
xml.should =~ %r{</#{x.class.name.gsub('::', '.')}>}
|
107
|
-
y = @dec.prepare.decode(xml)
|
108
|
-
y.a.should == x.a
|
109
|
-
y.h.should == x.h
|
110
|
-
y.o.class.should == ASIR::Coder::XML::Test
|
111
|
-
y.o.a.should == x.o.a
|
112
|
-
x.instance_variables.sort { |a, b| a.to_s <=> b.to_s}.should ==
|
113
|
-
y.instance_variables.sort { | a, b | a.to_s <=> b.to_s }
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should handle multiple references to same objects." do
|
117
|
-
x = Hash[ *basic_objs.map{|e| e.inspect}.zip(basic_objs).flatten ]
|
118
|
-
y = [ 1, 2 ]
|
119
|
-
x = [ x, x, y, y ]
|
120
|
-
xml = @enc.prepare.encode(x)
|
121
|
-
y = @dec.prepare.decode(xml)
|
122
|
-
y[0].object_id.should == y[1].object_id
|
123
|
-
y[2].object_id.should == y[3].object_id
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should handle self-referencing Array." do
|
127
|
-
x = [ 1 ]
|
128
|
-
x << x
|
129
|
-
xml = @enc.prepare.encode(x)
|
130
|
-
y = @dec.prepare.decode(xml)
|
131
|
-
y[0].should == x[0]
|
132
|
-
y[1].object_id.should == y.object_id
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should handle self-referencing Hash." do
|
136
|
-
x = { :a => 1 }
|
137
|
-
x[:self] = x
|
138
|
-
xml = @enc.prepare.encode(x)
|
139
|
-
y = @dec.prepare.decode(xml)
|
140
|
-
y[:a].should == x[:a]
|
141
|
-
y[:self].object_id.should == y.object_id
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|