matterhorn_whymper 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGRjZTNkNjYwM2M0OGJlMGJiZGJjMTBiYTk3YjIwNmNmMTlkMjViMg==
4
+ M2I1YmJhN2YxZWYzZjE3ZDE0NzdkYjNmZGE4ZDY3NTdhODczY2Y4MA==
5
5
  data.tar.gz: !binary |-
6
- MzQ4MTkwNGMyNDQyZmVmZDJlODJjYWUwNjJiNDY5MDAwOGY0ZjI0Mg==
6
+ N2Y5NTM0NTkwMWUyYzI4NDgwODZlMjkyZTRkNDcxM2FkNDk0NmE3YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWU4MmJjN2MyYzg0NzZjNDU1NTQ0YTA3NDJjZjQ5OGNhNDdjYTY3OTA2OWU0
10
- ZTlmMzZlZTlhNGEyNGEyNGUzOWZmNDI4YmE0MDdiODA1ZGJkNWVmMDMzZjQ1
11
- NWEyYTBkNzE4MTY3ZDgxNjViNmFiYWM2ZGYyM2Y3YTEzYmJlOTc=
9
+ MzA5MmI5NDI5MWMxOGIyZjRkYjkwYmQxZWZhNzAyZGNiY2M2MTdkYzRkNjg1
10
+ NWE5ODg4ZTUwODVmYzJiOTNmZTUzNzZkMzQ1OTQ2Nzg3NzZiMmY0NzRmNmE0
11
+ OWE3NTk4MTIwNjY4ZTk3NjM5Yzc0Zjc2MWQzODAwMTI3MWUyNzk=
12
12
  data.tar.gz: !binary |-
13
- ZmU1M2RkODAzMDVkYWM2ZjhmZmI4OWQ3N2IwYTM1MGJmOTRmYzZkNDk2MDg5
14
- NWI3MDlkYjQxYjlmMDViMjU1N2I2YTgwYjNmNTFhNWRlMzZjOWJiN2ZlMGM5
15
- MTJjYzA0ZDdhODZkYWYyMDRjZWFlMDMyODEyNmVlMDdhZjA0ZDE=
13
+ YjE3MzU2OGM1ODA0ZmM1MzJjNDQyYjJlZGY2ZTUzOWU3NWRmMDcwNmI2ZWM3
14
+ OGM0ZWQzOWI3NzFjNjY2OWEyOWNlMWUwMTVkNjE4MTkwZTAzMzY2Y2U0YjM0
15
+ NDcxM2ZkYzY2MDIwODFjOGI1ZWIwMjYyNzA5MzUzOTA4Yzc4NGQ=
@@ -142,16 +142,16 @@ class Matterhorn::DublinCore
142
142
  def get_value(ns, key)
143
143
  elem = @document.xpath("/xmlns:dublincore/#{ns}:#{key}").first
144
144
  return nil if elem.nil?
145
- elem.content
145
+ elem.content.to_s.strip
146
146
  end
147
147
 
148
148
 
149
149
  def set_value(ns, key, value)
150
150
  if !(elem = @document.at_xpath("/xmlns:dublincore/#{ns}:#{key}")).nil?
151
- elem.content = value
151
+ elem.content = value.to_s.strip
152
152
  else
153
153
  elem = Nokogiri::XML::Element.new(key, @document)
154
- elem.content = value
154
+ elem.content = value.to_s.strip
155
155
  elem.namespace = get_ns(ns) unless ns.nil?
156
156
  @document.root << elem
157
157
  end
@@ -162,7 +162,7 @@ class Matterhorn::DublinCore
162
162
  def add_value(ns, key, value)
163
163
  sibling = @document.xpath("/xmlns:dublincore/#{ns}:#{key}").last
164
164
  elem = Nokogiri::XML::Element.new(key, @document)
165
- elem.content = value
165
+ elem.content = value.to_s.strip
166
166
  elem.namespace = get_ns(ns) unless ns.nil?
167
167
  if !sibling.nil?
168
168
  sibling.after(elem)
@@ -175,7 +175,7 @@ class Matterhorn::DublinCore
175
175
 
176
176
  def each_element(ns, &block)
177
177
  @document.xpath("/xmlns:dublincore/#{ns}:*").each do |elem|
178
- yield elem.name, elem.content
178
+ yield elem.name, elem.content.to_s.strip
179
179
  end
180
180
  end
181
181
 
@@ -65,7 +65,7 @@ class Matterhorn::Endpoint::Event < Matterhorn::Endpoint
65
65
  begin
66
66
  dc_field_arr = []
67
67
  dublin_core.each_dcterms_element do |name, content|
68
- if changeable_element?(name) && !content.blank?
68
+ if changeable_element?(name) && !content.empty?
69
69
  dc_field_arr << {
70
70
  'id' => name,
71
71
  'value' => content
@@ -119,7 +119,7 @@ class Matterhorn::Endpoint::Series < Matterhorn::Endpoint
119
119
  series_id = dublin_core.dcterms_identifier
120
120
  dc_to_update = read(dublin_core.dcterms_identifier)
121
121
  if dc_to_update.nil?
122
- raise(Matterhorn::Matterhorn::Error.new("Series[#{series_id}] was not found on Matterhorn"))
122
+ raise(Matterhorn::Error.new("Series[#{series_id}] was not found on Matterhorn"))
123
123
  end
124
124
  dc = create(dublin_core, acl)
125
125
  if response_code == 204
@@ -16,7 +16,7 @@ module Matterhorn
16
16
 
17
17
  def initialize(protocol, domain, org_domain, user, password, auth_mode,
18
18
  http_timeout = nil, ssl_dont_verify_cert = false, multi_tenant = true)
19
- @sub_domain = org_domain.split('.').first
19
+ @sub_domain = org_domain.to_s.split('.').first.to_s.strip
20
20
  @uri = URI.parse("#{protocol}://#{domain}")
21
21
  @uri.user = user
22
22
  @uri.password = password
@@ -81,7 +81,7 @@ module Matterhorn
81
81
 
82
82
 
83
83
  def assemble_url(url)
84
- if @multi_tenant && !@sub_domain.blank?
84
+ if @multi_tenant && !@sub_domain.empty?
85
85
  @uri.request_uri + "#{@sub_domain}/" + url
86
86
  else
87
87
  @uri.request_uri + url
@@ -5,7 +5,7 @@ module MatterhornWhymper
5
5
 
6
6
  # -------------------------------------------------------------------------- const definitions ---
7
7
 
8
- VERSION = "1.0.3"
8
+ VERSION = "1.0.4"
9
9
 
10
10
 
11
11
  end # -------------------------------------------------------------------- end MatterhornWhymper ---
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0"?>
2
+ <dublincore xmlns="http://www.opencastproject.org/xsd/1.0/dublincore/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oc="http://www.opencastproject.org/matterhorn/" xsi:schemaLocation="http://www.opencastproject.org http://www.opencastproject.org/schema.xsd">
3
+ <dcterms:title>Space is Awesome</dcterms:title>
4
+ <dcterms:description>The Great Space Race was hotly anticipated as the follow-up to Legend's popular and influential graphic adventure Valhalla. Pre-release publicity boasted that the game contained "technical effects never before seen in home computer software", with "true solid 3D graphics".[2] The game was actually coded largely in BASIC.[3]&#xD;
5
+ &#xD;
6
+ After its release, the game was described by Sinclair User as "one of the most vacuous products we have seen."[4] The graphics also did not impress, as Big K magazine panned "Graphics are great - by 1982 standards. In 1985 they look amateurish and unprofessional".[5] Despite the heavy criticism at launch, the game has gained a cult status through the use of emulators in recent years.</dcterms:description>
7
+ <dcterms:created>2015-05-11</dcterms:created>
8
+ <dcterms:source>SWITCHtube_Channel_1</dcterms:source>
9
+ <dcterms:contributor>Ste&#x301;phane Kielholz</dcterms:contributor>
10
+ <dcterms:subject>Arts &amp; Culture</dcterms:subject>
11
+ <dcterms:publisher>Universit&#xE4;t Bern</dcterms:publisher>
12
+ </dublincore>
@@ -1,8 +1,29 @@
1
1
  test:
2
- protocol: http
3
- domain: admin.example.com
4
- user: inser_system_user_name_here
5
- password: insert_system_user_password_here
6
- auth_mode: digest
7
- ssl_dont_verify_cert: false
8
- multi_tenant: false
2
+ p1:
3
+ endpoint:
4
+ protocol: https
5
+ domain: cast-ng-test.switch.ch
6
+ user: <user>
7
+ password: <password>
8
+ auth_mode: digest
9
+ ssl_dont_verify_cert: true
10
+ multi_tenant: false
11
+ p2:
12
+ endpoint:
13
+ protocol: https
14
+ domain: cast-ng-test.switch.ch
15
+ user: <user>
16
+ password: <password>
17
+ auth_mode: digest
18
+ ssl_dont_verify_cert: true
19
+ multi_tenant: true
20
+ api:
21
+ protocol: https
22
+ domain: cast-ng-test.switch.ch
23
+ user: <user>
24
+ password: <password>
25
+ auth_mode: basic
26
+ ssl_dont_verify_cert: true
27
+ multi_tenant: true
28
+ default: p2
29
+
data/spec/spec_helper.rb CHANGED
@@ -10,10 +10,22 @@ require 'fileutils'
10
10
 
11
11
  Dir.glob(File.expand_path('../support/**/*.rb', __FILE__)).each { |lib| require lib }
12
12
 
13
- test_configuration = YAML::load_file(File.expand_path('../matterhorn.yml', __FILE__))
14
- MatterhornWhymper.configure do |config|
15
- config.add_matterhorn_instance
16
- config.add_endpoint(test_configuration['test'])
13
+
14
+ MatterhornWhymper.configure do |mhw_config|
15
+ mhw_yml = YAML::load_file(File.expand_path('../matterhorn.yml', __FILE__))['test']
16
+ mhw_yml.each do |mh_name, mh_config|
17
+ if mh_name != 'default'
18
+ mhw_config.add_matterhorn_instance(mh_name)
19
+ if !mh_config['endpoint'].nil?
20
+ mhw_config.add_endpoint(mh_config['endpoint'], mh_name)
21
+ end
22
+ if !mh_config['api'].nil?
23
+ mhw_config.add_api(mh_config['api'], mh_name)
24
+ end
25
+ else
26
+ mhw_config.set_default_matterhorn_instance(mh_config)
27
+ end
28
+ end
17
29
  end
18
30
 
19
31
  logfile_path = File.expand_path('../../log/test.log', __FILE__)
@@ -3,11 +3,16 @@ require 'tempfile'
3
3
 
4
4
  describe Matterhorn::Endpoint::Ingest do
5
5
  before do
6
- @ingest = Matterhorn::Endpoint::Ingest.new
6
+ @ingest = Matterhorn::Endpoint::create(:ingest)
7
7
  stub_request(:head, %r{}).to_return(status: 200, body: '', headers: { 'WWW-Authenticate' => 'Basic realm="Matterhorn"' })
8
8
  stub_request(:get, %r{/ingest/createMediaPackage}).to_return(status: 200, body: file_fixture_contents('empty_media_package.xml'))
9
9
  end
10
10
 
11
+ after do
12
+ @ingest.close
13
+ end
14
+
15
+
11
16
  it "adds a local file to its media package with addTrack" do
12
17
  stub_request(:post, %r{/ingest/addTrack}).to_return(status: 200, body: file_fixture_contents('media_package_with_one_track.xml'))
13
18
  @ingest.createMediaPackage
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+ require 'tempfile'
3
+
4
+ describe Matterhorn::Endpoint::Series do
5
+ before do
6
+ @series = Matterhorn::Endpoint::create(:series, 'enil.ch')
7
+ stub_request(:head, %r{}).to_return(status: 200, body: '', headers: { 'WWW-Authenticate' => 'Basic realm="Matterhorn"' })
8
+ end
9
+
10
+ after do
11
+ @series.close
12
+ end
13
+
14
+
15
+ it "reads a Dublin Core document for a series" do
16
+ series_id = SecureRandom.uuid
17
+ stub_request(:get, %r(/enil/series/#{series_id}.xml)).to_return(status: 200, body: file_fixture_contents('series_dublin_core.xml'))
18
+
19
+ dublin_core = @series.read(series_id)
20
+ expect(dublin_core.dcterms_title).to eq('Space is Awesome')
21
+ end
22
+
23
+ it "returns an error when reading a Dublin Core document for a non-existent series" do
24
+ series_id = SecureRandom.uuid
25
+ stub_request(:get, %r(/enil/series/#{series_id}.xml)).to_return(status: 404, body: '')
26
+
27
+ dublin_core = @series.read(series_id)
28
+ expect(dublin_core).to be_nil
29
+ end
30
+
31
+ describe "initialization" do
32
+ it "creates an endpoint instance with open" do
33
+ Matterhorn::Endpoint.open(:series) do |client|
34
+ expect(client).to be_kind_of(Matterhorn::Endpoint::Series)
35
+ end
36
+ end
37
+ end
38
+ 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: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Fritschi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-04 00:00:00.000000000 Z
11
+ date: 2015-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multipart-post
@@ -154,6 +154,7 @@ files:
154
154
  - matterhorn_whymper.gemspec
155
155
  - spec/files/empty_media_package.xml
156
156
  - spec/files/media_package_with_one_track.xml
157
+ - spec/files/series_dublin_core.xml
157
158
  - spec/matterhorn.yml.sample
158
159
  - spec/remote/matterhorn/endpoint/ingest_spec.rb
159
160
  - spec/spec_helper.rb
@@ -161,6 +162,7 @@ files:
161
162
  - spec/support/remote_helpers.rb
162
163
  - spec/unit/Matterhorn_whymper_spec.rb
163
164
  - spec/unit/matterhorn/endpoint/ingest_spec.rb
165
+ - spec/unit/matterhorn/endpoint/series_spec.rb
164
166
  - spec/unit/matterhorn/endpoints_spec.rb
165
167
  homepage: https://github.com/switch-ch/matterhorn_whymper
166
168
  licenses:
@@ -189,6 +191,7 @@ summary: Ruby wrapper around the Matterhorn Endpoint API
189
191
  test_files:
190
192
  - spec/files/empty_media_package.xml
191
193
  - spec/files/media_package_with_one_track.xml
194
+ - spec/files/series_dublin_core.xml
192
195
  - spec/matterhorn.yml.sample
193
196
  - spec/remote/matterhorn/endpoint/ingest_spec.rb
194
197
  - spec/spec_helper.rb
@@ -196,4 +199,5 @@ test_files:
196
199
  - spec/support/remote_helpers.rb
197
200
  - spec/unit/Matterhorn_whymper_spec.rb
198
201
  - spec/unit/matterhorn/endpoint/ingest_spec.rb
202
+ - spec/unit/matterhorn/endpoint/series_spec.rb
199
203
  - spec/unit/matterhorn/endpoints_spec.rb