holoserve-connector 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -53
- data/lib/holoserve/connector/bucket.rb +1 -0
- data/lib/holoserve/connector/history.rb +1 -0
- data/lib/holoserve/connector/pairs.rb +8 -26
- data/lib/holoserve/connector/state.rb +21 -0
- data/lib/holoserve/connector.rb +3 -5
- metadata +13 -14
- data/lib/holoserve/connector/fixtures.rb +0 -41
- data/lib/holoserve/connector/situation.rb +0 -22
data/Rakefile
CHANGED
@@ -1,56 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Cucumber::Rake::Task.new(:features) do |task|
|
9
|
-
task.cucumber_opts = "features --format pretty"
|
10
|
-
end
|
11
|
-
|
12
|
-
namespace :features do
|
13
|
-
|
14
|
-
Cucumber::Rake::Task.new(:wip) do |task|
|
15
|
-
task.cucumber_opts = "features --format pretty --tags @wip"
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
rescue LoadError
|
20
|
-
end
|
21
|
-
|
22
|
-
begin
|
23
|
-
require 'rspec'
|
24
|
-
require 'rspec/core/rake_task'
|
25
|
-
|
26
|
-
desc "Run specs"
|
27
|
-
RSpec::Core::RakeTask.new do |task|
|
28
|
-
task.pattern = "./spec/lib/**/*_spec.rb"
|
29
|
-
end
|
30
|
-
rescue LoadError
|
31
|
-
end
|
32
|
-
|
33
|
-
begin
|
34
|
-
require 'rdoc'
|
35
|
-
require 'rdoc/task'
|
36
|
-
|
37
|
-
Rake::RDocTask.new do |rdoc|
|
38
|
-
rdoc.main = "README.rdoc"
|
39
|
-
rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
|
40
|
-
end
|
41
|
-
rescue LoadError
|
42
|
-
end
|
43
|
-
|
44
|
-
namespace :gem do
|
45
|
-
|
46
|
-
desc "Builds the gem"
|
47
|
-
task :build do
|
48
|
-
system "gem build *.gemspec && mkdir -p pkg/ && mv *.gem pkg/"
|
49
|
-
end
|
50
|
-
|
51
|
-
desc "Builds and installs the gem"
|
52
|
-
task :install => :build do
|
53
|
-
system "gem install pkg/"
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
4
|
+
load File.join(File.dirname(__FILE__), "tasks", "features.rake")
|
5
|
+
load File.join(File.dirname(__FILE__), "tasks", "gem.rake")
|
6
|
+
load File.join(File.dirname(__FILE__), "tasks", "rdoc.rake")
|
7
|
+
load File.join(File.dirname(__FILE__), "tasks", "spec.rake")
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'transport'
|
2
2
|
|
3
3
|
class Holoserve::Connector::Pairs
|
4
4
|
|
@@ -6,37 +6,19 @@ class Holoserve::Connector::Pairs
|
|
6
6
|
@client = client
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def ids
|
10
|
+
Transport::JSON.request :get,
|
11
|
+
"#{@client.url}/pairs",
|
12
|
+
:expected_status_code => 200
|
13
13
|
end
|
14
14
|
|
15
15
|
def download(id)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
YAML.load response
|
16
|
+
Transport::JSON.request :get,
|
17
|
+
"#{@client.url}/pairs/#{id}",
|
18
|
+
:expected_status_code => 200
|
20
19
|
rescue Transport::UnexpectedStatusCodeError => error
|
21
20
|
raise Holoserve::Connector::Error, error.message unless error.status_code == 404
|
22
21
|
nil
|
23
22
|
end
|
24
23
|
|
25
|
-
def clear!
|
26
|
-
Transport::JSON.request :delete, "#{@client.url}/pairs"
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def upload_file(filename)
|
32
|
-
uploader = Holoserve::Connector::Tool::Uploader.new filename,
|
33
|
-
:post,
|
34
|
-
"#{@client.url}/pairs",
|
35
|
-
:expected_status_code => 200
|
36
|
-
uploader.upload
|
37
|
-
rescue Transport::UnexpectedStatusCodeError => error
|
38
|
-
raise Holoserve::Connector::Error, "the file #{filename} has an invalid format" if error.status_code == 400
|
39
|
-
raise Holoserve::Connector::Error, error.message
|
40
|
-
end
|
41
|
-
|
42
24
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'transport'
|
2
|
+
|
3
|
+
class Holoserve::Connector::State
|
4
|
+
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def set(hash)
|
10
|
+
Transport::JSON.request :put, "#{@client.url}/state", :parameters => hash
|
11
|
+
end
|
12
|
+
|
13
|
+
def get
|
14
|
+
Transport::JSON.request :get, "#{@client.url}/state"
|
15
|
+
end
|
16
|
+
|
17
|
+
def clear!
|
18
|
+
Transport::JSON.request :delete, "#{@client.url}/state"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/lib/holoserve/connector.rb
CHANGED
@@ -5,7 +5,7 @@ class Holoserve::Connector
|
|
5
5
|
autoload :Fixtures, File.join(File.dirname(__FILE__), "connector", "fixtures")
|
6
6
|
autoload :History, File.join(File.dirname(__FILE__), "connector", "history")
|
7
7
|
autoload :Pairs, File.join(File.dirname(__FILE__), "connector", "pairs")
|
8
|
-
autoload :
|
8
|
+
autoload :State, File.join(File.dirname(__FILE__), "connector", "state")
|
9
9
|
autoload :Tool, File.join(File.dirname(__FILE__), "connector", "tool")
|
10
10
|
|
11
11
|
class Error < StandardError; end
|
@@ -14,10 +14,9 @@ class Holoserve::Connector
|
|
14
14
|
attr_reader :port
|
15
15
|
|
16
16
|
attr_reader :bucket
|
17
|
-
attr_reader :fixtures
|
18
17
|
attr_reader :history
|
19
18
|
attr_reader :pairs
|
20
|
-
attr_reader :
|
19
|
+
attr_reader :state
|
21
20
|
|
22
21
|
def initialize(options = { })
|
23
22
|
@host, @port = *options.values_at(:host, :port)
|
@@ -25,10 +24,9 @@ class Holoserve::Connector
|
|
25
24
|
@port ||= 4250
|
26
25
|
|
27
26
|
@bucket = Bucket.new self
|
28
|
-
@fixtures = Fixtures.new self
|
29
27
|
@history = History.new self
|
30
28
|
@pairs = Pairs.new self
|
31
|
-
@
|
29
|
+
@state = State.new self
|
32
30
|
end
|
33
31
|
|
34
32
|
def url
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: holoserve-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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-
|
12
|
+
date: 2012-03-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: transport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70365766527360 !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: *70365766527360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: holoserve
|
27
|
-
requirement: &
|
27
|
+
requirement: &70365766526560 !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: *70365766526560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: cucumber
|
38
|
-
requirement: &
|
38
|
+
requirement: &70365766525820 !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: *70365766525820
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70365766525140 !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: *70365766525140
|
58
58
|
description: Provides a client for the control interface of holoserve and some RSpec
|
59
59
|
matchers.
|
60
60
|
email: philipp.bruell@skrill.com
|
@@ -67,10 +67,9 @@ files:
|
|
67
67
|
- LICENSE
|
68
68
|
- Rakefile
|
69
69
|
- lib/holoserve/connector/bucket.rb
|
70
|
-
- lib/holoserve/connector/fixtures.rb
|
71
70
|
- lib/holoserve/connector/history.rb
|
72
71
|
- lib/holoserve/connector/pairs.rb
|
73
|
-
- lib/holoserve/connector/
|
72
|
+
- lib/holoserve/connector/state.rb
|
74
73
|
- lib/holoserve/connector/tool/uploader.rb
|
75
74
|
- lib/holoserve/connector/tool.rb
|
76
75
|
- lib/holoserve/connector.rb
|
@@ -92,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
91
|
version: '0'
|
93
92
|
segments:
|
94
93
|
- 0
|
95
|
-
hash:
|
94
|
+
hash: 35958409398174168
|
96
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
96
|
none: false
|
98
97
|
requirements:
|
@@ -101,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
100
|
version: '0'
|
102
101
|
requirements: []
|
103
102
|
rubyforge_project: holoserve-connector
|
104
|
-
rubygems_version: 1.8.
|
103
|
+
rubygems_version: 1.8.15
|
105
104
|
signing_key:
|
106
105
|
specification_version: 3
|
107
106
|
summary: Connector library for HoloServe.
|
@@ -1,41 +0,0 @@
|
|
1
|
-
|
2
|
-
class Holoserve::Connector::Fixtures
|
3
|
-
|
4
|
-
def initialize(client)
|
5
|
-
@client = client
|
6
|
-
end
|
7
|
-
|
8
|
-
def upload(pattern)
|
9
|
-
Dir[ pattern ].each do |filename|
|
10
|
-
upload_file filename
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def download(id)
|
15
|
-
response = Transport::HTTP.request :get,
|
16
|
-
"#{@client.url}/fixtures/#{id}.yaml",
|
17
|
-
:expected_status_code => 200
|
18
|
-
YAML.load response
|
19
|
-
rescue Transport::UnexpectedStatusCodeError => error
|
20
|
-
raise Holoserve::Connector::Error, error.message unless error.status_code == 404
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
|
24
|
-
def clear!
|
25
|
-
Transport::JSON.request :delete, "#{@client.url}/fixtures"
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def upload_file(filename)
|
31
|
-
uploader = Holoserve::Connector::Tool::Uploader.new filename,
|
32
|
-
:post,
|
33
|
-
"#{@client.url}/fixtures",
|
34
|
-
:expected_status_code => 200
|
35
|
-
uploader.upload
|
36
|
-
rescue Transport::UnexpectedStatusCodeError => error
|
37
|
-
raise Holoserve::Connector::Error, "the file #{filename} has an invalid format" if error.status_code == 400
|
38
|
-
raise Holoserve::Connector::Error, error.message
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
|
2
|
-
class Holoserve::Connector::Situation
|
3
|
-
|
4
|
-
def initialize(client)
|
5
|
-
@client = client
|
6
|
-
end
|
7
|
-
|
8
|
-
def name=(value)
|
9
|
-
Transport::JSON.request :put, "#{@client.url}/situation", :parameters => { :name => value }
|
10
|
-
end
|
11
|
-
|
12
|
-
def name
|
13
|
-
response = Transport::JSON.request :get, "#{@client.url}/situation"
|
14
|
-
name = response["name"]
|
15
|
-
name == "" ? nil : name
|
16
|
-
end
|
17
|
-
|
18
|
-
def clear!
|
19
|
-
Transport::JSON.request :put, "#{@client.url}/situation", :parameters => { :name => nil }
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|