duracloud-client 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b304d53dd688ed00817d59d286e32a5d53f88acc
4
- data.tar.gz: 065f2f3e9f0307f83e863f8ba7b1a60b680414e5
3
+ metadata.gz: 597a70d0d1ce9abc360fe01770e5dd4ed058604c
4
+ data.tar.gz: ef764b6b7e68c8dfe9899ff46f5ab3f325a006d5
5
5
  SHA512:
6
- metadata.gz: d73d05c4ef0bbd91a4928b79c2c260fdec0b755ece9a43423eac2229a56874c65e24e0e7cf8a7830dcabd02a293a0945a20a585c8bb2790493dae9a5d2be9220
7
- data.tar.gz: 6f2edaffb35c789e94e264c4f97607129e403d6673f52dcf6a28af28719e50b82c4fe0b703555923aa417144a38962300c7e8fc11ef293cc18d8f50cbc24b13c
6
+ metadata.gz: f7da0a6da94606f9d25e3164c84999c602d7ece4c9ea62930abe5b3b7816f0f551ef797303a04a3b6af7ed48e8509b66925121c9a3e38cc6c27746c59035ae77
7
+ data.tar.gz: e05f77e6a948cf0008ccddb0de25f0f9ed0c07d5fc1a9f5b77796c9e0fee6f4ab7d0341f9a31d6ca283bcdd36ff18a3fe217b05fe5ee7d9fcb3e0a81b4b2c9b6
data/lib/duracloud.rb CHANGED
@@ -1,11 +1,24 @@
1
1
  require "duracloud/version"
2
2
  require "duracloud/error"
3
- require "duracloud/client"
4
- require "duracloud/request"
5
- require "duracloud/content"
6
- require "duracloud/store"
7
- require "duracloud/space"
8
3
 
9
4
  module Duracloud
10
-
5
+ autoload :BitIntegrityReport, "duracloud/bit_integrity_report"
6
+ autoload :Client, "duracloud/client"
7
+ autoload :Configuration, "duracloud/configuration"
8
+ autoload :Connection, "duracloud/connection"
9
+ autoload :Content, "duracloud/content"
10
+ autoload :ContentProperties, "duracloud/content_properties"
11
+ autoload :DurastoreRequest, "duracloud/durastore_request"
12
+ autoload :ErrorHandler, "duracloud/error_handler"
13
+ autoload :HasProperties, "duracloud/has_properties"
14
+ autoload :Manifest, "duracloud/manifest"
15
+ autoload :Persistence, "duracloud/persistence"
16
+ autoload :Properties, "duracloud/properties"
17
+ autoload :Request, "duracloud/request"
18
+ autoload :Response, "duracloud/response"
19
+ autoload :RestMethods, "duracloud/rest_methods"
20
+ autoload :Space, "duracloud/space"
21
+ autoload :SpaceAcls, "duracloud/space_acls"
22
+ autoload :SpaceProperties, "duracloud/space_properties"
23
+ autoload :Store, "duracloud/store"
11
24
  end
@@ -0,0 +1,63 @@
1
+ require "date"
2
+ require "csv"
3
+
4
+ module Duracloud
5
+ class BitIntegrityReport
6
+
7
+ SUCCESS = "SUCCESS".freeze
8
+ FAILURE = "FAILURE".freeze
9
+
10
+ CSV_OPTS = {
11
+ col_sep: '\t',
12
+ headers: :first_row,
13
+ write_headers: true,
14
+ return_headers: true,
15
+ }
16
+
17
+ def self.success?(space_id)
18
+ new(space_id).success?
19
+ end
20
+
21
+ attr_reader :space_id
22
+
23
+ def initialize(space_id)
24
+ @space_id = space_id
25
+ end
26
+
27
+ def data
28
+ report.body
29
+ end
30
+
31
+ def completion_date
32
+ DateTime.parse(properties["Bit-Integrity-Report-Completion-Date"].first)
33
+ end
34
+
35
+ def result
36
+ properties["Bit-Integrity-Report-Result"].first
37
+ end
38
+
39
+ def csv(opts = {})
40
+ CSV.new(data, CSV_OPTS.merge(opts))
41
+ end
42
+
43
+ def success?
44
+ result == SUCCESS
45
+ end
46
+
47
+ private
48
+
49
+ def report
50
+ @report ||= Client.get_bit_integrity_report(space_id)
51
+ end
52
+
53
+ def properties
54
+ @properties ||= if @report
55
+ report.headers
56
+ else
57
+ response = Client.get_bit_integrity_report_properties(space_id)
58
+ response.headers
59
+ end
60
+ end
61
+
62
+ end
63
+ end
@@ -1,10 +1,5 @@
1
1
  require "forwardable"
2
2
 
3
- require "duracloud/configuration"
4
- require "duracloud/connection"
5
- require "duracloud/error_handler"
6
- require "duracloud/rest_methods"
7
-
8
3
  module Duracloud
9
4
  class Client
10
5
  extend Forwardable
@@ -2,10 +2,6 @@ require "uri"
2
2
  require "stringio"
3
3
  require "active_model"
4
4
 
5
- require "duracloud/content_properties"
6
- require "duracloud/persistence"
7
- require "duracloud/has_properties"
8
-
9
5
  module Duracloud
10
6
  #
11
7
  # A piece of content in DuraCloud
@@ -1,11 +1,7 @@
1
- require "duracloud/properties"
2
-
3
1
  module Duracloud
4
2
  class ContentProperties < Properties
5
-
6
3
  def self.property?(prop)
7
4
  super && !( space_property?(prop) || space_acl?(prop) || copy_content_property?(prop) )
8
5
  end
9
-
10
6
  end
11
7
  end
@@ -1,5 +1,3 @@
1
- require "duracloud/request"
2
-
3
1
  module Duracloud
4
2
  class DurastoreRequest < Request
5
3
  def base_path
@@ -0,0 +1,24 @@
1
+ require "csv"
2
+
3
+ module Duracloud
4
+ class Manifest
5
+
6
+ CSV_OPTS = {
7
+ col_sep: '\t',
8
+ headers: :first_row,
9
+ write_headers: true,
10
+ return_headers: true,
11
+ }
12
+
13
+ def self.csv(space_id, csv_opts: {})
14
+ data = raw(space_id)
15
+ CSV.new(data, CSV_OPTS.merge(csv_opts))
16
+ end
17
+
18
+ def self.raw(space_id)
19
+ response = Client.get_manifest(space_id)
20
+ response.body
21
+ end
22
+
23
+ end
24
+ end
@@ -1,6 +1,3 @@
1
- require "duracloud/connection"
2
- require "duracloud/response"
3
-
4
1
  module Duracloud
5
2
  class Request
6
3
  attr_reader :client, :url, :http_method, :body, :headers, :query
@@ -1,5 +1,3 @@
1
- require "duracloud/durastore_request"
2
-
3
1
  module Duracloud
4
2
  module RestMethods
5
3
 
@@ -56,27 +54,27 @@ module Duracloud
56
54
  end
57
55
 
58
56
  def get_audit_log
59
- raise NotImplementedError
57
+ durastore :get, "audit/#{space_id}"
60
58
  end
61
59
 
62
- def get_manifest
63
- raise NotImplementedError
60
+ def get_manifest(space_id)
61
+ durastore :get, "manifest/#{space_id}"
64
62
  end
65
63
 
66
- def get_bit_integrity_report
67
- raise NotImplementedError
64
+ def get_bit_integrity_report(space_id)
65
+ durastore :get, "bit-integrity/#{space_id}"
68
66
  end
69
67
 
70
- def get_bit_integrity_report_properties
71
- raise NotImplementedError
68
+ def get_bit_integrity_report_properties(space_id)
69
+ durastore :head, "bit-integrity/#{space_id}"
72
70
  end
73
71
 
74
72
  def get_tasks
75
- raise NotImplementedError
73
+ raise NotImplementedError, "The API method 'Get Tasks' has not been implemented."
76
74
  end
77
75
 
78
76
  def perform_task
79
- raise NotImplementedError
77
+ raise NotImplementedError, "The API method 'Perform Task' has not been implemented."
80
78
  end
81
79
 
82
80
  private
@@ -2,11 +2,6 @@ require "date"
2
2
  require "nokogiri"
3
3
  require "forwardable"
4
4
 
5
- require "duracloud/persistence"
6
- require "duracloud/has_properties"
7
- require "duracloud/space_properties"
8
- require "duracloud/space_acls"
9
-
10
5
  module Duracloud
11
6
  class Space
12
7
  extend Forwardable
@@ -1,6 +1,3 @@
1
- require "delegate"
2
- require "duracloud/properties"
3
-
4
1
  module Duracloud
5
2
  class SpaceAcls < Properties
6
3
 
@@ -1,5 +1,4 @@
1
1
  require "date"
2
- require "duracloud/properties"
3
2
 
4
3
  module Duracloud
5
4
  class SpaceProperties < Properties
@@ -1,3 +1,3 @@
1
1
  module Duracloud
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,3 @@
1
+ space-id content-id MD5
2
+ auditlogs localhost/51/auditlogs/localhost_51_auditlogs-2014-09-10-15-56-07.tsv 6992f8e57dafb17335f766aa2acf5942
3
+ auditlogs localhost/51/photos/localhost_51_photos-2014-09-10-15-55-01.tsv 820e786633fb495db447dc5d5cf0b2bd
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.0.2
4
+ version: 0.0.3
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: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -139,6 +139,7 @@ files:
139
139
  - duracloud.gemspec
140
140
  - lib/duracloud-client.rb
141
141
  - lib/duracloud.rb
142
+ - lib/duracloud/bit_integrity_report.rb
142
143
  - lib/duracloud/client.rb
143
144
  - lib/duracloud/configuration.rb
144
145
  - lib/duracloud/connection.rb
@@ -148,6 +149,7 @@ files:
148
149
  - lib/duracloud/error.rb
149
150
  - lib/duracloud/error_handler.rb
150
151
  - lib/duracloud/has_properties.rb
152
+ - lib/duracloud/manifest.rb
151
153
  - lib/duracloud/persistence.rb
152
154
  - lib/duracloud/properties.rb
153
155
  - lib/duracloud/request.rb
@@ -158,6 +160,7 @@ files:
158
160
  - lib/duracloud/space_properties.rb
159
161
  - lib/duracloud/store.rb
160
162
  - lib/duracloud/version.rb
163
+ - spec/fixtures/responses/GetManifest.tsv
161
164
  - spec/fixtures/responses/GetSpaces.xml
162
165
  - spec/fixtures/responses/GetStores.xml
163
166
  - spec/spec_helper.rb
@@ -191,6 +194,7 @@ signing_key:
191
194
  specification_version: 4
192
195
  summary: Ruby client for communicating with DuraCloud
193
196
  test_files:
197
+ - spec/fixtures/responses/GetManifest.tsv
194
198
  - spec/fixtures/responses/GetSpaces.xml
195
199
  - spec/fixtures/responses/GetStores.xml
196
200
  - spec/spec_helper.rb