orchestrate.io 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/Guardfile +9 -0
- data/LICENSE +20 -0
- data/LICENSE.txt +22 -0
- data/README.md +108 -0
- data/Rakefile +5 -0
- data/bin/orchestrate.io +6 -0
- data/lib/orchestrate.io/client.rb +58 -0
- data/lib/orchestrate.io/configuration.rb +43 -0
- data/lib/orchestrate.io/core_ext/string.rb +19 -0
- data/lib/orchestrate.io/core_ext.rb +5 -0
- data/lib/orchestrate.io/events.rb +47 -0
- data/lib/orchestrate.io/graph.rb +52 -0
- data/lib/orchestrate.io/helper.rb +20 -0
- data/lib/orchestrate.io/key_value.rb +46 -0
- data/lib/orchestrate.io/logging.rb +34 -0
- data/lib/orchestrate.io/request.rb +51 -0
- data/lib/orchestrate.io/search.rb +46 -0
- data/lib/orchestrate.io/version.rb +5 -0
- data/lib/orchestrate.io.rb +21 -0
- data/orchestrate.io.gemspec +33 -0
- data/spec/orchestrate.io/client_spec.rb +111 -0
- data/spec/orchestrate.io/events_spec.rb +51 -0
- data/spec/orchestrate.io/graph_spec.rb +51 -0
- data/spec/orchestrate.io/key_value_spec.rb +67 -0
- data/spec/orchestrate.io/request_spec.rb +54 -0
- data/spec/orchestrate.io/search_spec.rb +25 -0
- data/spec/orchestrate.io_spec.rb +47 -0
- data/spec/spec_helper.rb +61 -0
- data/spec/support/fixtures/get_events_by_key.json +12 -0
- data/spec/support/fixtures/get_graph.json +30 -0
- data/spec/support/fixtures/get_value_by_key.json +18 -0
- data/spec/support/fixtures/get_values_by_key.json +18 -0
- data/spec/support/fixtures/search_collection.json +32 -0
- data/spec/support/pseudo_orchestrate.io.rb +61 -0
- metadata +251 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'orchestrate.io/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "orchestrate.io"
|
8
|
+
spec.version = OrchestrateIo::VERSION
|
9
|
+
spec.authors = ["azukiwasher"]
|
10
|
+
spec.email = ["azukiwasher@higanworks.com"]
|
11
|
+
spec.description = %q{A Ruby wrapper for the Orchestrate.io API}
|
12
|
+
spec.summary = %q{A Ruby wrapper for the Orchestrate.io API.}
|
13
|
+
spec.homepage = "https://github.com/azukiwasher/ruby-orchestrate.io"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "httparty", "~> 0.12.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency 'simplecov'
|
27
|
+
spec.add_development_dependency 'simplecov-rcov'
|
28
|
+
spec.add_development_dependency 'webmock'
|
29
|
+
spec.add_development_dependency 'guard-rspec'
|
30
|
+
spec.add_development_dependency 'timecop'
|
31
|
+
spec.add_development_dependency 'sinatra'
|
32
|
+
spec.add_development_dependency 'rb-readline'
|
33
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe OrchestrateIo::Client do
|
5
|
+
let(:default_options) {{
|
6
|
+
:request_headers=>{
|
7
|
+
"User-Agent"=>"Orchestrate.io Ruby Gem #{OrchestrateIo::Version}",
|
8
|
+
"Content-Type"=>"application/json; charset=utf-8",
|
9
|
+
"Accept-Language"=>"ja,en"
|
10
|
+
},
|
11
|
+
:endpoint=>"https://api.orchestrate.io",
|
12
|
+
:api_key=>"",
|
13
|
+
:version=>"#{OrchestrateIo.options[:version]}",
|
14
|
+
:verbose=>false
|
15
|
+
}}
|
16
|
+
|
17
|
+
describe '::new' do
|
18
|
+
it 'initializes attributes' do
|
19
|
+
client = OrchestrateIo.new(api_key: 'abc')
|
20
|
+
expect(client.request_headers).to eql default_options[:request_headers]
|
21
|
+
expect(client.endpoint).to eql default_options[:endpoint]
|
22
|
+
expect(client.verbose).to eql default_options[:verbose]
|
23
|
+
expect(client.version).to eql default_options[:version]
|
24
|
+
expect(client.api_key).to eql 'abc'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'initializes options for client' do
|
28
|
+
OrchestrateIo::Client.should_receive(:format).with(:json)
|
29
|
+
OrchestrateIo::Client.should_receive(:base_uri).with(default_options[:endpoint])
|
30
|
+
OrchestrateIo::Client.should_receive(:headers).with(default_options[:request_headers])
|
31
|
+
OrchestrateIo.new(api_key: 'abc')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'sets logger level to debug' do
|
35
|
+
OrchestrateIo.new(api_key: 'abc', verbose: true)
|
36
|
+
expect(OrchestrateIo.logger.level).to eql Logger::DEBUG
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'sets logger level to info' do
|
40
|
+
OrchestrateIo.new(api_key: 'abc', verbose: false)
|
41
|
+
expect(OrchestrateIo.logger.level).to eql Logger::INFO
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#request" do
|
46
|
+
pending "TODO: A lesson for Fujiwara san"
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#method_missing" do
|
50
|
+
let(:client){ OrchestrateIo::Client.new(api_key: 'abc') }
|
51
|
+
before { OrchestrateIo.stub(:request) }
|
52
|
+
|
53
|
+
context '#key_value' do
|
54
|
+
it 'creates a new key_value ' do
|
55
|
+
request_data = '{ "Title": "The Godfather" }'
|
56
|
+
expect(
|
57
|
+
client.key_value(:get){
|
58
|
+
collection "films"
|
59
|
+
key "the_godfather"
|
60
|
+
}
|
61
|
+
).to be_an_instance_of OrchestrateIo::KeyValue
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context '#search' do
|
66
|
+
it 'creates a new search instance' do
|
67
|
+
search_query = "Genre:crime"
|
68
|
+
expect(
|
69
|
+
client.search(:get){
|
70
|
+
collection "films"
|
71
|
+
query search_query
|
72
|
+
}
|
73
|
+
).to be_an_instance_of OrchestrateIo::Search
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context '#events' do
|
78
|
+
it 'creates a new event instance' do
|
79
|
+
request_data = '{ "User": "peter_bradshaw", "Text": "A measured, deathly serious epic." }'
|
80
|
+
expect(
|
81
|
+
client.events(:get){
|
82
|
+
collection "films"
|
83
|
+
key "the_godfather"
|
84
|
+
type "comments"
|
85
|
+
}
|
86
|
+
).to be_an_instance_of OrchestrateIo::Events
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context '#graph' do
|
91
|
+
it 'creates a new graph instance' do
|
92
|
+
expect(
|
93
|
+
client.graph(:get){
|
94
|
+
collection "films"
|
95
|
+
key "the_godfather"
|
96
|
+
relation "sequel"
|
97
|
+
}
|
98
|
+
).to be_an_instance_of OrchestrateIo::Graph
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#basic_auth" do
|
104
|
+
let(:client){ OrchestrateIo::Client.new(api_key: 'abc') }
|
105
|
+
it "returns an object for the basic authentication" do
|
106
|
+
hash = client.__send__(:basic_auth)
|
107
|
+
expect(hash[:basic_auth][:username]).to eql 'abc'
|
108
|
+
expect(hash[:basic_auth][:password]).to be_empty
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe OrchestrateIo::Events do
|
5
|
+
let(:client) { OrchestrateIo.new(api_key: 'abc') }
|
6
|
+
|
7
|
+
describe "PUT /:version/:collection/:key/events/:type" do
|
8
|
+
let(:request) {
|
9
|
+
client.events :put do
|
10
|
+
collection "films"
|
11
|
+
key "the_godfather"
|
12
|
+
type "comments"
|
13
|
+
data "{\"Text\" :\"It's hard to find a moment in the film that isn't great.\"}"
|
14
|
+
end
|
15
|
+
}
|
16
|
+
|
17
|
+
it "performs a request with the correct options" do
|
18
|
+
client.should_receive(:request).
|
19
|
+
with(:put, "/v0/films/the_godfather/events/comments", {:body=>"{\"Text\" :\"It's hard to find a moment in the film that isn't great.\"}"})
|
20
|
+
request.perform
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns http created with no body" do
|
24
|
+
response = request.perform
|
25
|
+
expect(response.code).to eql 201
|
26
|
+
expect(response.parsed_response).to be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "GET /:version/:collection/:key/events/:type" do
|
31
|
+
let(:request) {
|
32
|
+
client.events :get do
|
33
|
+
collection "films"
|
34
|
+
key "the_godfather"
|
35
|
+
type "comments"
|
36
|
+
end
|
37
|
+
}
|
38
|
+
|
39
|
+
it "performs a request with the correct options" do
|
40
|
+
client.should_receive(:request).
|
41
|
+
with(:get, "/v0/films/the_godfather/events/comments", {})
|
42
|
+
request.perform
|
43
|
+
end
|
44
|
+
|
45
|
+
it "returns http created with no body" do
|
46
|
+
response = request.perform
|
47
|
+
expect(response.code).to eql 200
|
48
|
+
expect(response.parsed_response["results"]).to be_instance_of Array
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe OrchestrateIo::Graph do
|
5
|
+
let(:client) { OrchestrateIo::Client.new(api_key: 'abc') }
|
6
|
+
|
7
|
+
describe "PUT /:version/:collection/:key/relations/:relation/:to_collection/:to_key" do
|
8
|
+
let(:request){
|
9
|
+
client.graph :put do
|
10
|
+
collection "films"
|
11
|
+
key "the_godfather"
|
12
|
+
relation "sequel"
|
13
|
+
to_collection "films"
|
14
|
+
to_key "the_godfather_part_2"
|
15
|
+
end
|
16
|
+
}
|
17
|
+
|
18
|
+
it "performs a request with the correct options" do
|
19
|
+
client.should_receive(:request).
|
20
|
+
with(:put, "/v0/films/the_godfather/relations/sequel/films/the_godfather_part_2", {})
|
21
|
+
request.perform
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns http created with no body" do
|
25
|
+
response = request.perform
|
26
|
+
expect(response.code).to eql 201
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "GET /:version/:collection/:key/relations/:relation" do
|
31
|
+
let(:request){
|
32
|
+
client.graph :get do
|
33
|
+
collection "films"
|
34
|
+
key "the_godfather"
|
35
|
+
relation "sequel"
|
36
|
+
end
|
37
|
+
}
|
38
|
+
|
39
|
+
it "performs a request with the correct options" do
|
40
|
+
client.should_receive(:request).
|
41
|
+
with(:get, "/v0/films/the_godfather/relations/sequel", {})
|
42
|
+
request.perform
|
43
|
+
end
|
44
|
+
|
45
|
+
it "returns http ok with body" do
|
46
|
+
response = request.perform
|
47
|
+
expect(response.code).to eql 200
|
48
|
+
expect(response.parsed_response["results"].first["value"]["Title"]).to eql "The Godfather: Part II"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe OrchestrateIo::KeyValue do
|
5
|
+
let(:client){ OrchestrateIo.new(api_key: 'abc') }
|
6
|
+
|
7
|
+
describe "PUT /:version/:collection/:key" do
|
8
|
+
let(:request){
|
9
|
+
client.key_value :put do
|
10
|
+
collection "films"
|
11
|
+
key "the_godfather"
|
12
|
+
data "{\"Title\": \"The Godfather\"}"
|
13
|
+
end
|
14
|
+
}
|
15
|
+
|
16
|
+
it "performs a request with the correct options" do
|
17
|
+
client.should_receive(:request).
|
18
|
+
with(:put, "/v0/films/the_godfather", {:body=>"{\"Title\": \"The Godfather\"}"})
|
19
|
+
request.perform
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns http created with no body" do
|
23
|
+
response = request.perform
|
24
|
+
expect(response.code).to eql 201
|
25
|
+
expect(response.parsed_response).to be_nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "GET /:version/:collection/:key" do
|
30
|
+
let(:request){
|
31
|
+
client.key_value :get do
|
32
|
+
collection "films"
|
33
|
+
key "the_godfather"
|
34
|
+
end
|
35
|
+
}
|
36
|
+
|
37
|
+
it "performs a request with the correct options" do
|
38
|
+
client.should_receive(:request).with(:get, "/v0/films/the_godfather", {})
|
39
|
+
request.perform
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns http ok with body" do
|
43
|
+
response = request.perform
|
44
|
+
expect(response.code).to eql 200
|
45
|
+
expect(response.parsed_response["Director"]).to eql "Akira Kurosawa"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "DELETE /:version/:collection/:key" do
|
50
|
+
let(:request){
|
51
|
+
client.key_value :delete do
|
52
|
+
collection "films"
|
53
|
+
key "the_godfather"
|
54
|
+
end
|
55
|
+
}
|
56
|
+
|
57
|
+
it "performs a request with the correct options" do
|
58
|
+
client.should_receive(:request).with(:delete, "/v0/films/the_godfather", {})
|
59
|
+
request.perform
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns http no content" do
|
63
|
+
response = request.perform
|
64
|
+
expect(response.code).to eql 204
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OrchestrateIo::Request do
|
4
|
+
class Client
|
5
|
+
def version ; "v0" ; end
|
6
|
+
def request(http_method, uri, options={}) ; 200 ; end
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:request){
|
10
|
+
OrchestrateIo::Request.new(
|
11
|
+
args = {
|
12
|
+
client: Client.new,
|
13
|
+
http_method: :get,
|
14
|
+
uri: "/:version/:collection/:key",
|
15
|
+
options: Hash[:body, :data]
|
16
|
+
}
|
17
|
+
) do
|
18
|
+
collection "films"
|
19
|
+
key "the_godfather"
|
20
|
+
data "{\"Title\": \"The Godfather\"}"
|
21
|
+
end
|
22
|
+
}
|
23
|
+
|
24
|
+
describe "#uri" do
|
25
|
+
it "returns a request uri" do
|
26
|
+
expect(request.uri).to eql "/v0/films/the_godfather"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#parse_options" do
|
31
|
+
context "simple options" do
|
32
|
+
it "returns a request data" do
|
33
|
+
options = Hash[:body, :data]
|
34
|
+
result = {:body=>"{\"Title\": \"The Godfather\"}"}
|
35
|
+
expect(request.parse_options(options)).to eql result
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "nested options" do
|
40
|
+
it "returns a request data" do
|
41
|
+
options = {query:{query: :data}}
|
42
|
+
result = {:query=>{:query=>"{\"Title\": \"The Godfather\"}"}}
|
43
|
+
expect(request.parse_options(options)).to eql result
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#perform" do
|
49
|
+
it "perform a request to the uri with the options" do
|
50
|
+
Client.any_instance.should_receive(:request).with(:get, "/v0/films/the_godfather", {:body=>"{\"Title\": \"The Godfather\"}"}).and_return(200)
|
51
|
+
expect(request.perform). to eql 200
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe OrchestrateIo::Search do
|
5
|
+
let(:client){ OrchestrateIo::Client.new(api_key: 'abc') }
|
6
|
+
let(:request){
|
7
|
+
client.search :get do
|
8
|
+
collection "films"
|
9
|
+
query "Genre:crime"
|
10
|
+
end
|
11
|
+
}
|
12
|
+
|
13
|
+
describe "GET /:version/:collection" do
|
14
|
+
it "performs a request with the correct options" do
|
15
|
+
client.should_receive(:request).with(:get, "/v0/films", {:query=>{:query=>"Genre:crime"}})
|
16
|
+
request.perform
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns http ok with body" do
|
20
|
+
response = request.perform
|
21
|
+
expect(response.code).to eql 200
|
22
|
+
expect(response.parsed_response["results"].first["value"]["Genre"]).to eql "Crime, Drama"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe OrchestrateIo do
|
5
|
+
let(:default_options) {{
|
6
|
+
:request_headers=>{
|
7
|
+
"User-Agent"=>"Orchestrate.io Ruby Gem #{OrchestrateIo::Version}",
|
8
|
+
"Content-Type"=>"application/json; charset=utf-8",
|
9
|
+
"Accept-Language"=>"ja,en"
|
10
|
+
},
|
11
|
+
:endpoint=>"https://api.orchestrate.io",
|
12
|
+
:api_key=>"",
|
13
|
+
:version=>"#{OrchestrateIo.options[:version]}",
|
14
|
+
:verbose=>false
|
15
|
+
}}
|
16
|
+
|
17
|
+
describe '::new' do
|
18
|
+
it 'creates a new client' do
|
19
|
+
expect(OrchestrateIo.new(api_key: 'abc')).to be_an_instance_of OrchestrateIo::Client
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.logger' do
|
24
|
+
it 'initializes logger' do
|
25
|
+
expect(OrchestrateIo.logger).to be_an_instance_of Logger
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'initializes logger by custom formatter' do
|
29
|
+
pending
|
30
|
+
expect(OrchestrateIo.logger.formatter).to be_an_instance_of OrchestrateIo::Logging::Pretty
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.logger=' do
|
35
|
+
it 'initializes logger by give logger object' do
|
36
|
+
OrchestrateIo.logger = Logger.new('application.log', 20, 'daily')
|
37
|
+
expect(OrchestrateIo.logger).to be_an_instance_of Logger
|
38
|
+
OrchestrateIo.logger = nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.options' do
|
43
|
+
it 'returns options reset to defaults' do
|
44
|
+
expect(OrchestrateIo.options).to eql default_options
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
3
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
4
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
5
|
+
# loaded once.
|
6
|
+
#
|
7
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
8
|
+
|
9
|
+
unless ENV['CI']
|
10
|
+
require 'simplecov'
|
11
|
+
require 'simplecov-rcov'
|
12
|
+
|
13
|
+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
14
|
+
SimpleCov.start do
|
15
|
+
add_filter 'spec'
|
16
|
+
add_filter 'vendor'
|
17
|
+
add_filter 'features'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'orchestrate.io'
|
22
|
+
require 'rspec'
|
23
|
+
require 'webmock/rspec'
|
24
|
+
require 'json'
|
25
|
+
require 'timecop'
|
26
|
+
|
27
|
+
# Use Webmock to route all requests to our Sinatra application `PseudoOrchestrateIo`.
|
28
|
+
require_relative 'support/pseudo_orchestrate.io'
|
29
|
+
|
30
|
+
# Keep the client from external requests.
|
31
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
32
|
+
|
33
|
+
RSpec.configure do |config|
|
34
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
35
|
+
config.run_all_when_everything_filtered = true
|
36
|
+
config.filter_run :focus
|
37
|
+
|
38
|
+
# Run specs in random order to surface order dependencies. If you find an
|
39
|
+
# order dependency and want to debug it, you can fix the order by providing
|
40
|
+
# the seed, which is printed after each run.
|
41
|
+
# --seed 1234
|
42
|
+
config.order = 'random'
|
43
|
+
|
44
|
+
config.expect_with :rspec do |c|
|
45
|
+
c.syntax = :expect
|
46
|
+
end
|
47
|
+
|
48
|
+
# Stub any HTTP requests to `api.orchestrate.io` with WebMock
|
49
|
+
# and returns prepended content.
|
50
|
+
config.before(:each) do
|
51
|
+
stub_request(:any, /api.orchestrate.io/).to_rack(PseudoOrchestrateIo.new)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def load_json(string)
|
56
|
+
JSON.parse(string)
|
57
|
+
end
|
58
|
+
|
59
|
+
def dump_json(object)
|
60
|
+
JSON.pretty_generate(object)
|
61
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"results": [
|
3
|
+
{
|
4
|
+
"path": {
|
5
|
+
"collection": "films",
|
6
|
+
"key": "the_godfather_part_2",
|
7
|
+
"ref": "dd76dd28ff14d348"
|
8
|
+
},
|
9
|
+
"value": {
|
10
|
+
"Title": "The Godfather: Part II",
|
11
|
+
"Year": 1974,
|
12
|
+
"Rated": "R",
|
13
|
+
"Released": "20 Dec 1974",
|
14
|
+
"Runtime": "3 h 20 min",
|
15
|
+
"Genre": "Crime, Drama",
|
16
|
+
"Director": "Francis Ford Coppola",
|
17
|
+
"Writer": "Francis Ford Coppola, Mario Puzo",
|
18
|
+
"Actors": "Al Pacino, Robert De Niro, Robert Duvall, Diane Keaton",
|
19
|
+
"Plot": "The early life and career of Vito Corleone in 1920s New York is portrayed while his son, Michael, expands and tightens his grip on his crime syndicate stretching from Lake Tahoe, Nevada to pre-revolution 1958 Cuba.",
|
20
|
+
"Poster": "http://ia.media-imdb.com/images/M/MV5BNDc2NTM3MzU1Nl5BMl5BanBnXkFtZTcwMTA5Mzg3OA@@._V1_SX300.jpg",
|
21
|
+
"imdbRating": 9,
|
22
|
+
"imdbVotes": "473,096",
|
23
|
+
"imdbID": "tt0071562",
|
24
|
+
"Type": "movie",
|
25
|
+
"Response": "True"
|
26
|
+
}
|
27
|
+
}
|
28
|
+
],
|
29
|
+
"count": 1
|
30
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"Title": "Rashomon",
|
3
|
+
"Year": "1950",
|
4
|
+
"Rated": "Unrated",
|
5
|
+
"Released": "26 Dec 1951",
|
6
|
+
"Runtime": "1 h 28 min",
|
7
|
+
"Genre": "Crime, Drama",
|
8
|
+
"Director": "Akira Kurosawa",
|
9
|
+
"Writer": "Ryûnosuke Akutagawa, Akira Kurosawa",
|
10
|
+
"Actors": "Toshirô Mifune, Machiko Kyô, Masayuki Mori, Takashi Shimura",
|
11
|
+
"Plot": "A heinous crime and its aftermath are recalled from differing points of view.",
|
12
|
+
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjEzMzA4NDE2OF5BMl5BanBnXkFtZTcwNTc5MDI2NQ@@._V1_SX300.jpg",
|
13
|
+
"imdbRating": "8.4",
|
14
|
+
"imdbVotes": "69,263",
|
15
|
+
"imdbID": "tt0042876",
|
16
|
+
"Type": "movie",
|
17
|
+
"Response": "True"
|
18
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"Title": "Rashomon",
|
3
|
+
"Year": "1950",
|
4
|
+
"Rated": "Unrated",
|
5
|
+
"Released": "26 Dec 1951",
|
6
|
+
"Runtime": "1 h 28 min",
|
7
|
+
"Genre": "Crime, Drama",
|
8
|
+
"Director": "Akira Kurosawa",
|
9
|
+
"Writer": "Ryûnosuke Akutagawa, Akira Kurosawa",
|
10
|
+
"Actors": "Toshirô Mifune, Machiko Kyô, Masayuki Mori, Takashi Shimura",
|
11
|
+
"Plot": "A heinous crime and its aftermath are recalled from differing points of view.",
|
12
|
+
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjEzMzA4NDE2OF5BMl5BanBnXkFtZTcwNTc5MDI2NQ@@._V1_SX300.jpg",
|
13
|
+
"imdbRating": "8.4",
|
14
|
+
"imdbVotes": "69,263",
|
15
|
+
"imdbID": "tt0042876",
|
16
|
+
"Type": "movie",
|
17
|
+
"Response": "True"
|
18
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
{
|
2
|
+
"results": [
|
3
|
+
{
|
4
|
+
"path": {
|
5
|
+
"collection": "films",
|
6
|
+
"key": "kurosawa",
|
7
|
+
"ref": "76bc5546c0a60e92"
|
8
|
+
},
|
9
|
+
"value": {
|
10
|
+
"Title": "Rashomon",
|
11
|
+
"Year": "1950",
|
12
|
+
"Rated": "Unrated",
|
13
|
+
"Released": "26 Dec 1951",
|
14
|
+
"Runtime": "1 h 28 min",
|
15
|
+
"Genre": "Crime, Drama",
|
16
|
+
"Director": "Akira Kurosawa",
|
17
|
+
"Writer": "Ryûnosuke Akutagawa, Akira Kurosawa",
|
18
|
+
"Actors": "Toshirô Mifune, Machiko Kyô, Masayuki Mori, Takashi Shimura",
|
19
|
+
"Plot": "A heinous crime and its aftermath are recalled from differing points of view.",
|
20
|
+
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjEzMzA4NDE2OF5BMl5BanBnXkFtZTcwNTc5MDI2NQ@@._V1_SX300.jpg",
|
21
|
+
"imdbRating": "8.4",
|
22
|
+
"imdbVotes": "69,263",
|
23
|
+
"imdbID": "tt0042876",
|
24
|
+
"Type": "movie",
|
25
|
+
"Response": "True"
|
26
|
+
},
|
27
|
+
"score": 0.3665771186351776
|
28
|
+
}
|
29
|
+
],
|
30
|
+
"total_count": 1,
|
31
|
+
"count": 1
|
32
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'sinatra/base'
|
3
|
+
|
4
|
+
class PseudoOrchestrateIo < Sinatra::Base
|
5
|
+
|
6
|
+
# == KeyValue
|
7
|
+
|
8
|
+
# PUT /:version/:collection/:key
|
9
|
+
put "/:version/:collection/:key" do
|
10
|
+
json_response 201
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /:version/:collection/:key
|
14
|
+
get "/:version/:collection/:key" do
|
15
|
+
json_response 200, "get_values_by_key.json"
|
16
|
+
end
|
17
|
+
|
18
|
+
# DELETE /:version/:collection/:key
|
19
|
+
delete "/:version/:collection/:key" do
|
20
|
+
json_response 204
|
21
|
+
end
|
22
|
+
|
23
|
+
# == Search
|
24
|
+
|
25
|
+
# GET /:version/:collection
|
26
|
+
get "/:version/:collection" do
|
27
|
+
json_response 200, "search_collection.json"
|
28
|
+
end
|
29
|
+
|
30
|
+
# == Events
|
31
|
+
|
32
|
+
# PUT /:version/:collection/:key/events/:type
|
33
|
+
put "/:version/:collection/:key/events/:type" do
|
34
|
+
json_response 201
|
35
|
+
end
|
36
|
+
|
37
|
+
# GET /:version/:collection/:key/events/:type
|
38
|
+
get "/:version/:collection/:key/events/:type" do
|
39
|
+
json_response 200, "get_events_by_key.json"
|
40
|
+
end
|
41
|
+
|
42
|
+
# == Graph
|
43
|
+
|
44
|
+
# PUT /:version/:collection/:key/relations/:relation
|
45
|
+
put "/:version/:collection/:key/relations/:relation/:to_collection/:to_key" do
|
46
|
+
json_response 201
|
47
|
+
end
|
48
|
+
|
49
|
+
# GET /:version/:collection/:key/relations/:relation
|
50
|
+
get "/:version/:collection/:key/relations/:relation" do
|
51
|
+
json_response 200, "get_graph.json"
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def json_response(response_code, filename="")
|
57
|
+
content_type :json
|
58
|
+
status response_code
|
59
|
+
File.open(File.join(File.dirname(__FILE__), 'fixtures', filename), 'rb').read unless filename.empty?
|
60
|
+
end
|
61
|
+
end
|