duracloud-client 0.9.1 → 0.10.0

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.
@@ -1,3 +1,3 @@
1
1
  module Duracloud
2
- VERSION = "0.9.1"
2
+ VERSION = "0.10.0"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -16,12 +16,10 @@ WebMock::Util::Headers.class_eval do
16
16
  end
17
17
  end
18
18
 
19
- Duracloud::Client.configure do |config|
20
- config.host = "example.com"
21
- config.user = "testuser"
22
- config.password = "testpass"
23
- config.silence_logging!
24
- end
19
+ Duracloud.host = "example.com"
20
+ Duracloud.user = "testuser"
21
+ Duracloud.password = "testpass"
22
+ Duracloud.silence_logging!
25
23
 
26
24
  RSpec.configure do |config|
27
25
  # rspec-expectations config goes here. You can use an alternate
@@ -1,26 +1,30 @@
1
1
  module Duracloud
2
2
  RSpec.describe CLI do
3
3
 
4
- subject { described_class.new(**opts) }
4
+ subject { described_class.new(*opts) }
5
5
 
6
6
  describe "find item" do
7
- let(:opts) { {command: "find", space_id: "foo", content_id: "bar"} }
7
+ let(:opts) { %w(find -s foo -c bar) }
8
8
  specify {
9
- expect(Commands::FindItem).to receive(:call).with(subject) { nil }
9
+ stub = stub_request(:head, "https://example.com/durastore/foo/bar")
10
+ expect(Commands::FindItem).to receive(:call).with(subject).and_call_original
10
11
  subject.execute
12
+ expect(stub).to have_been_requested
11
13
  }
12
14
  end
13
15
 
14
16
  describe "find space" do
15
- let(:opts) { {command: "find", space_id: "foo"} }
17
+ let(:opts) { %w(find -s foo) }
16
18
  specify {
17
- expect(Commands::FindSpace).to receive(:call).with(subject) { nil }
19
+ stub = stub_request(:head, "https://example.com/durastore/foo")
20
+ expect(Commands::FindSpace).to receive(:call).with(subject).and_call_original
18
21
  subject.execute
22
+ expect(stub).to have_been_requested
19
23
  }
20
24
  end
21
25
 
22
26
  describe "find items" do
23
- let(:opts) { {command: "find", space_id: "foo", infile: "/foo/bar"} }
27
+ let(:opts) { %w( find -s foo -f /foo/bar ) }
24
28
  specify {
25
29
  expect(Commands::FindItems).to receive(:call).with(subject) { nil }
26
30
  subject.execute
@@ -28,15 +32,17 @@ module Duracloud
28
32
  end
29
33
 
30
34
  describe "count" do
31
- let(:opts) { {command: "count", space_id: "foo"} }
35
+ let(:opts) { %w( count -s foo ) }
32
36
  specify {
33
- expect(Commands::Count).to receive(:call).with(subject) { nil }
37
+ stub = stub_request(:head, "https://example.com/durastore/foo")
38
+ expect(Commands::Count).to receive(:call).with(subject).and_call_original
34
39
  subject.execute
40
+ expect(stub).to have_been_requested
35
41
  }
36
42
  end
37
43
 
38
44
  describe "sync" do
39
- let(:opts) { {command: "sync", space_id: "foo", content_id: "bar", infile: "foo/bar"} }
45
+ let(:opts) { %w( sync -s foo -c bar -f /foo/bar ) }
40
46
  specify {
41
47
  expect(Commands::Sync).to receive(:call).with(subject) { nil }
42
48
  subject.execute
@@ -44,7 +50,7 @@ module Duracloud
44
50
  end
45
51
 
46
52
  describe "validate" do
47
- let(:opts) { {command: "validate", space_id: "foo", content_dir: "/tmp"} }
53
+ let(:opts) { %w( validate -s foo -d /tmp ) }
48
54
  specify {
49
55
  expect(Commands::Validate).to receive(:call).with(subject) { nil }
50
56
  subject.execute
@@ -52,7 +58,7 @@ module Duracloud
52
58
  end
53
59
 
54
60
  describe "download_manifest" do
55
- let(:opts) { {command: "download_manifest", space_id: "foo"} }
61
+ let(:opts) { %w( download_manifest -s foo ) }
56
62
  specify {
57
63
  expect(Commands::DownloadManifest).to receive(:call).with(subject) { nil }
58
64
  subject.execute
@@ -60,7 +66,7 @@ module Duracloud
60
66
  end
61
67
 
62
68
  describe "get_storage_report" do
63
- let(:opts) { {command: "get_storage_report", space_id: "foo"} }
69
+ let(:opts) { %w( get_storage_report -s foo ) }
64
70
  specify {
65
71
  expect(Commands::GetStorageReport).to receive(:call).with(subject) { nil }
66
72
  subject.execute
@@ -68,7 +74,7 @@ module Duracloud
68
74
  end
69
75
 
70
76
  describe "list content ids" do
71
- let(:opts) { {command: "list_content_ids", space_id: "foo"} }
77
+ let(:opts) { %w( list_content_ids -s foo ) }
72
78
  specify {
73
79
  expect(Commands::ListContentIds).to receive(:call).with(subject) { nil }
74
80
  subject.execute
@@ -76,12 +82,20 @@ module Duracloud
76
82
  end
77
83
 
78
84
  describe "list items" do
79
- let(:opts) { {command: "list_items", space_id: "foo"} }
85
+ let(:opts) { %w( list_items -s foo ) }
80
86
  specify {
81
87
  expect(Commands::ListItems).to receive(:call).with(subject) { nil }
82
88
  subject.execute
83
89
  }
84
90
  end
85
91
 
92
+ describe "store" do
93
+ let(:opts) { %w( store -s foo -c bar -f /foo/bar -t image/jpeg ) }
94
+ specify {
95
+ expect(Commands::StoreContent).to receive(:call).with(subject) { nil }
96
+ subject.execute
97
+ }
98
+ end
99
+
86
100
  end
87
101
  end
@@ -201,8 +201,7 @@ module Duracloud
201
201
  describe "when found" do
202
202
  before { stub_request(:delete, url) }
203
203
  it "deletes the content" do
204
- subject.delete
205
- expect(subject).to be_deleted
204
+ expect { subject.delete }.to change(subject, :deleted?).from(false).to(true)
206
205
  end
207
206
  end
208
207
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duracloud-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chandek-Stark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2017-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -52,26 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.7'
55
- - !ruby/object:Gem::Dependency
56
- name: activemodel
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '4.2'
62
- - - "<"
63
- - !ruby/object:Gem::Version
64
- version: '6'
65
- type: :runtime
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '4.2'
72
- - - "<"
73
- - !ruby/object:Gem::Version
74
- version: '6'
75
55
  - !ruby/object:Gem::Dependency
76
56
  name: nokogiri
77
57
  requirement: !ruby/object:Gem::Requirement
@@ -173,8 +153,6 @@ files:
173
153
  - Rakefile
174
154
  - bin/duracloud
175
155
  - duracloud.gemspec
176
- - gemfiles/Gemfile.activemodel-4.2
177
- - gemfiles/Gemfile.activemodel-5.0
178
156
  - lib/duracloud-client.rb
179
157
  - lib/duracloud.rb
180
158
  - lib/duracloud/abstract_entity.rb
@@ -199,20 +177,18 @@ files:
199
177
  - lib/duracloud/commands/get_storage_report_for_store.rb
200
178
  - lib/duracloud/commands/list_content_ids.rb
201
179
  - lib/duracloud/commands/list_items.rb
180
+ - lib/duracloud/commands/store_content.rb
202
181
  - lib/duracloud/commands/sync.rb
203
182
  - lib/duracloud/commands/validate.rb
204
- - lib/duracloud/configuration.rb
205
- - lib/duracloud/connection.rb
206
183
  - lib/duracloud/content.rb
207
184
  - lib/duracloud/content_manifest.rb
208
- - lib/duracloud/durastore_request.rb
209
185
  - lib/duracloud/error.rb
210
- - lib/duracloud/error_handler.rb
211
186
  - lib/duracloud/fast_sync_validation.rb
212
187
  - lib/duracloud/manifest.rb
213
188
  - lib/duracloud/properties.rb
214
189
  - lib/duracloud/request.rb
215
190
  - lib/duracloud/response.rb
191
+ - lib/duracloud/response_handler.rb
216
192
  - lib/duracloud/rest_methods.rb
217
193
  - lib/duracloud/space.rb
218
194
  - lib/duracloud/space_acls.rb
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
- gem "activemodel", "~> 4.2.7"
3
- gemspec path: "../"
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
- gem "activemodel", "~> 5.0.1"
3
- gemspec path: "../"
@@ -1,42 +0,0 @@
1
- require "logger"
2
- require "uri"
3
-
4
- module Duracloud
5
- class Configuration
6
-
7
- class << self
8
- attr_accessor :host, :port, :user, :password, :logger
9
-
10
- def silence_logging!
11
- self.logger = Logger.new(File::NULL)
12
- end
13
- end
14
-
15
- attr_reader :host, :port, :user, :password, :logger
16
-
17
- def initialize(host: nil, port: nil, user: nil, password: nil, logger: nil)
18
- @host = host || default(:host)
19
- @port = port || default(:port)
20
- @user = user || default(:user)
21
- @password = password || default(:password)
22
- @logger = logger || self.class.logger || Logger.new(STDERR)
23
- freeze
24
- end
25
-
26
- def base_url
27
- URI::HTTPS.build(host: host, port: port)
28
- end
29
-
30
- def inspect
31
- "#<#{self.class} host=#{host.inspect}, port=#{port.inspect}," \
32
- " user=#{user.inspect}>"
33
- end
34
-
35
- private
36
-
37
- def default(attr)
38
- self.class.send(attr) || ENV["DURACLOUD_#{attr.to_s.upcase}"]
39
- end
40
-
41
- end
42
- end
@@ -1,18 +0,0 @@
1
- require 'httpclient'
2
-
3
- module Duracloud
4
- #
5
- # An HTTP connection to DuraCloud.
6
- #
7
- # @note We are using HTTPClient because Net::HTTP capitalizes
8
- # request header names which is incompatible with DuraCloud's
9
- # custom case-sensitive content property headers (x-dura-meta-*).
10
- #
11
- class Connection < HTTPClient
12
- def initialize(client, base_path = '/')
13
- base_url = client.base_url + base_path
14
- super(base_url: base_url, force_basic_auth: true)
15
- set_auth(client.base_url, client.user, client.password)
16
- end
17
- end
18
- end
@@ -1,7 +0,0 @@
1
- module Duracloud
2
- class DurastoreRequest < Request
3
- def base_path
4
- '/durastore/'
5
- end
6
- end
7
- end
@@ -1,56 +0,0 @@
1
- module Duracloud
2
- class ErrorHandler
3
- def self.call(response)
4
- new(response).call
5
- end
6
-
7
- attr_reader :response
8
-
9
- def initialize(response)
10
- @response = response # XXX dup?
11
- end
12
-
13
- def call
14
- message = response_has_error_message? ? response.body : status_message
15
- raise handle_status, message
16
- end
17
-
18
- def status_message
19
- [response.status, response.reason].join(' ')
20
- end
21
-
22
- def server_error?
23
- response.status >= 500
24
- end
25
-
26
- def handle_status
27
- send("handle_#{response.status}")
28
- rescue NoMethodError
29
- server_error? ? handle_server_error : handle_default
30
- end
31
-
32
- def handle_server_error
33
- ServerError
34
- end
35
-
36
- def handle_default
37
- Error
38
- end
39
-
40
- def handle_400
41
- BadRequestError
42
- end
43
-
44
- def handle_404
45
- NotFoundError
46
- end
47
-
48
- def handle_409
49
- ConflictError
50
- end
51
-
52
- def response_has_error_message?
53
- response.plain_text? && response.has_body?
54
- end
55
- end
56
- end