matterhorn_whymper 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/lib/matterhorn/endpoint/ingest.rb +24 -10
- data/lib/matterhorn/http_client.rb +1 -1
- data/lib/matterhorn_whymper/version.rb +1 -1
- data/matterhorn_whymper.gemspec +2 -0
- data/spec/files/empty_media_package.xml +7 -0
- data/spec/files/media_package_with_one_track.xml +9 -0
- data/spec/remote/matterhorn/endpoint/ingest_spec.rb +19 -0
- data/spec/spec_helper.rb +20 -1
- data/spec/support/fixture_helpers.rb +15 -0
- data/spec/support/remote_helpers.rb +15 -0
- data/spec/{Matterhorn_whymper_spec.rb → unit/Matterhorn_whymper_spec.rb} +0 -0
- data/spec/unit/matterhorn/endpoint/ingest_spec.rb +30 -0
- data/spec/{endpoints_spec.rb → unit/matterhorn/endpoints_spec.rb} +2 -19
- metadata +46 -6
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Njg3OGRhNTBkYTBhNWY2MWJiM2Y4NzUyZGMyYTQ2NmExMTI4MzNjNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2RiNzg1OWE5OGI5ZWZkMGFjOGU5MDljY2ViMDNjYjQ3NDAwNjE4YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzgwM2RlZGQ3ZGE3MDY1YzFlYzdlMDBlOTRmYzRhMTFjN2E5OTU5MzBlN2Y2
|
10
|
+
NDg1ZTBmZGMwMDM1NTU2OWFjMGM0MzBlYmFhYzc4ZDg2ODMzZTc0ZWM2YTg4
|
11
|
+
ZDViMGNmNGEyZmU5NGE3OGYyNzgxN2NlNGQyZGZlYTJjMmFmNDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODAyNDUzMzg0Y2JhMmY0NTBiMGZkYzgwZThhODkxOTMwMjY0ZDU1MjllMGJh
|
14
|
+
NDMwMDA0NGQwMThiNjQwYzMyMTYxNzcwYzE2ODVmMmZjNmZkNGZhYWNmMzYy
|
15
|
+
YmE3OTI4OTE5MjhiZDM4OTM0Y2ZiODQ5OTc2NzBhYzJjZjlhNzk=
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -76,18 +76,32 @@ class Matterhorn::Endpoint::Ingest < Matterhorn::Endpoint
|
|
76
76
|
@media_pkg_remote
|
77
77
|
end
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
HTTP_PROTOCOL_RE = /^https?:/
|
80
|
+
|
81
|
+
def addTrack(file_or_url, flavor)
|
81
82
|
unless @media_pkg_remote then raise(Matterhorn::Error, "No media package is available!"); end
|
82
|
-
@media_pkg_local.add_track(
|
83
|
+
@media_pkg_local.add_track(file_or_url, flavor) if @media_pkg_local
|
83
84
|
begin
|
84
|
-
@media_pkg_remote =
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
@media_pkg_remote =
|
86
|
+
if HTTP_PROTOCOL_RE =~ file_or_url
|
87
|
+
http_client.post(
|
88
|
+
"ingest/addTrack",
|
89
|
+
{
|
90
|
+
'flavor' => flavor,
|
91
|
+
'mediaPackage' => @media_pkg_remote,
|
92
|
+
'url' => file_or_url
|
93
|
+
}
|
94
|
+
).body
|
95
|
+
else
|
96
|
+
http_client.post(
|
97
|
+
"ingest/addTrack",
|
98
|
+
{
|
99
|
+
'flavor' => flavor,
|
100
|
+
'mediaPackage' => @media_pkg_remote,
|
101
|
+
'BODY' => file_or_url
|
102
|
+
}
|
103
|
+
).body
|
104
|
+
end
|
91
105
|
rescue Matterhorn::HttpClientError => ex
|
92
106
|
MatterhornWhymper.logger.error { "#{self.class.name}::addTrack | " +
|
93
107
|
"Media package not valid! / media package:\n#{@media_pkg_remote}" }
|
@@ -5,7 +5,7 @@ module MatterhornWhymper
|
|
5
5
|
|
6
6
|
# -------------------------------------------------------------------------- const definitions ---
|
7
7
|
|
8
|
-
VERSION = "0.
|
8
|
+
VERSION = "0.3.0"
|
9
9
|
|
10
10
|
|
11
11
|
end # -------------------------------------------------------------------- end MatterhornWhymper ---
|
data/matterhorn_whymper.gemspec
CHANGED
@@ -22,8 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency "multipart-post", "~> 2.0"
|
23
23
|
spec.add_runtime_dependency "net-http-digest_auth", "~> 1.4"
|
24
24
|
spec.add_runtime_dependency "nokogiri", "~> 1.6"
|
25
|
+
spec.add_runtime_dependency "mime-types", "> 1.25"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.6"
|
27
28
|
spec.add_development_dependency "rake", "~> 10.3"
|
28
29
|
spec.add_development_dependency "rspec", "~> 2.14"
|
30
|
+
spec.add_development_dependency "webmock", "~> 1.18"
|
29
31
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<mediapackage xmlns="http://mediapackage.opencastproject.org" start="2014-06-16T14:20:42Z" id="188d25d5-c93d-4b09-80ab-95e13a352b14">
|
3
|
+
<media>
|
4
|
+
<track type="source/raw" id="beef711f-6519-4cf6-8af5-8eac5aaa50c5"><tags/><url>http://mh-int-admin.bcc.switch.ch/files/mediapackage/188d25d5-c93d-4b09-80ab-95e13a352b14/beef711f-6519-4cf6-8af5-8eac5aaa50c5/isforAto1953.avi?AWSAccessKeyId=K8Z3D0TTLAO4O55WKZDD&Expires=1403528601&Signature=HShVG9L3lNeOOjffM9RuZ997oeo%3D</url></track>
|
5
|
+
</media>
|
6
|
+
<metadata/>
|
7
|
+
<attachments/>
|
8
|
+
<publications/>
|
9
|
+
</mediapackage>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if endpoint_configured?
|
4
|
+
|
5
|
+
describe Matterhorn::Endpoint::Ingest, "when talking to the remote server" do
|
6
|
+
include Support::RemoteHelpers
|
7
|
+
|
8
|
+
it "creates a mediapackage" do
|
9
|
+
Matterhorn::Endpoint.open(:ingest) do |ingest_endpoint|
|
10
|
+
ingest_endpoint.createMediaPackage()
|
11
|
+
mp_local = ingest_endpoint.media_package
|
12
|
+
mp_remote = ingest_endpoint.media_package('remote')
|
13
|
+
expect(mp_local).not_to be nil
|
14
|
+
expect(mp_remote).not_to be nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,9 +3,16 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
Bundler.setup
|
5
5
|
|
6
|
-
require 'matterhorn_whymper'
|
6
|
+
require 'matterhorn_whymper'
|
7
|
+
require 'webmock/rspec'
|
8
|
+
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
Dir.glob(File.expand_path('../support/**/*.rb', __FILE__)).each { |lib| require lib }
|
7
12
|
|
8
13
|
RSpec.configure do |config|
|
14
|
+
config.include Support::FixtureHelpers
|
15
|
+
|
9
16
|
MatterhornWhymper.configure do |mh_config|
|
10
17
|
mh_yml = YAML::load_file( "./spec/matterhorn.yml" )
|
11
18
|
mh_config.system_account_user = mh_yml['matterhorn']['system_account_user']
|
@@ -13,4 +20,16 @@ RSpec.configure do |config|
|
|
13
20
|
mh_config.system_domain = mh_yml['matterhorn']['system_domain']
|
14
21
|
mh_config.system_protocol = mh_yml['matterhorn']['system_protocol']
|
15
22
|
end
|
23
|
+
|
24
|
+
logfile_path = File.expand_path('../../log/test.log', __FILE__)
|
25
|
+
FileUtils.mkdir_p(File.dirname(logfile_path))
|
26
|
+
MatterhornWhymper.logger = Logger.new(File.open(logfile_path, 'a'))
|
27
|
+
end
|
28
|
+
|
29
|
+
module Kernel
|
30
|
+
private
|
31
|
+
|
32
|
+
def endpoint_configured?
|
33
|
+
MatterhornWhymper.configuration.system_domain.to_s.strip != ''
|
34
|
+
end
|
16
35
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Support
|
2
|
+
module FixtureHelpers
|
3
|
+
def file_fixture_base_path
|
4
|
+
File.expand_path('../../files', __FILE__)
|
5
|
+
end
|
6
|
+
|
7
|
+
def file_fixture_filename(path)
|
8
|
+
File.join(file_fixture_base_path, path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def file_fixture_contents(path)
|
12
|
+
File.read(file_fixture_filename(path))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Support
|
2
|
+
module RemoteHelpers
|
3
|
+
def self.included(context)
|
4
|
+
context.before do
|
5
|
+
MatterhornWhymper.logger.level = Logger::DEBUG
|
6
|
+
WebMock.allow_net_connect!
|
7
|
+
end
|
8
|
+
|
9
|
+
context.after do
|
10
|
+
WebMock.disable_net_connect!
|
11
|
+
MatterhornWhymper.logger.level = Logger::WARN
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
describe Matterhorn::Endpoint::Ingest do
|
5
|
+
before do
|
6
|
+
@ingest = Matterhorn::Endpoint::Ingest.new
|
7
|
+
stub_request(:head, %r{}).to_return(status: 200, body: '', headers: { 'WWW-Authenticate' => 'Basic realm="Matterhorn"' })
|
8
|
+
stub_request(:get, %r{/ingest/createMediaPackage}).to_return(status: 200, body: file_fixture_contents('empty_media_package.xml'))
|
9
|
+
end
|
10
|
+
|
11
|
+
it "adds a local file to its media package with addTrack" do
|
12
|
+
stub_request(:post, %r{/ingest/addTrack}).to_return(status: 200, body: file_fixture_contents('media_package_with_one_track.xml'))
|
13
|
+
@ingest.createMediaPackage
|
14
|
+
tempfile = Tempfile.new('source')
|
15
|
+
tempfile.close
|
16
|
+
begin
|
17
|
+
response_body = @ingest.addTrack(tempfile.path, 'source/raw')
|
18
|
+
expect(response_body).to start_with('<?xml')
|
19
|
+
ensure
|
20
|
+
tempfile.unlink
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "adds a source URL to its media package with addTrack" do
|
25
|
+
stub_request(:post, %r{/ingest/addTrack}).to_return(status: 200, body: file_fixture_contents('media_package_with_one_track.xml'))
|
26
|
+
@ingest.createMediaPackage
|
27
|
+
response_body = @ingest.addTrack('http://example.com/path/to/file', 'source/raw')
|
28
|
+
expect(response_body).to start_with('<?xml')
|
29
|
+
end
|
30
|
+
end
|
@@ -1,34 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Matterhorn::Endpoint do
|
4
|
-
|
5
|
-
it "does ingest endpoint available" do
|
4
|
+
it "sets up an ingest endpoint" do
|
6
5
|
Matterhorn::Endpoint.open(:ingest) do |ingest_endpoint|
|
7
6
|
expect(ingest_endpoint).not_to be nil
|
8
7
|
expect(ingest_endpoint.class.name).to eq 'Matterhorn::Endpoint::Ingest'
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
12
|
-
it "
|
11
|
+
it "sets up a workflow endpoint" do
|
13
12
|
Matterhorn::Endpoint.open(:workflow) do |workflow_endpoint|
|
14
13
|
expect(workflow_endpoint).not_to be nil
|
15
14
|
expect(workflow_endpoint.class.name).to eq 'Matterhorn::Endpoint::Workflow'
|
16
15
|
end
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
20
|
-
|
21
|
-
|
22
|
-
describe "Ingest Mediapackages" do
|
23
|
-
|
24
|
-
it "creates a mediapackage" do
|
25
|
-
Matterhorn::Endpoint.open(:ingest) do |ingest_endpoint|
|
26
|
-
ingest_endpoint.createMediaPackage()
|
27
|
-
mp_local = ingest_endpoint.media_package
|
28
|
-
mp_remote = ingest_endpoint.media_package('remote')
|
29
|
-
expect(mp_local).not_to be nil
|
30
|
-
expect(mp_remote).not_to be nil
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matterhorn_whymper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Fritschi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mime-types
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>'
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.25'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>'
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.25'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - ~>
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '2.14'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.18'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.18'
|
97
125
|
description: ! "This Ruby wrapper is designed to write some ruby scripts against the\n
|
98
126
|
\ Matterhorn Endpoint API"
|
99
127
|
email:
|
@@ -120,10 +148,16 @@ files:
|
|
120
148
|
- lib/matterhorn_whymper.rb
|
121
149
|
- lib/matterhorn_whymper/version.rb
|
122
150
|
- matterhorn_whymper.gemspec
|
123
|
-
- spec/
|
124
|
-
- spec/
|
151
|
+
- spec/files/empty_media_package.xml
|
152
|
+
- spec/files/media_package_with_one_track.xml
|
125
153
|
- spec/matterhorn.yml.sample
|
154
|
+
- spec/remote/matterhorn/endpoint/ingest_spec.rb
|
126
155
|
- spec/spec_helper.rb
|
156
|
+
- spec/support/fixture_helpers.rb
|
157
|
+
- spec/support/remote_helpers.rb
|
158
|
+
- spec/unit/Matterhorn_whymper_spec.rb
|
159
|
+
- spec/unit/matterhorn/endpoint/ingest_spec.rb
|
160
|
+
- spec/unit/matterhorn/endpoints_spec.rb
|
127
161
|
homepage: https://github.com/switch-ch/matterhorn_whymper
|
128
162
|
licenses:
|
129
163
|
- MIT
|
@@ -149,7 +183,13 @@ signing_key:
|
|
149
183
|
specification_version: 4
|
150
184
|
summary: Ruby wrapper around the Matterhorn Endpoint API
|
151
185
|
test_files:
|
152
|
-
- spec/
|
153
|
-
- spec/
|
186
|
+
- spec/files/empty_media_package.xml
|
187
|
+
- spec/files/media_package_with_one_track.xml
|
154
188
|
- spec/matterhorn.yml.sample
|
189
|
+
- spec/remote/matterhorn/endpoint/ingest_spec.rb
|
155
190
|
- spec/spec_helper.rb
|
191
|
+
- spec/support/fixture_helpers.rb
|
192
|
+
- spec/support/remote_helpers.rb
|
193
|
+
- spec/unit/Matterhorn_whymper_spec.rb
|
194
|
+
- spec/unit/matterhorn/endpoint/ingest_spec.rb
|
195
|
+
- spec/unit/matterhorn/endpoints_spec.rb
|