duracloud-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ require "nokogiri"
2
+
3
+ module Duracloud
4
+ class Store
5
+
6
+ def self.all
7
+ response = Client.get_stores
8
+ doc = Nokogiri::XML(response.body)
9
+ doc.css('storageAcct').map { |acct| new(acct) }
10
+ end
11
+
12
+ attr_reader :id, :owner_id, :primary, :provider_type
13
+
14
+ def initialize(xml_node)
15
+ @owner_id = xml_node['ownerId']
16
+ @primary = xml_node['isPrimary']
17
+ @id = xml_node.css('id').text
18
+ @provider_type = xml_node.css('storageProviderType').text
19
+ end
20
+
21
+ def primary?
22
+ primary == "1"
23
+ end
24
+
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Duracloud
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/duracloud.rb CHANGED
@@ -3,7 +3,9 @@ require "duracloud/error"
3
3
  require "duracloud/client"
4
4
  require "duracloud/request"
5
5
  require "duracloud/content"
6
+ require "duracloud/store"
7
+ require "duracloud/space"
6
8
 
7
9
  module Duracloud
8
- # Your code goes here...
10
+
9
11
  end
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <spaces>
3
+ <space id="space1" />
4
+ <space id="space2" />
5
+ </spaces>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <storageProviderAccounts>
3
+ <storageAcct ownerId="0" isPrimary="0">
4
+ <id>1</id>
5
+ <storageProviderType>AMAZON_GLACIER</storageProviderType>
6
+ </storageAcct>
7
+ <storageAcct ownerId="0" isPrimary="1">
8
+ <id>2</id>
9
+ <storageProviderType>AMAZON_S3</storageProviderType>
10
+ </storageAcct>
11
+ </storageProviderAccounts>
@@ -0,0 +1,94 @@
1
+ require "duracloud"
2
+ require "rspec/its"
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+
45
+ # These two settings work together to allow you to limit a spec run
46
+ # to individual examples or groups you care about by tagging them with
47
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
48
+ # get run.
49
+ config.filter_run :focus
50
+ config.run_all_when_everything_filtered = true
51
+
52
+ # Allows RSpec to persist some state between runs in order to support
53
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
54
+ # you configure your source control system to ignore this file.
55
+ config.example_status_persistence_file_path = "spec/examples.txt"
56
+
57
+ # Limits the available syntax to the non-monkey patched syntax that is
58
+ # recommended. For more details, see:
59
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
60
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
61
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
62
+ config.disable_monkey_patching!
63
+
64
+ # This setting enables warnings. It's recommended, but in some cases may
65
+ # be too noisy due to issues in dependencies.
66
+ config.warnings = false
67
+
68
+ # Many RSpec users commonly either run the entire suite or an individual
69
+ # file, and it's useful to allow more verbose output when running an
70
+ # individual spec file.
71
+ if config.files_to_run.one?
72
+ # Use the documentation formatter for detailed output,
73
+ # unless a formatter has already been configured
74
+ # (e.g. via a command-line flag).
75
+ config.default_formatter = 'doc'
76
+ end
77
+
78
+ # Print the 10 slowest examples and example groups at the
79
+ # end of the spec run, to help surface which specs are running
80
+ # particularly slow.
81
+ config.profile_examples = 10
82
+
83
+ # Run specs in random order to surface order dependencies. If you find an
84
+ # order dependency and want to debug it, you can fix the order by providing
85
+ # the seed, which is printed after each run.
86
+ # --seed 1234
87
+ config.order = :random
88
+
89
+ # Seed global randomization in this process using the `--seed` CLI option.
90
+ # Setting this allows you to use `--seed` to deterministically reproduce
91
+ # test failures related to randomization by passing the same `--seed` value
92
+ # as the one that triggered the failure.
93
+ Kernel.srand config.seed
94
+ end
@@ -0,0 +1,9 @@
1
+ module Duracloud
2
+ RSpec.describe Client do
3
+ describe "#get_content"
4
+ describe "#get_content_properties"
5
+ describe "#set_content_properties"
6
+ describe "#store_content"
7
+ describe "#delete_content"
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ module Duracloud
2
+ RSpec.describe Content do
3
+
4
+ describe ".find" do
5
+ subject { Content.find(space_id: "foo", id: "bar") }
6
+ before {
7
+ allow_any_instance_of(Content).to receive(:load_properties) { nil }
8
+ }
9
+ it { is_expected.to be_a(Content) }
10
+ its(:url) { is_expected.to eq("foo/bar") }
11
+ end
12
+
13
+ describe ".create" do
14
+ let(:body) { "Contents of the file" }
15
+ subject { Content.create(space_id: "foo", id: "bar", body: body) }
16
+ before {
17
+ allow_any_instance_of(Content).to receive(:save) { nil }
18
+ }
19
+ it { is_expected.to be_a(Content) }
20
+ its(:url) { is_expected.to eq("foo/bar") }
21
+ end
22
+
23
+ describe "#save" do
24
+ end
25
+
26
+ describe "#delete" do
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ module Duracloud
2
+ RSpec.describe Properties do
3
+
4
+ describe ".filter"
5
+ describe ".property?"
6
+ describe ".duraspace_property?"
7
+ describe ".internal_property?"
8
+ describe ".space_property?"
9
+ describe ".space_acl?"
10
+ describe ".copy_content_property?"
11
+
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module Duracloud
2
+ RSpec.describe Space do
3
+ # TODO
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Duracloud
2
+ RSpec.describe Store do
3
+ # TODO
4
+ end
5
+ 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.0.1
4
+ version: 0.0.2
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-08 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -38,6 +38,62 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activemodel
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-its
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
41
97
  - !ruby/object:Gem::Dependency
42
98
  name: bundler
43
99
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +114,14 @@ dependencies:
58
114
  requirements:
59
115
  - - "~>"
60
116
  - !ruby/object:Gem::Version
61
- version: '10.0'
117
+ version: '11.1'
62
118
  type: :development
63
119
  prerelease: false
64
120
  version_requirements: !ruby/object:Gem::Requirement
65
121
  requirements:
66
122
  - - "~>"
67
123
  - !ruby/object:Gem::Version
68
- version: '10.0'
124
+ version: '11.1'
69
125
  description: Ruby client for communicating with DuraCloud
70
126
  email:
71
127
  - dchandekstark@gmail.com
@@ -74,6 +130,8 @@ extensions: []
74
130
  extra_rdoc_files: []
75
131
  files:
76
132
  - ".gitignore"
133
+ - ".rspec"
134
+ - ".travis.yml"
77
135
  - Gemfile
78
136
  - LICENSE
79
137
  - README.md
@@ -86,14 +144,28 @@ files:
86
144
  - lib/duracloud/connection.rb
87
145
  - lib/duracloud/content.rb
88
146
  - lib/duracloud/content_properties.rb
89
- - lib/duracloud/content_request.rb
90
- - lib/duracloud/content_response.rb
147
+ - lib/duracloud/durastore_request.rb
91
148
  - lib/duracloud/error.rb
92
149
  - lib/duracloud/error_handler.rb
150
+ - lib/duracloud/has_properties.rb
151
+ - lib/duracloud/persistence.rb
152
+ - lib/duracloud/properties.rb
93
153
  - lib/duracloud/request.rb
94
- - lib/duracloud/request_options.rb
95
154
  - lib/duracloud/response.rb
155
+ - lib/duracloud/rest_methods.rb
156
+ - lib/duracloud/space.rb
157
+ - lib/duracloud/space_acls.rb
158
+ - lib/duracloud/space_properties.rb
159
+ - lib/duracloud/store.rb
96
160
  - lib/duracloud/version.rb
161
+ - spec/fixtures/responses/GetSpaces.xml
162
+ - spec/fixtures/responses/GetStores.xml
163
+ - spec/spec_helper.rb
164
+ - spec/unit/client_spec.rb
165
+ - spec/unit/content_spec.rb
166
+ - spec/unit/properties_spec.rb
167
+ - spec/unit/space_spec.rb
168
+ - spec/unit/store_spec.rb
97
169
  homepage: https://github.com/duracloud/duracloud-ruby-client
98
170
  licenses:
99
171
  - APACHE2
@@ -106,7 +178,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
178
  requirements:
107
179
  - - ">="
108
180
  - !ruby/object:Gem::Version
109
- version: '0'
181
+ version: '2.1'
110
182
  required_rubygems_version: !ruby/object:Gem::Requirement
111
183
  requirements:
112
184
  - - ">="
@@ -114,8 +186,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
186
  version: '0'
115
187
  requirements: []
116
188
  rubyforge_project:
117
- rubygems_version: 2.4.3
189
+ rubygems_version: 2.5.1
118
190
  signing_key:
119
191
  specification_version: 4
120
192
  summary: Ruby client for communicating with DuraCloud
121
- test_files: []
193
+ test_files:
194
+ - spec/fixtures/responses/GetSpaces.xml
195
+ - spec/fixtures/responses/GetStores.xml
196
+ - spec/spec_helper.rb
197
+ - spec/unit/client_spec.rb
198
+ - spec/unit/content_spec.rb
199
+ - spec/unit/properties_spec.rb
200
+ - spec/unit/space_spec.rb
201
+ - spec/unit/store_spec.rb
@@ -1,16 +0,0 @@
1
- require "digest"
2
- require_relative "request"
3
- require_relative "content_response"
4
- require_relative "connection"
5
-
6
- module Duracloud
7
- class ContentRequest < Request
8
- def base_path
9
- '/durastore/'
10
- end
11
-
12
- def response_class
13
- ContentResponse
14
- end
15
- end
16
- end
@@ -1,11 +0,0 @@
1
- module Duracloud
2
- class ContentResponse < Response
3
- def content
4
- @content ||= Content.from_response(self)
5
- end
6
-
7
- def properties
8
- content.properties
9
- end
10
- end
11
- end
@@ -1,25 +0,0 @@
1
- require "digest"
2
-
3
- module Duracloud
4
- class RequestOptions
5
-
6
- attr_reader :payload, :content_type, :md5, :properties, :query
7
-
8
- def initialize(**options)
9
- @payload = options.delete(:payload)
10
- @content_type = options.delete(:content_type)
11
- @md5 = options.delete(:md5)
12
- @properties = options.delete(:properties)
13
- @query = options.delete(:query) { |k| Hash.new }.merge(options)
14
- end
15
-
16
- def headers
17
- Hash.new.tap do |h|
18
- h["Content-MD5"] = md5 if md5
19
- h["Content-Type"] = content_type if content_type
20
- h.update(properties) if properties
21
- end
22
- end
23
-
24
- end
25
- end