From ad0adae5beaacc1c6f3dce0e2e52b11060337c94 Mon Sep 17 00:00:00 2001 From: David Chandek-Stark Date: Fri, 8 Sep 2017 12:56:50 -0400 Subject: [PATCH 1/7] Bumped version to 0.10.0.pre --- lib/duracloud/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/duracloud/version.rb b/lib/duracloud/version.rb index 34aae28..33e1f61 100644 --- a/lib/duracloud/version.rb +++ b/lib/duracloud/version.rb @@ -1,3 +1,3 @@ module Duracloud - VERSION = "0.9.0" + VERSION = "0.10.0.pre" end From e6b248f50228c08f07b350b621281c58d72e5605 Mon Sep 17 00:00:00 2001 From: David Chandek-Stark Date: Tue, 12 Sep 2017 13:14:12 -0400 Subject: [PATCH 2/7] Adds `store` command to CLI. --- Gemfile | 2 +- lib/duracloud/cli.rb | 18 ++++++----- lib/duracloud/command_options.rb | 5 +++ lib/duracloud/commands.rb | 4 +++ lib/duracloud/commands/store_content.rb | 13 ++++++++ spec/unit/cli_spec.rb | 42 ++++++++++++++++--------- 6 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 lib/duracloud/commands/store_content.rb diff --git a/Gemfile b/Gemfile index 58eba09..f7ed12c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in duracloud.gemspec gemspec gem 'activemodel', '~> 4.2.7' +gem 'byebug' diff --git a/lib/duracloud/cli.rb b/lib/duracloud/cli.rb index 454468f..e5515fd 100644 --- a/lib/duracloud/cli.rb +++ b/lib/duracloud/cli.rb @@ -39,7 +39,7 @@ class CLI :work_dir validates_presence_of :space_id, message: "-s/--space-id option is required.", unless: "command == 'get_storage_report'" - validates_inclusion_of :command, in: COMMANDS + validates_inclusion_of :command, in: COMMANDS, message: "Invalid command" def self.error!(exception) $stderr.puts exception.message @@ -50,18 +50,20 @@ def self.error!(exception) end def self.call(*args) - options = CommandOptions.new(*args) - cli = new(options) # .merge(command: command)) - if cli.invalid? - message = cli.errors.map { |k, v| "ERROR: #{v}" }.join("\n") - raise CommandError, message - end - cli.execute + new(*args).execute rescue => e error!(e) end + def initialize(*args) + super CommandOptions.new(*args) + end + def execute + if invalid? + message = errors.map { |k, v| "ERROR: #{v}" }.join("\n") + raise CommandError, message + end configure_client send(command, self) end diff --git a/lib/duracloud/command_options.rb b/lib/duracloud/command_options.rb index b8db165..2a572ec 100644 --- a/lib/duracloud/command_options.rb +++ b/lib/duracloud/command_options.rb @@ -113,6 +113,11 @@ def parser opts.on("--[no-]all-spaces", "Get report for all spaces") do |v| self.all_spaces = v end + + opts.on("-t", "--content-type CONTENT_TYPE", + "Media type of content to store") do |v| + self.content_type = v + end end end diff --git a/lib/duracloud/commands.rb b/lib/duracloud/commands.rb index 949a756..54d2637 100644 --- a/lib/duracloud/commands.rb +++ b/lib/duracloud/commands.rb @@ -33,6 +33,10 @@ def list_items(cli) ListItems.call(cli) end + def store(cli) + StoreContent.call(cli) + end + end end diff --git a/lib/duracloud/commands/store_content.rb b/lib/duracloud/commands/store_content.rb new file mode 100644 index 0000000..7950432 --- /dev/null +++ b/lib/duracloud/commands/store_content.rb @@ -0,0 +1,13 @@ +module Duracloud::Commands + class StoreContent < Command + + def call + File.open(infile, "rb") do |body| + Duracloud::Content.create(space_id: space_id, store_id: store_id, + content_id: content_id, body: body, + md5: md5, content_type: content_type) + end + end + + end +end diff --git a/spec/unit/cli_spec.rb b/spec/unit/cli_spec.rb index 3591800..90a0389 100644 --- a/spec/unit/cli_spec.rb +++ b/spec/unit/cli_spec.rb @@ -1,26 +1,30 @@ module Duracloud RSpec.describe CLI do - subject { described_class.new(**opts) } + subject { described_class.new(*opts) } describe "find item" do - let(:opts) { {command: "find", space_id: "foo", content_id: "bar"} } + let(:opts) { %w(find -s foo -c bar) } specify { - expect(Commands::FindItem).to receive(:call).with(subject) { nil } + stub = stub_request(:head, "https://example.com/durastore/foo/bar") + expect(Commands::FindItem).to receive(:call).with(subject).and_call_original subject.execute + expect(stub).to have_been_requested } end describe "find space" do - let(:opts) { {command: "find", space_id: "foo"} } + let(:opts) { %w(find -s foo) } specify { - expect(Commands::FindSpace).to receive(:call).with(subject) { nil } + stub = stub_request(:head, "https://example.com/durastore/foo") + expect(Commands::FindSpace).to receive(:call).with(subject).and_call_original subject.execute + expect(stub).to have_been_requested } end describe "find items" do - let(:opts) { {command: "find", space_id: "foo", infile: "/foo/bar"} } + let(:opts) { %w( find -s foo -f /foo/bar ) } specify { expect(Commands::FindItems).to receive(:call).with(subject) { nil } subject.execute @@ -28,15 +32,17 @@ module Duracloud end describe "count" do - let(:opts) { {command: "count", space_id: "foo"} } + let(:opts) { %w( count -s foo ) } specify { - expect(Commands::Count).to receive(:call).with(subject) { nil } + stub = stub_request(:head, "https://example.com/durastore/foo") + expect(Commands::Count).to receive(:call).with(subject).and_call_original subject.execute + expect(stub).to have_been_requested } end describe "sync" do - let(:opts) { {command: "sync", space_id: "foo", content_id: "bar", infile: "foo/bar"} } + let(:opts) { %w( sync -s foo -c bar -f /foo/bar ) } specify { expect(Commands::Sync).to receive(:call).with(subject) { nil } subject.execute @@ -44,7 +50,7 @@ module Duracloud end describe "validate" do - let(:opts) { {command: "validate", space_id: "foo", content_dir: "/tmp"} } + let(:opts) { %w( validate -s foo -d /tmp ) } specify { expect(Commands::Validate).to receive(:call).with(subject) { nil } subject.execute @@ -52,7 +58,7 @@ module Duracloud end describe "download_manifest" do - let(:opts) { {command: "download_manifest", space_id: "foo"} } + let(:opts) { %w( download_manifest -s foo ) } specify { expect(Commands::DownloadManifest).to receive(:call).with(subject) { nil } subject.execute @@ -60,7 +66,7 @@ module Duracloud end describe "get_storage_report" do - let(:opts) { {command: "get_storage_report", space_id: "foo"} } + let(:opts) { %w( get_storage_report -s foo ) } specify { expect(Commands::GetStorageReport).to receive(:call).with(subject) { nil } subject.execute @@ -68,7 +74,7 @@ module Duracloud end describe "list content ids" do - let(:opts) { {command: "list_content_ids", space_id: "foo"} } + let(:opts) { %w( list_content_ids -s foo ) } specify { expect(Commands::ListContentIds).to receive(:call).with(subject) { nil } subject.execute @@ -76,12 +82,20 @@ module Duracloud end describe "list items" do - let(:opts) { {command: "list_items", space_id: "foo"} } + let(:opts) { %w( list_items -s foo ) } specify { expect(Commands::ListItems).to receive(:call).with(subject) { nil } subject.execute } end + describe "store" do + let(:opts) { %w( store -s foo -c bar -f /foo/bar -t image/jpeg ) } + specify { + expect(Commands::StoreContent).to receive(:call).with(subject) { nil } + subject.execute + } + end + end end From 2b09084236e61fbb18ac60766de12e72a6b4bcd5 Mon Sep 17 00:00:00 2001 From: David Chandek-Stark Date: Mon, 30 Oct 2017 22:40:10 -0400 Subject: [PATCH 3/7] Adds Content.delete class method. --- lib/duracloud/abstract_entity.rb | 1 - lib/duracloud/content.rb | 9 +++++++++ spec/unit/content_spec.rb | 3 +-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/duracloud/abstract_entity.rb b/lib/duracloud/abstract_entity.rb index eb7b371..115e133 100644 --- a/lib/duracloud/abstract_entity.rb +++ b/lib/duracloud/abstract_entity.rb @@ -45,7 +45,6 @@ def properties @properties ||= Properties.new end - def load_properties run_callbacks :load_properties do do_load_properties diff --git a/lib/duracloud/content.rb b/lib/duracloud/content.rb index 902e6b6..705a2ec 100644 --- a/lib/duracloud/content.rb +++ b/lib/duracloud/content.rb @@ -45,6 +45,15 @@ def self.create(**kwargs) new(**kwargs).save end + # Delete content from DuraCloud. + # @return [Duraclound::Content] the deleted content. + # @raise [Duracloud::NotFoundError] the space, content or store (if given) does not exist. + # @raise [Duracloud::MessageDigestError] the provided digest in the :md5 keyword option, + # if given, does not match the stored value. + def self.delete(**kwargs) + find(**kwargs).delete + end + attr_accessor :space_id, :content_id, :store_id, :body, :md5, :content_type, :size, :modified alias_method :id, :content_id diff --git a/spec/unit/content_spec.rb b/spec/unit/content_spec.rb index 9607bec..4934e51 100644 --- a/spec/unit/content_spec.rb +++ b/spec/unit/content_spec.rb @@ -201,8 +201,7 @@ module Duracloud describe "when found" do before { stub_request(:delete, url) } it "deletes the content" do - subject.delete - expect(subject).to be_deleted + expect { subject.delete }.to change(subject, :deleted?).from(false).to(true) end end end From 2e08048afc1783991e0b71242f8807cf29a998c1 Mon Sep 17 00:00:00 2001 From: David Chandek-Stark Date: Tue, 31 Oct 2017 11:24:05 -0400 Subject: [PATCH 4/7] Updated README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3382c75..4d081b5 100644 --- a/README.md +++ b/README.md @@ -283,6 +283,8 @@ D, [2016-04-29T18:29:03.935451 #32379] DEBUG -- : Duracloud::Client HEAD https:/ => false ``` +*Added in v0.10.0.pre* `Duracloud::Content.delete` class method. + ### Reports The audit logs, bit integrity reports and manifests are accessible in their original TSV format and in normalized CSV tables. From fae683e1fe966df35271c9ec9955fdac80e65862 Mon Sep 17 00:00:00 2001 From: David Chandek-Stark Date: Tue, 31 Oct 2017 14:43:52 -0400 Subject: [PATCH 5/7] Removes dependency on activemodel. Usage of ActiveModel::Model as an included module in several classes has been functionally replaced by subclassing Hashie classes (principally Hashie::Dash). --- .travis.yml | 4 +-- Gemfile | 1 - duracloud.gemspec | 1 - gemfiles/Gemfile.activemodel-4.2 | 3 -- gemfiles/Gemfile.activemodel-5.0 | 3 -- lib/duracloud/abstract_entity.rb | 32 ++++++------------ lib/duracloud/cli.rb | 55 ++++++++++++++----------------- lib/duracloud/command_options.rb | 8 +++-- lib/duracloud/content.rb | 20 ++++++----- lib/duracloud/content_manifest.rb | 11 +++---- lib/duracloud/space.rb | 13 ++++---- lib/duracloud/storage_report.rb | 7 +--- lib/duracloud/sync_validation.rb | 10 +++--- 13 files changed, 73 insertions(+), 95 deletions(-) delete mode 100644 gemfiles/Gemfile.activemodel-4.2 delete mode 100644 gemfiles/Gemfile.activemodel-5.0 diff --git a/.travis.yml b/.travis.yml index 2ccd0f0..5b53273 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,5 @@ language: ruby rvm: - 2.2 - 2.3.1 -gemfile: - - gemfiles/Gemfile.activemodel-4.2 + - 2.4 + diff --git a/Gemfile b/Gemfile index f7ed12c..6e9bd98 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,4 @@ source 'https://rubygems.org' gemspec -gem 'activemodel', '~> 4.2.7' gem 'byebug' diff --git a/duracloud.gemspec b/duracloud.gemspec index 506871f..cd997d2 100644 --- a/duracloud.gemspec +++ b/duracloud.gemspec @@ -23,7 +23,6 @@ Gem::Specification.new do |spec| spec.add_dependency "addressable", "~> 2.5" spec.add_dependency "hashie", "~> 3.4" spec.add_dependency "httpclient", "~> 2.7" - spec.add_dependency "activemodel", ">= 4.2", "< 6" spec.add_dependency "nokogiri", "~> 1.6" spec.add_development_dependency "webmock", "~> 2.0" diff --git a/gemfiles/Gemfile.activemodel-4.2 b/gemfiles/Gemfile.activemodel-4.2 deleted file mode 100644 index c9e9ad1..0000000 --- a/gemfiles/Gemfile.activemodel-4.2 +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' -gem "activemodel", "~> 4.2.7" -gemspec path: "../" diff --git a/gemfiles/Gemfile.activemodel-5.0 b/gemfiles/Gemfile.activemodel-5.0 deleted file mode 100644 index ad5f25e..0000000 --- a/gemfiles/Gemfile.activemodel-5.0 +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' -gem "activemodel", "~> 5.0.1" -gemspec path: "../" diff --git a/lib/duracloud/abstract_entity.rb b/lib/duracloud/abstract_entity.rb index 115e133..88e3fe1 100644 --- a/lib/duracloud/abstract_entity.rb +++ b/lib/duracloud/abstract_entity.rb @@ -1,30 +1,19 @@ -require "active_model" - module Duracloud - class AbstractEntity - include ActiveModel::Model - extend ActiveModel::Callbacks - - define_model_callbacks :save, :delete, :load_properties - after_save :persisted! - after_save :reset_properties - after_load_properties :persisted! - before_delete :reset_properties - after_delete :deleted! - after_delete :freeze + class AbstractEntity < Hashie::Dash def save raise Error, "Cannot save deleted #{self.class}." if deleted? - run_callbacks :save do - do_save - end + do_save + persisted! + reset_properties end def delete raise Error, "Cannot delete, already deleted." if deleted? - run_callbacks :delete do - do_delete - end + reset_properties + do_delete + deleted! + freeze end def persisted? @@ -46,9 +35,8 @@ def properties end def load_properties - run_callbacks :load_properties do - do_load_properties - end + do_load_properties + persisted! end private diff --git a/lib/duracloud/cli.rb b/lib/duracloud/cli.rb index e5515fd..d086981 100644 --- a/lib/duracloud/cli.rb +++ b/lib/duracloud/cli.rb @@ -1,9 +1,8 @@ require 'optparse' -require 'active_model' +require 'hashie' module Duracloud - class CLI - include ActiveModel::Model + class CLI < Hashie::Dash include Commands COMMANDS = Commands.public_instance_methods.map(&:to_s) @@ -18,32 +17,29 @@ class CLI EOS HELP = "Type 'duracloud -h/--help' for usage." - attr_accessor :all_spaces, - :command, - :content_dir, - :content_id, - :content_type, - :fast, - :format, - :host, - :infile, - :logging, - :md5, - :missing, - :password, - :port, - :prefix, - :space_id, - :store_id, - :user, - :work_dir - - validates_presence_of :space_id, message: "-s/--space-id option is required.", unless: "command == 'get_storage_report'" - validates_inclusion_of :command, in: COMMANDS, message: "Invalid command" + property :all_spaces + property :command, required: true + property :content_dir + property :content_id + property :content_type + property :fast + property :format + property :host + property :infile + property :logging + property :md5 + property :missing + property :password + property :port + property :prefix + property :space_id, required: -> { command != "get_storage_report" }, message: "-s/--space-id option is required." + property :store_id + property :user + property :work_dir def self.error!(exception) $stderr.puts exception.message - if [ CommandError, OptionParser::ParseError ].include?(exception.class) + if [ ArgumentError, CommandError, OptionParser::ParseError ].include?(exception.class) $stderr.puts HELP end exit(false) @@ -56,13 +52,12 @@ def self.call(*args) end def initialize(*args) - super CommandOptions.new(*args) + super CommandOptions.parse(*args) end def execute - if invalid? - message = errors.map { |k, v| "ERROR: #{v}" }.join("\n") - raise CommandError, message + unless COMMANDS.include?(command) + raise CommandError, "Invalid command: #{command.inspect}." end configure_client send(command, self) diff --git a/lib/duracloud/command_options.rb b/lib/duracloud/command_options.rb index 2a572ec..3aad399 100644 --- a/lib/duracloud/command_options.rb +++ b/lib/duracloud/command_options.rb @@ -4,10 +4,14 @@ module Duracloud class CommandOptions < Hashie::Mash - def initialize(*args) - super() + def self.parse(*args) + new.parse(*args) + end + + def parse(*args) self.command = args.shift if CLI::COMMANDS.include?(args.first) parser.parse!(args) + to_hash(symbolize_keys: true) end def print_version diff --git a/lib/duracloud/content.rb b/lib/duracloud/content.rb index 705a2ec..7d2bd0e 100644 --- a/lib/duracloud/content.rb +++ b/lib/duracloud/content.rb @@ -1,5 +1,3 @@ -require "active_model" - module Duracloud # # A piece of content in DuraCloud @@ -13,6 +11,17 @@ class CopyError < Error; end COPY_SOURCE_STORE_HEADER = "x-dura-meta-copy-source-store" MANIFEST_EXT = ".dura-manifest" + property :space_id, required: true + property :content_id, required: true + property :store_id + property :body + property :md5 + property :content_type + property :size + property :modified + + alias_method :id, :content_id + # Does the content exist in DuraCloud? # @return [Boolean] whether the content exists. # @raise [Duracloud::MessageDigestError] the provided digest in the :md5 keyword option, @@ -54,11 +63,6 @@ def self.delete(**kwargs) find(**kwargs).delete end - attr_accessor :space_id, :content_id, :store_id, - :body, :md5, :content_type, :size, :modified - alias_method :id, :content_id - validates_presence_of :space_id, :content_id - # Return the space associated with this content. # @return [Duracloud::Space] the space. # @raise [Duracloud::NotFoundError] the space or store does not exist. @@ -90,7 +94,7 @@ def download(&block) # The current instance still represents the original content. # @raise [Duracloud::Error] def copy(**args) - dest = args.except(:force) + dest = args.reject { |k, v| k == :force } dest[:space_id] ||= space_id dest[:store_id] ||= store_id dest[:content_id] ||= content_id diff --git a/lib/duracloud/content_manifest.rb b/lib/duracloud/content_manifest.rb index e572d89..0e1d185 100644 --- a/lib/duracloud/content_manifest.rb +++ b/lib/duracloud/content_manifest.rb @@ -1,13 +1,12 @@ require 'nokogiri' -require 'active_model' +require 'hashie' module Duracloud - class ContentManifest - include ActiveModel::Model + class ContentManifest < Hashie::Dash - validates_presence_of :space_id, :manifest_id - - attr_accessor :space_id, :manifest_id, :store_id + property :space_id, required: true + property :manifest_id, required: true + property :store_id def self.find(**kwargs) new(**kwargs).tap do |manifest| diff --git a/lib/duracloud/space.rb b/lib/duracloud/space.rb index e6ee82a..dcc7bfd 100644 --- a/lib/duracloud/space.rb +++ b/lib/duracloud/space.rb @@ -7,7 +7,10 @@ module Duracloud # class Space < AbstractEntity - after_save :reset_acls + property :space_id, required: true + property :store_id + + alias_method :id, :space_id # Max size of content item list for one request. # This limit is imposed by Duracloud. @@ -117,12 +120,6 @@ def manifest(*args) end end - attr_accessor :space_id, :store_id - alias_method :id, :space_id - - after_save :reset_acls - before_delete :reset_acls - # @param space_id [String] the space ID # @param store_id [String] the store ID (optional) def initialize(space_id, store_id = nil) @@ -249,11 +246,13 @@ def properties_class end def do_delete + reset_acls Client.delete_space(id, **query) end def do_save persisted? ? update : create + reset_acls end def query diff --git a/lib/duracloud/storage_report.rb b/lib/duracloud/storage_report.rb index 1e66e7a..2ec3964 100644 --- a/lib/duracloud/storage_report.rb +++ b/lib/duracloud/storage_report.rb @@ -1,5 +1,4 @@ require 'hashie' -require 'active_support' module Duracloud class StorageReport < Hashie::Trash @@ -15,17 +14,13 @@ def time @time ||= Time.at(timestamp / 1000.0).utc end - def human_size - ActiveSupport::NumberHelper.number_to_human_size(byte_count, prefix: :si) - end - def to_s <<-EOS Date: #{time} Space ID: #{space_id || "(all)"} Store ID: #{store_id} Objects: #{object_count} -Total size: #{human_size} (#{byte_count} bytes) +Total size: #{byte_count} bytes EOS end diff --git a/lib/duracloud/sync_validation.rb b/lib/duracloud/sync_validation.rb index dddf21f..9621a13 100644 --- a/lib/duracloud/sync_validation.rb +++ b/lib/duracloud/sync_validation.rb @@ -1,11 +1,10 @@ -require 'active_model' require 'tempfile' require 'csv' require 'fileutils' +require 'hashie' module Duracloud - class SyncValidation - include ActiveModel::Model + class SyncValidation < Hashie::Dash TWO_SPACES = ' ' MD5_CSV_OPTS = { col_sep: TWO_SPACES }.freeze @@ -15,7 +14,10 @@ class SyncValidation CHANGED = "CHANGED" FOUND = "FOUND" - attr_accessor :space_id, :content_dir, :store_id, :work_dir, :fast + property :space_id, required: true + property :content_dir, required: true + property :store_id + property :work_dir def self.call(*args) new(*args).call From bfa2653c89f688caab1699659fa6d6a7db304ed7 Mon Sep 17 00:00:00 2001 From: David Chandek-Stark Date: Wed, 1 Nov 2017 14:43:00 -0400 Subject: [PATCH 6/7] Various refactorings to remove cruft and simplify code. --- README.md | 86 +++++++++++++----------------- lib/duracloud.rb | 42 ++++++++++++--- lib/duracloud/abstract_entity.rb | 2 + lib/duracloud/cli.rb | 12 ++--- lib/duracloud/client.rb | 41 +++----------- lib/duracloud/configuration.rb | 42 --------------- lib/duracloud/connection.rb | 18 ------- lib/duracloud/durastore_request.rb | 7 --- lib/duracloud/error_handler.rb | 56 ------------------- lib/duracloud/request.rb | 44 ++++++++++----- lib/duracloud/response.rb | 5 +- lib/duracloud/response_handler.rb | 63 ++++++++++++++++++++++ lib/duracloud/rest_methods.rb | 5 +- lib/duracloud/space.rb | 4 +- spec/spec_helper.rb | 10 ++-- 15 files changed, 188 insertions(+), 249 deletions(-) delete mode 100644 lib/duracloud/configuration.rb delete mode 100644 lib/duracloud/connection.rb delete mode 100644 lib/duracloud/durastore_request.rb delete mode 100644 lib/duracloud/error_handler.rb create mode 100644 lib/duracloud/response_handler.rb diff --git a/README.md b/README.md index 4d081b5..1d29ea4 100644 --- a/README.md +++ b/README.md @@ -31,36 +31,21 @@ Option 1. Environment variables Option 2. Manual configuration -```ruby -Duracloud::Client.configure do |config| - config.host = "foo.duracloud.org" - config.user = "bob@example.com" - config.password = "s3cret" -end -``` +*Changed in v0.10.0* Set attributes on `Duracloud` module instead of using `Duracloud::Client.configure {|config| ...}` block. -``` -> c = Duracloud::Client.new - => #> - ``` + Duracloud.host = "foo.duracloud.org" + Duracloud.user = "bob@example.com" + Duracloud.password = "s3cret" #### Logging -By default, `Duracloud::Client` logs to `STDERR`. Use the `logger` config setting to change: +By default duracloud-client logs to `STDERR`. Use the `logger` config setting to change: -```ruby -Duracloud::Client.configure do |config| - config.logger = Rails.logger -end -``` + Duracloud.logger = Rails.logger You can also silence logging: -```ruby -Duracloud::Client.configure do |config| - config.silence_logging! # sets logger device to null device -end -``` + Duracloud.silence_logging! # sets logger device to null device ### List Storage Providers @@ -81,7 +66,7 @@ end ``` >> space = Duracloud::Space.create("rest-api-testing2") -D, [2016-04-29T12:12:32.641574 #28275] DEBUG -- : Duracloud::Client PUT https://foo.duracloud.org/durastore/rest-api-testing2 201 Created +D, [2016-04-29T12:12:32.641574 #28275] DEBUG -- : Duracloud::Request PUT https://foo.duracloud.org/durastore/rest-api-testing2 201 Created => # ``` @@ -91,7 +76,7 @@ A `Duracloud::BadRequestError` exception is raised if the space ID is invalid (i ``` >> space = Duracloud::Space.find("rest-api-testing") -D, [2016-04-29T12:15:12.593075 #28275] DEBUG -- : Duracloud::Client HEAD https://foo.duracloud.org/durastore/rest-api-testing 200 OK +D, [2016-04-29T12:15:12.593075 #28275] DEBUG -- : Duracloud::Request HEAD https://foo.duracloud.org/durastore/rest-api-testing 200 OK => # >> space.count @@ -103,11 +88,11 @@ D, [2016-04-29T12:15:12.593075 #28275] DEBUG -- : Duracloud::Client HEAD https:/ A `Duracloud::NotFoundError` exception is raised if the space does not exist. -NOTE: When the object count in a space exceeds 1000, Duracloud returns "1000+" as the count. Ruby's integer coercion `to_i` +**Note:** When the object count in a space exceeds 1000, Duracloud returns `1000+` as the count. Ruby's integer coercion `to_i` turns that string into the integer 1000. Getting an exact count above 1000 requires (on the client side) enumerating the content_ids -(below, fixed in v0.7.2 when count is >= 1000) which can take a long time for a space with a lot of content items, -since a maxiumum of 1000 ids can be retrived at one time. If an up-to-the-minute -count is not required, the storage report for the space (not yet implemented in this library) shows an exact count on a daily basis. +(below, fixed in v0.7.2 when count is >= 1000) which can take a long time for a space with a lot of content items +(a maxiumum of 1000 ids can be retrived at one time). If an up-to-the-minute +count is not required, the storage report for the space shows an exact count on a daily basis. #### Enumerate the content IDs of the space @@ -152,10 +137,11 @@ Duracloud::SyncValidation.call(space_id: 'foo', content_dir: '/var/foo/bar') create a temporary directory which is deleted on completion of the process. If `:work_dir` is specified, no cleanup is performed. Files created in work directory: -- `{SPACE_ID}-manifest.tsv` (DuraCloud manifest as downloaded) -- `{SPACE_ID}-md5.txt` (Munged manifest for md5deep) -- `{SPACE_ID}-audit.txt` (Output of md5deep, empty if all files match) -- `{SPACE_ID}-recheck.txt` (Out of audit recheck, if necessary) + + {SPACE_ID}-manifest.tsv DuraCloud manifest as downloaded + {SPACE_ID}-md5.txt Munged manifest for md5deep + {SPACE_ID}-audit.txt Output of md5deep, empty if all files match + {SPACE_ID}-recheck.txt Output of audit recheck, if necessary *Added in version 0.9.0* - `Duracloud::FastSyncValidation`. This variant of sync validation does not compute local hashes but instead compares the local file list (generated with `find`) to the list of content IDs in the space manifest. Local misses are rechecked as in `SyncValidation` (but without MD5 comparison). @@ -181,6 +167,8 @@ When storing content a `Duracloud::NotFoundError` is raised if the space does no A `Duracloud::BadRequestError` is raised if the content ID is invalid. A `Duracloud::ConflictError` is raised if the provided MD5 digest does not match the stored digest. +**Note:** duracloud-client does not currently provide for chunking of large files as, for example, the DuraCloud Sync Tool does. + #### Retrieve an existing content item from DuraCloud ``` @@ -196,7 +184,7 @@ raised if the content ID exists and the stored digest does not match. If a content item is not found at the content ID, `Duracloud::Content.find` will look for a "content manifest" by appending ".dura-manifest" to the content ID. If the manifest is found, the content item is marked as -"chunked". **Caution: Working with chunked files should be considered EXPERIMENTAL.** +"chunked". **Caution: Working with chunked files should be considered EXPERIMENTAL and unsupported.** #### Update the properties for a content item @@ -205,7 +193,7 @@ by appending ".dura-manifest" to the content ID. If the manifest is found, the c => # >> content = space.find_content("foo3") -D, [2016-04-29T18:31:16.975749 #32379] DEBUG -- : Duracloud::Client HEAD https://foo.duracloud.org/durastore/rest-api-testing/foo3 200 OK +D, [2016-04-29T18:31:16.975749 #32379] DEBUG -- : Duracloud::Request HEAD https://foo.duracloud.org/durastore/rest-api-testing/foo3 200 OK => # >> content.properties @@ -213,12 +201,12 @@ D, [2016-04-29T18:31:16.975749 #32379] DEBUG -- : Duracloud::Client HEAD https:/ >> content.properties["x-dura-meta-creator"] = "bob@example.com" >> content.save -D, [2016-04-29T18:31:52.770195 #32379] DEBUG -- : Duracloud::Client POST https://foo.duracloud.org/durastore/rest-api-testing/foo3 200 OK +D, [2016-04-29T18:31:52.770195 #32379] DEBUG -- : Duracloud::Request POST https://foo.duracloud.org/durastore/rest-api-testing/foo3 200 OK I, [2016-04-29T18:31:52.770293 #32379] INFO -- : Content foo3 updated successfully => true >> content.properties["x-dura-meta-creator"] -D, [2016-04-29T18:32:06.465928 #32379] DEBUG -- : Duracloud::Client HEAD https://foo.duracloud.org/durastore/rest-api-testing/foo3 200 OK +D, [2016-04-29T18:32:06.465928 #32379] DEBUG -- : Duracloud::Request HEAD https://foo.duracloud.org/durastore/rest-api-testing/foo3 200 OK => "bob@example.com" ``` @@ -234,11 +222,11 @@ Also, `:space_id` and `:content_id` arguments are not required, but default to t ``` >> content = Duracloud::Content.find(space_id: 'rest-api-testing', content_id: 'contentItem.txt') -D, [2017-01-27T17:16:45.846459 #93283] DEBUG -- : Duracloud::Client HEAD https://duke.duracloud.org/durastore/rest-api-testing/contentItem.txt 200 OK +D, [2017-01-27T17:16:45.846459 #93283] DEBUG -- : Duracloud::Request HEAD https://duke.duracloud.org/durastore/rest-api-testing/contentItem.txt 200 OK => # >> content.copy(space_id: 'rest-api-testing2') -D, [2017-01-27T17:17:59.848741 #93283] DEBUG -- : Duracloud::Client PUT https://duke.duracloud.org/durastore/rest-api-testing2/contentItem.txt 201 Created +D, [2017-01-27T17:17:59.848741 #93283] DEBUG -- : Duracloud::Request PUT https://duke.duracloud.org/durastore/rest-api-testing2/contentItem.txt 201 Created => # ``` @@ -246,18 +234,18 @@ D, [2017-01-27T17:17:59.848741 #93283] DEBUG -- : Duracloud::Client PUT https:// *Added in v0.3.0; Changed in v0.4.0.* -See also *Copy a content item, above. +See also *Copy a content item*, above. ``` This is a convenience operation -- copy and delete -- not directly supported by the DuraCloud REST API. >> content = Duracloud::Content.find(space_id: 'rest-api-testing', content_id: 'contentItem.txt') -D, [2017-01-27T17:19:41.926994 #93286] DEBUG -- : Duracloud::Client HEAD https://duke.duracloud.org/durastore/rest-api-testing/contentItem.txt 200 OK +D, [2017-01-27T17:19:41.926994 #93286] DEBUG -- : Duracloud::Request HEAD https://duke.duracloud.org/durastore/rest-api-testing/contentItem.txt 200 OK => # >> content.move(space_id: 'rest-api-testing2') -D, [2017-01-27T17:20:07.542468 #93286] DEBUG -- : Duracloud::Client PUT https://duke.duracloud.org/durastore/rest-api-testing2/contentItem.txt 201 Created -D, [2017-01-27T17:20:08.442504 #93286] DEBUG -- : Duracloud::Client DELETE https://duke.duracloud.org/durastore/rest-api-testing/contentItem.txt 200 OK +D, [2017-01-27T17:20:07.542468 #93286] DEBUG -- : Duracloud::Request PUT https://duke.duracloud.org/durastore/rest-api-testing2/contentItem.txt 201 Created +D, [2017-01-27T17:20:08.442504 #93286] DEBUG -- : Duracloud::Request DELETE https://duke.duracloud.org/durastore/rest-api-testing/contentItem.txt 200 OK => # >> content.deleted? @@ -274,12 +262,12 @@ D, [2017-01-27T17:20:08.442504 #93286] DEBUG -- : Duracloud::Client DELETE https => # >> content.delete -D, [2016-04-29T18:28:31.459962 #32379] DEBUG -- : Duracloud::Client DELETE https://foo.duracloud.org/durastore/rest-api-testing/foo2 200 OK +D, [2016-04-29T18:28:31.459962 #32379] DEBUG -- : Duracloud::Request DELETE https://foo.duracloud.org/durastore/rest-api-testing/foo2 200 OK I, [2016-04-29T18:28:31.460069 #32379] INFO -- : Content foo2 deleted successfully => # >> Duracloud::Content.exist?(space_id: "rest-api-testing", content_id: "foo2") -D, [2016-04-29T18:29:03.935451 #32379] DEBUG -- : Duracloud::Client HEAD https://foo.duracloud.org/durastore/rest-api-testing/foo2 404 Not Found +D, [2016-04-29T18:29:03.935451 #32379] DEBUG -- : Duracloud::Request HEAD https://foo.duracloud.org/durastore/rest-api-testing/foo2 404 Not Found => false ``` @@ -297,7 +285,7 @@ The audit logs, bit integrity reports and manifests are accessible in their orig => # >> audit_log.csv -D, [2016-05-19T13:36:49.107520 #28754] DEBUG -- : Duracloud::Client GET https://duke.duracloud.org/durastore/audit/rest-api-testing 200 OK +D, [2016-05-19T13:36:49.107520 #28754] DEBUG -- : Duracloud::Request GET https://duke.duracloud.org/durastore/audit/rest-api-testing 200 OK => # ``` @@ -309,20 +297,20 @@ D, [2016-05-19T13:36:49.107520 #28754] DEBUG -- : Duracloud::Client GET https:// => # >> manifest.csv -D, [2016-05-19T13:37:39.831013 #28754] DEBUG -- : Duracloud::Client GET https://duke.duracloud.org/durastore/manifest/rest-api-testing 200 OK +D, [2016-05-19T13:37:39.831013 #28754] DEBUG -- : Duracloud::Request GET https://duke.duracloud.org/durastore/manifest/rest-api-testing 200 OK => # >> manifest.csv.headers => ["space_id", "content_id", "md5"] ``` -*Added in v0.5.0: Support for asynchronous generation of manifest (Generate Manifest API)* +*Added in v0.5.0* Support for asynchronous generation of manifest (Generate Manifest API) ``` >> manifest = Duracloud::Manifest.new('ddr-validation') => # >> manifest.generate - D, [2017-06-06T20:49:50.191301 #92029] DEBUG -- : Duracloud::Client POST https://duke.duracloud.org/durastore/manifest/ddr-validation 202 Accepted + D, [2017-06-06T20:49:50.191301 #92029] DEBUG -- : Duracloud::Request POST https://duke.duracloud.org/durastore/manifest/ddr-validation 202 Accepted I, [2017-06-06T20:49:50.191414 #92029] INFO -- : We are processing your manifest generation request. To retrieve your file, please poll the URI in the Location header of this response: (https://duke.duracloud.org/durastore/x-duracloud-admin/generated-manifests/manifest-ddr-validation_amazon_s3_2017-06-07-00-49-50.txt.gz). => "https://duke.duracloud.org/durastore/x-duracloud-admin/generated-manifests/manifest-ddr-validation_amazon_s3_2017-06-07-00-49-50.txt.gz" ``` @@ -335,7 +323,7 @@ D, [2016-05-19T13:37:39.831013 #28754] DEBUG -- : Duracloud::Client GET https:// => # >> bit_integrity_report.csv -D, [2016-05-19T15:39:33.538448 #29974] DEBUG -- : Duracloud::Client GET https://duke.duracloud.org/durastore/bit-integrity/rest-api-testing 200 OK +D, [2016-05-19T15:39:33.538448 #29974] DEBUG -- : Duracloud::Request GET https://duke.duracloud.org/durastore/bit-integrity/rest-api-testing 200 OK => # ``` diff --git a/lib/duracloud.rb b/lib/duracloud.rb index 2e16fab..1514137 100644 --- a/lib/duracloud.rb +++ b/lib/duracloud.rb @@ -1,7 +1,10 @@ -require "duracloud/version" -require "duracloud/error" +require 'logger' +require 'uri' +require 'duracloud/version' +require 'duracloud/error' module Duracloud + autoload :AbstractEntity, "duracloud/abstract_entity" autoload :AuditLog, "duracloud/audit_log" autoload :BitIntegrityReport, "duracloud/bit_integrity_report" @@ -10,24 +13,47 @@ module Duracloud autoload :CLI, "duracloud/cli" autoload :CommandOptions, "duracloud/command_options" autoload :Commands, "duracloud/commands" - autoload :Configuration, "duracloud/configuration" - autoload :Connection, "duracloud/connection" autoload :Content, "duracloud/content" autoload :ContentManifest, "duracloud/content_manifest" - autoload :DurastoreRequest, "duracloud/durastore_request" - autoload :ErrorHandler, "duracloud/error_handler" autoload :FastSyncValidation, "duracloud/fast_sync_validation" autoload :Manifest, "duracloud/manifest" - autoload :Persistence, "duracloud/persistence" autoload :Properties, "duracloud/properties" autoload :Request, "duracloud/request" autoload :Response, "duracloud/response" + autoload :ResponseHandler, "duracloud/response_handler" autoload :RestMethods, "duracloud/rest_methods" autoload :Space, "duracloud/space" autoload :SpaceAcls, "duracloud/space_acls" - autoload :Store, "duracloud/store" autoload :StorageReport, "duracloud/storage_report" autoload :StorageReports, "duracloud/storage_reports" + autoload :Store, "duracloud/store" autoload :SyncValidation, "duracloud/sync_validation" autoload :TSV, "duracloud/tsv" + + class << self + attr_accessor :host, :port, :user, :password + attr_writer :logger + + def logger + @logger ||= Logger.new(STDERR) + end + + def silence_logging! + self.logger = Logger.new(File::NULL) + end + + def base_url + URI::HTTPS.build(host: host, port: port, path: '/') + end + + def auth? + !!user + end + end + + self.host = ENV["DURACLOUD_HOST"] + self.port = ENV["DURACLOUD_PORT"] + self.user = ENV["DURACLOUD_USER"] + self.password = ENV["DURACLOUD_PASSWORD"] + end diff --git a/lib/duracloud/abstract_entity.rb b/lib/duracloud/abstract_entity.rb index 88e3fe1..0eda84b 100644 --- a/lib/duracloud/abstract_entity.rb +++ b/lib/duracloud/abstract_entity.rb @@ -1,3 +1,5 @@ +require 'hashie' + module Duracloud class AbstractEntity < Hashie::Dash diff --git a/lib/duracloud/cli.rb b/lib/duracloud/cli.rb index d086981..b94c683 100644 --- a/lib/duracloud/cli.rb +++ b/lib/duracloud/cli.rb @@ -66,14 +66,12 @@ def execute private def configure_client - Client.configure do |config| - config.user = user if user - config.password = password if password - config.host = host if host - config.port = port if port + Duracloud.user = user if user + Duracloud.password = password if password + Duracloud.host = host if host + Duracloud.port = port if port - config.silence_logging! unless logging - end + Duracloud.silence_logging! unless logging end end diff --git a/lib/duracloud/client.rb b/lib/duracloud/client.rb index db761e8..7523adc 100644 --- a/lib/duracloud/client.rb +++ b/lib/duracloud/client.rb @@ -1,46 +1,17 @@ -require "forwardable" - module Duracloud class Client - extend Forwardable extend RestMethods include RestMethods - def self.execute(request_class, http_method, url, **options, &block) - new.execute(request_class, http_method, url, **options, &block) - end - - def self.configure - yield Configuration + def self.execute(http_method, url, **options, &block) + new.execute(http_method, url, **options, &block) end - attr_reader :config - - delegate [:host, :port, :user, :password, :base_url, :logger] => :config - - def initialize(**options) - @config = Configuration.new(**options) - end - - def execute(request_class, http_method, url, **options, &block) - request = request_class.new(self, http_method, url, **options) - response = request.execute(&block) - handle_response(response) - response - end - - private - - def handle_response(response) - logger.debug([self.class.to_s, response.request_method, response.url, response.request_query, - response.status, response.reason].join(' ')) - if response.error? - ErrorHandler.call(response) - elsif %w(POST PUT DELETE).include?(response.request_method) && - response.plain_text? && - response.has_body? - logger.info(response.body) + def execute(http_method, url, **options, &block) + Request.execute(http_method, url, **options, &block).tap do |response| + ResponseHandler.call(response) end end + end end diff --git a/lib/duracloud/configuration.rb b/lib/duracloud/configuration.rb deleted file mode 100644 index 8adab21..0000000 --- a/lib/duracloud/configuration.rb +++ /dev/null @@ -1,42 +0,0 @@ -require "logger" -require "uri" - -module Duracloud - class Configuration - - class << self - attr_accessor :host, :port, :user, :password, :logger - - def silence_logging! - self.logger = Logger.new(File::NULL) - end - end - - attr_reader :host, :port, :user, :password, :logger - - def initialize(host: nil, port: nil, user: nil, password: nil, logger: nil) - @host = host || default(:host) - @port = port || default(:port) - @user = user || default(:user) - @password = password || default(:password) - @logger = logger || self.class.logger || Logger.new(STDERR) - freeze - end - - def base_url - URI::HTTPS.build(host: host, port: port) - end - - def inspect - "#<#{self.class} host=#{host.inspect}, port=#{port.inspect}," \ - " user=#{user.inspect}>" - end - - private - - def default(attr) - self.class.send(attr) || ENV["DURACLOUD_#{attr.to_s.upcase}"] - end - - end -end diff --git a/lib/duracloud/connection.rb b/lib/duracloud/connection.rb deleted file mode 100644 index 8d288b7..0000000 --- a/lib/duracloud/connection.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'httpclient' - -module Duracloud - # - # An HTTP connection to DuraCloud. - # - # @note We are using HTTPClient because Net::HTTP capitalizes - # request header names which is incompatible with DuraCloud's - # custom case-sensitive content property headers (x-dura-meta-*). - # - class Connection < HTTPClient - def initialize(client, base_path = '/') - base_url = client.base_url + base_path - super(base_url: base_url, force_basic_auth: true) - set_auth(client.base_url, client.user, client.password) - end - end -end diff --git a/lib/duracloud/durastore_request.rb b/lib/duracloud/durastore_request.rb deleted file mode 100644 index be2c868..0000000 --- a/lib/duracloud/durastore_request.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Duracloud - class DurastoreRequest < Request - def base_path - '/durastore/' - end - end -end diff --git a/lib/duracloud/error_handler.rb b/lib/duracloud/error_handler.rb deleted file mode 100644 index ff221d0..0000000 --- a/lib/duracloud/error_handler.rb +++ /dev/null @@ -1,56 +0,0 @@ -module Duracloud - class ErrorHandler - def self.call(response) - new(response).call - end - - attr_reader :response - - def initialize(response) - @response = response # XXX dup? - end - - def call - message = response_has_error_message? ? response.body : status_message - raise handle_status, message - end - - def status_message - [response.status, response.reason].join(' ') - end - - def server_error? - response.status >= 500 - end - - def handle_status - send("handle_#{response.status}") - rescue NoMethodError - server_error? ? handle_server_error : handle_default - end - - def handle_server_error - ServerError - end - - def handle_default - Error - end - - def handle_400 - BadRequestError - end - - def handle_404 - NotFoundError - end - - def handle_409 - ConflictError - end - - def response_has_error_message? - response.plain_text? && response.has_body? - end - end -end diff --git a/lib/duracloud/request.rb b/lib/duracloud/request.rb index 30b6560..9f1154b 100644 --- a/lib/duracloud/request.rb +++ b/lib/duracloud/request.rb @@ -1,29 +1,47 @@ require 'addressable/uri' +require 'httpclient' module Duracloud class Request - attr_reader :client, :url, :http_method, :body, :headers, :query - # @param client [Duracloud::Client] the client + attr_reader :url, :http_method, :body, :headers, :query + + def self.execute(http_method, url, **options, &block) + request = new(http_method, url, **options) + request.execute(&block) + end + # @param http_method [Symbol] the lower-case symbol corresponding to HTTP method # @param url [String] relative or absolute URL # @param body [String] the body of the request # @param headers [Hash] HTTP headers # @param query [Hash] Query string parameters # def initialize(client, http_method, url, body: nil, headers: nil, query: nil) - def initialize(client, http_method, url, **options) - @client = client + def initialize(http_method, url, **options) @http_method = http_method @url = Addressable::URI.parse(url).normalize.to_s set_options(options.dup) end def execute(&block) - response_class.new original_response(&block) + Response.new(original_response(&block)).tap do |response| + log_request(response) + end end private + def log_request(response) + message = [ self.class.to_s, + response.request_method, + response.request_uri, + response.request_query, + response.status, + response.reason + ].join(' ') + Duracloud.logger.debug(message) + end + def original_response(&block) connection.send(http_method, url, @@ -41,16 +59,14 @@ def set_options(options) @query = query.merge(options).reject { |k, v| v.to_s.empty? } end - def base_path - '/' - end - - def response_class - Response - end - + # @return [HTTPClient] An HTTP connection to DuraCloud. + # @note We are using HTTPClient because Net::HTTP capitalizes + # request header names which is incompatible with DuraCloud's + # custom case-sensitive content property headers (x-dura-meta-*). def connection - @connection ||= Connection.new(client, base_path) + HTTPClient.new(base_url: Duracloud.base_url, force_basic_auth: Duracloud.auth?).tap do |conn| + conn.set_auth(Duracloud.base_url, Duracloud.user, Duracloud.password) if Duracloud.auth? + end end end end diff --git a/lib/duracloud/response.rb b/lib/duracloud/response.rb index d531058..6f87545 100644 --- a/lib/duracloud/response.rb +++ b/lib/duracloud/response.rb @@ -8,12 +8,10 @@ class Response attr_reader :original_response delegate [:header, :body, :code, :ok?, :redirect?, :status, :reason] => :original_response, - :content_type => :header, + [:content_type, :request_method, :request_uri, :request_query] => :header, :empty? => :body def_delegator :header, :request_uri, :url - def_delegator :header, :request_method - def_delegator :header, :request_query def initialize(original_response) @original_response = original_response @@ -49,5 +47,6 @@ def size def modified DateTime.parse(header["last-modified"].first) rescue nil end + end end diff --git a/lib/duracloud/response_handler.rb b/lib/duracloud/response_handler.rb new file mode 100644 index 0000000..8a74ca2 --- /dev/null +++ b/lib/duracloud/response_handler.rb @@ -0,0 +1,63 @@ +module Duracloud + class ResponseHandler + + def self.call(response) + new(response).call + end + + attr_reader :response + + def initialize(response) + @response = response + end + + def call + handle_error + log_response + end + + def log_response + if loggable_response_body? + Duracloud.logger.info(response.body) + end + end + + def loggable_response_body? + %w(POST PUT DELETE).include?(response.request_method) && + response.plain_text? && + response.has_body? + end + + def handle_error + if response.error? + raise exception, error_message + end + end + + def error_message + if response.plain_text? && response.has_body? + response.body + else + [ response.status, response.reason ].join(' ') + end + end + + def exception + case response.status + when 400 + BadRequestError + when 404 + NotFoundError + when 409 + ConflictError + else + if response.status >= 500 + ServerError + else + Error + end + end + end + + end +end diff --git a/lib/duracloud/rest_methods.rb b/lib/duracloud/rest_methods.rb index 626625c..67714f3 100644 --- a/lib/duracloud/rest_methods.rb +++ b/lib/duracloud/rest_methods.rb @@ -125,8 +125,9 @@ def get_storage_reports_for_all_spaces_in_a_store(epoch_ms, **query) private - def durastore(*args, &block) - execute(DurastoreRequest, *args, &block) + def durastore(http_method, url_path, **options, &block) + url = [ "durastore", url_path ].join("/") + execute(http_method, url, **options, &block) end def durastore_content(http_method, space_id, content_id, **options, &block) diff --git a/lib/duracloud/space.rb b/lib/duracloud/space.rb index dcc7bfd..169c6f6 100644 --- a/lib/duracloud/space.rb +++ b/lib/duracloud/space.rb @@ -1,5 +1,5 @@ -require "date" -require "nokogiri" +require 'date' +require 'nokogiri' module Duracloud # diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a007a88..da7a77b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,12 +16,10 @@ def self.normalize_headers(headers) end end -Duracloud::Client.configure do |config| - config.host = "example.com" - config.user = "testuser" - config.password = "testpass" - config.silence_logging! -end +Duracloud.host = "example.com" +Duracloud.user = "testuser" +Duracloud.password = "testpass" +Duracloud.silence_logging! RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate From 7f0d9d9879673d76cf34bca743a6fa19ba34c9a8 Mon Sep 17 00:00:00 2001 From: David Chandek-Stark Date: Wed, 1 Nov 2017 14:47:39 -0400 Subject: [PATCH 7/7] Version 0.10.0 --- lib/duracloud/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/duracloud/version.rb b/lib/duracloud/version.rb index 33e1f61..aa3637a 100644 --- a/lib/duracloud/version.rb +++ b/lib/duracloud/version.rb @@ -1,3 +1,3 @@ module Duracloud - VERSION = "0.10.0.pre" + VERSION = "0.10.0" end