-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
189 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
require 'duracloud' | ||
|
||
Duracloud::Command.call(*ARGV) | ||
Duracloud::CLI.call(*ARGV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'delegate' | ||
|
||
module Duracloud::Commands | ||
class Command < SimpleDelegator | ||
|
||
def self.call(command) | ||
new(command).call | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require_relative "command" | ||
|
||
module Duracloud::Commands | ||
class DownloadManifest < Command | ||
|
||
def call | ||
Duracloud::Manifest.download(space_id, store_id, format: format) do |chunk| | ||
print chunk | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require_relative "command" | ||
|
||
module Duracloud::Commands | ||
class GetProperties < Command | ||
|
||
def call | ||
proplist = content_id ? content_properties : space_properties | ||
puts proplist | ||
end | ||
|
||
private | ||
|
||
def content_properties | ||
content = Duracloud::Content.find(space_id: space_id, store_id: store_id, content_id: content_id, md5: md5) | ||
proplist = content.properties.map { |k, v| "#{k}: #{v}" } | ||
proplist << "MD5: #{content.md5}" | ||
proplist << "Size: #{content.size} (#{content.human_size})" | ||
proplist << "Chunked?: #{content.chunked?}" | ||
end | ||
|
||
def space_properties | ||
space = Duracloud::Space.find(space_id, store_id) | ||
space.properties.map { |k, v| "#{k}: #{v}" } | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require_relative 'command' | ||
|
||
module Duracloud::Commands | ||
class Sync < Command | ||
|
||
def call | ||
if infile | ||
File.open(infile, "rb") do |f| | ||
self.content_id ||= infile # XXX relativize to cwd? | ||
Duracloud::Content.create(space_id: space_id, store_id: store_id, content_id: content_id, md5: md5, body: f) | ||
end | ||
else | ||
Duracloud::Content.create(space_id: space_id, store_id: store_id, content_id: content_id, md5: md5, body: $stdin) | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require_relative "command" | ||
|
||
module Duracloud::Commands | ||
class Validate < Command | ||
|
||
def call | ||
Duracloud::SyncValidation.call(space_id: space_id, store_id: store_id, content_dir: content_dir) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Duracloud | ||
VERSION = "0.7.2" | ||
VERSION = "0.8.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module Duracloud | ||
RSpec.describe CLI do | ||
|
||
subject { described_class.new(**opts) } | ||
|
||
describe "properties" do | ||
let(:opts) { {space_id: "foo", content_id: "bar"} } | ||
let(:command) { "properties" } | ||
specify { | ||
expect(Commands::GetProperties).to receive(:call).with(subject) { nil } | ||
subject.execute(command) | ||
} | ||
end | ||
|
||
describe "sync" do | ||
let(:opts) { {space_id: "foo", content_id: "bar", infile: "foo/bar"} } | ||
let(:command) { "sync" } | ||
specify { | ||
expect(Commands::Sync).to receive(:call).with(subject) { nil } | ||
subject.execute(command) | ||
} | ||
end | ||
|
||
describe "validate" do | ||
let(:opts) { {space_id: "foo", content_dir: "/tmp"} } | ||
let(:command) { "validate" } | ||
specify { | ||
expect(Commands::Validate).to receive(:call).with(subject) { nil } | ||
subject.execute(command) | ||
} | ||
end | ||
|
||
describe "manifest" do | ||
let(:opts) { {space_id: "foo"} } | ||
let(:command) { "manifest" } | ||
specify { | ||
expect(Commands::DownloadManifest).to receive(:call).with(subject) { nil } | ||
subject.execute(command) | ||
} | ||
end | ||
|
||
end | ||
end |