sony-ci-api 0.0.1 → 0.0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78ddca4a90c4040cd7dd9061255f8093be1f6ad0
|
4
|
+
data.tar.gz: 7dc66ce63747e28bba420c2002a8ee521559060c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb0604d3a6b3b1dabafc68c8ea32637b5855fcc9bd747e1eb2d4ef5c02c826100160c983432f09df973aa7533d183173483fe6cf7779f7318046dbefaf39fd49
|
7
|
+
data.tar.gz: d037bef8500d5b8f45f6e9f363306ee4871ce295a9e38e260a132861352368040183a4a4e7395a4bfbd30b825d86487f9e75b9cf56a90b437487c1e2da3c4bb6
|
data/bin/sony-ci-api
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/sony-ci-api/sony_ci_admin'
|
4
|
+
|
5
|
+
args = begin
|
6
|
+
Hash[ARGV.slice_before { |a| a.match(/^--/) }.to_a.map { |a| [a[0].gsub(/^--/, ''), a[1..-1]] }]
|
7
|
+
rescue
|
8
|
+
{}
|
9
|
+
end
|
10
|
+
|
11
|
+
ci = SonyCiAdmin.new(
|
12
|
+
# verbose: true,
|
13
|
+
credentials_path: 'ci.yml')
|
14
|
+
|
15
|
+
begin
|
16
|
+
case args.keys.sort
|
17
|
+
|
18
|
+
when ['log', 'up']
|
19
|
+
fail ArgumentError.new if args['log'].empty? || args['up'].empty?
|
20
|
+
args['up'].each { |path| ci.upload(path, args['log'].first) }
|
21
|
+
|
22
|
+
when ['down']
|
23
|
+
fail ArgumentError.new if args['down'].empty?
|
24
|
+
args['down'].each { |id| puts ci.download(id) }
|
25
|
+
|
26
|
+
when ['list']
|
27
|
+
fail ArgumentError.new unless args['list'].empty?
|
28
|
+
ci.each { |asset| puts "#{asset['name']}\t#{asset['id']}" }
|
29
|
+
|
30
|
+
when ['recheck']
|
31
|
+
fail ArgumentError.new if args['recheck'].empty?
|
32
|
+
args['recheck'].each do |file|
|
33
|
+
File.foreach(file) do |line|
|
34
|
+
line.chomp!
|
35
|
+
id = line.split("\t")[2]
|
36
|
+
detail = ci.detail(id).to_s.gsub("\n", ' ')
|
37
|
+
puts line + "\t" + detail
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
else
|
42
|
+
fail ArgumentError.new
|
43
|
+
end
|
44
|
+
rescue ArgumentError
|
45
|
+
abort 'Usage: --up GLOB --log LOG_FILE | --down ID | --list | --recheck LOG_FILE'
|
46
|
+
end
|
data/lib/sony-ci-api.rb
ADDED
@@ -6,32 +6,39 @@ require_relative 'sony_ci_basic'
|
|
6
6
|
class SonyCiAdmin < SonyCiBasic
|
7
7
|
include Enumerable
|
8
8
|
|
9
|
+
# Upload a document to Ci. Underlying API treats large and small files
|
10
|
+
# differently, but this should treat both alike.
|
9
11
|
def upload(file_path, log_file)
|
10
12
|
Uploader.new(self, file_path, log_file).upload
|
11
13
|
end
|
12
14
|
|
15
|
+
# Just the names of items in the workspace. This may include directories.
|
13
16
|
def list_names
|
14
17
|
list.map { |item| item['name'] } - ['Workspace']
|
15
18
|
# A self reference is present even in an empty workspace.
|
16
19
|
end
|
17
20
|
|
21
|
+
# Full metadata for a windowed set of items.
|
18
22
|
def list(limit=50, offset=0)
|
19
23
|
Lister.new(self).list(limit, offset)
|
20
24
|
end
|
21
25
|
|
26
|
+
# Iterate over all items.
|
22
27
|
def each
|
23
28
|
Lister.new(self).each { |asset| yield asset }
|
24
29
|
end
|
25
30
|
|
31
|
+
# Delete items by asset ID.
|
26
32
|
def delete(asset_id)
|
27
33
|
Deleter.new(self).delete(asset_id)
|
28
34
|
end
|
29
35
|
|
36
|
+
# Get detailed metadata by asset ID.
|
30
37
|
def detail(asset_id)
|
31
38
|
Detailer.new(self).detail(asset_id)
|
32
39
|
end
|
33
40
|
|
34
|
-
class CiClient
|
41
|
+
class CiClient #:nodoc:
|
35
42
|
# This class hierarchy might be excessive, but it gives us:
|
36
43
|
# - a single place for the `perform` method
|
37
44
|
# - and an isolated container for related private methods
|
@@ -47,7 +54,7 @@ class SonyCiAdmin < SonyCiBasic
|
|
47
54
|
end
|
48
55
|
end
|
49
56
|
|
50
|
-
class Detailer < CiClient
|
57
|
+
class Detailer < CiClient #:nodoc:
|
51
58
|
def initialize(ci)
|
52
59
|
@ci = ci
|
53
60
|
end
|
@@ -60,7 +67,7 @@ class SonyCiAdmin < SonyCiBasic
|
|
60
67
|
end
|
61
68
|
end
|
62
69
|
|
63
|
-
class Deleter < CiClient
|
70
|
+
class Deleter < CiClient #:nodoc:
|
64
71
|
def initialize(ci)
|
65
72
|
@ci = ci
|
66
73
|
end
|
@@ -72,7 +79,7 @@ class SonyCiAdmin < SonyCiBasic
|
|
72
79
|
end
|
73
80
|
end
|
74
81
|
|
75
|
-
class Lister < CiClient
|
82
|
+
class Lister < CiClient #:nodoc:
|
76
83
|
include Enumerable
|
77
84
|
|
78
85
|
def initialize(ci)
|
@@ -99,7 +106,7 @@ class SonyCiAdmin < SonyCiBasic
|
|
99
106
|
end
|
100
107
|
end
|
101
108
|
|
102
|
-
class Uploader < CiClient
|
109
|
+
class Uploader < CiClient #:nodoc:
|
103
110
|
def initialize(ci, path, log_path)
|
104
111
|
@ci = ci
|
105
112
|
@path = path
|
@@ -172,49 +179,3 @@ class SonyCiAdmin < SonyCiBasic
|
|
172
179
|
end
|
173
180
|
end
|
174
181
|
|
175
|
-
if __FILE__ == $PROGRAM_NAME
|
176
|
-
args = begin
|
177
|
-
Hash[ARGV.slice_before { |a| a.match(/^--/) }.to_a.map { |a| [a[0].gsub(/^--/, ''), a[1..-1]] }]
|
178
|
-
rescue
|
179
|
-
{}
|
180
|
-
end
|
181
|
-
|
182
|
-
ci = Ci.new(
|
183
|
-
# verbose: true,
|
184
|
-
credentials_path: Rails.root + 'config/ci.yml')
|
185
|
-
|
186
|
-
begin
|
187
|
-
case args.keys.sort
|
188
|
-
|
189
|
-
when ['log', 'up']
|
190
|
-
fail ArgumentError.new if args['log'].empty? || args['up'].empty?
|
191
|
-
args['up'].each { |path| ci.upload(path, args['log'].first) }
|
192
|
-
|
193
|
-
when ['down']
|
194
|
-
fail ArgumentError.new if args['down'].empty?
|
195
|
-
args['down'].each { |id| puts ci.download(id) }
|
196
|
-
|
197
|
-
when ['list']
|
198
|
-
fail ArgumentError.new unless args['list'].empty?
|
199
|
-
ci.each { |asset| puts "#{asset['name']}\t#{asset['id']}" }
|
200
|
-
|
201
|
-
when ['recheck']
|
202
|
-
fail ArgumentError.new if args['recheck'].empty?
|
203
|
-
args['recheck'].each do |file|
|
204
|
-
File.foreach(file) do |line|
|
205
|
-
line.chomp!
|
206
|
-
id = line.split("\t")[2]
|
207
|
-
detail = ci.detail(id).to_s.gsub("\n", ' ')
|
208
|
-
puts line + "\t" + detail
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
else
|
213
|
-
fail ArgumentError.new
|
214
|
-
end
|
215
|
-
rescue ArgumentError
|
216
|
-
abort 'Usage: --up GLOB --log LOG_FILE | --down ID | --list | --recheck LOG_FILE'
|
217
|
-
end
|
218
|
-
|
219
|
-
end
|
220
|
-
|
@@ -7,6 +7,7 @@ class SonyCiBasic
|
|
7
7
|
attr_reader :verbose
|
8
8
|
attr_reader :workspace_id
|
9
9
|
|
10
|
+
# Either +credentials_path+ or a +credentials+ object itself must be supplied.
|
10
11
|
def initialize(opts={}) # rubocop:disable PerceivedComplexity, CyclomaticComplexity
|
11
12
|
unrecognized_opts = opts.keys - [:verbose, :credentials_path, :credentials]
|
12
13
|
fail "Unrecognized options #{unrecognized_opts}" unless unrecognized_opts == []
|
@@ -44,11 +45,12 @@ class SonyCiBasic
|
|
44
45
|
@workspace_id = credentials['workspace_id']
|
45
46
|
end
|
46
47
|
|
48
|
+
# Generate a temporary download URL for an asset.
|
47
49
|
def download(asset_id)
|
48
50
|
Downloader.new(self).download(asset_id)
|
49
51
|
end
|
50
52
|
|
51
|
-
class CiClient
|
53
|
+
class CiClient #:nodoc:
|
52
54
|
# This class hierarchy might be excessive, but it gives us:
|
53
55
|
# - a single place for the `perform` method
|
54
56
|
# - and an isolated container for related private methods
|
@@ -64,7 +66,7 @@ class SonyCiBasic
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
class Downloader < CiClient
|
69
|
+
class Downloader < CiClient #:nodoc:
|
68
70
|
@@cache = {}
|
69
71
|
|
70
72
|
def initialize(ci)
|
@@ -84,49 +86,3 @@ class SonyCiBasic
|
|
84
86
|
end
|
85
87
|
end
|
86
88
|
end
|
87
|
-
|
88
|
-
if __FILE__ == $PROGRAM_NAME
|
89
|
-
args = begin
|
90
|
-
Hash[ARGV.slice_before { |a| a.match(/^--/) }.to_a.map { |a| [a[0].gsub(/^--/, ''), a[1..-1]] }]
|
91
|
-
rescue
|
92
|
-
{}
|
93
|
-
end
|
94
|
-
|
95
|
-
ci = Ci.new(
|
96
|
-
# verbose: true,
|
97
|
-
credentials_path: Rails.root + 'config/ci.yml')
|
98
|
-
|
99
|
-
begin
|
100
|
-
case args.keys.sort
|
101
|
-
|
102
|
-
when ['log', 'up']
|
103
|
-
fail ArgumentError.new if args['log'].empty? || args['up'].empty?
|
104
|
-
args['up'].each { |path| ci.upload(path, args['log'].first) }
|
105
|
-
|
106
|
-
when ['down']
|
107
|
-
fail ArgumentError.new if args['down'].empty?
|
108
|
-
args['down'].each { |id| puts ci.download(id) }
|
109
|
-
|
110
|
-
when ['list']
|
111
|
-
fail ArgumentError.new unless args['list'].empty?
|
112
|
-
ci.each { |asset| puts "#{asset['name']}\t#{asset['id']}" }
|
113
|
-
|
114
|
-
when ['recheck']
|
115
|
-
fail ArgumentError.new if args['recheck'].empty?
|
116
|
-
args['recheck'].each do |file|
|
117
|
-
File.foreach(file) do |line|
|
118
|
-
line.chomp!
|
119
|
-
id = line.split("\t")[2]
|
120
|
-
detail = ci.detail(id).to_s.gsub("\n", ' ')
|
121
|
-
puts line + "\t" + detail
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
else
|
126
|
-
fail ArgumentError.new
|
127
|
-
end
|
128
|
-
rescue ArgumentError
|
129
|
-
abort 'Usage: --up GLOB --log LOG_FILE | --down ID | --list | --recheck LOG_FILE'
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sony-ci-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuck McCallum
|
@@ -12,12 +12,15 @@ date: 2015-05-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
13
13
|
description: Wrapper for the Sony Ci API (http://developers.cimediacloud.com/)
|
14
14
|
email: chuck_mccallum@wgbh.org
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- sony-ci-api
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
19
|
-
-
|
20
|
-
- lib/
|
20
|
+
- bin/sony-ci-api
|
21
|
+
- lib/sony-ci-api.rb
|
22
|
+
- lib/sony-ci-api/sony_ci_admin.rb
|
23
|
+
- lib/sony-ci-api/sony_ci_basic.rb
|
21
24
|
homepage: https://github.com/WGBH/sony-ci-api
|
22
25
|
licenses:
|
23
26
|
- MIT
|