pb_core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pb_core.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 The Public Radio Exchange, www.prx.org
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # PBCore
2
+
3
+ Gem for working with PBCore 2.0 XML data:
4
+ * http://pbcore.org/
5
+ * http://www.pbcoreresources.org/
6
+
7
+ Uses sax-machine (which relies on nokogiri) for parsing:
8
+ * https://github.com/pauldix/sax-machine
9
+ * http://nokogiri.org/
10
+
11
+ Created for Pop Up Archive project:
12
+ * http://popuparchive.org/
13
+ * https://github.com/PRX/pop-up-archive
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ gem 'pb_core'
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install pb_core
28
+
29
+ ## Usage
30
+
31
+ require 'pb_core'
32
+ f = File.open(some_file)
33
+ doc = PBCore::V2::DescriptionDocument.parse(f)
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/pb_core ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pb_core'
4
+
5
+ # TODO: create command line parser for xml files
@@ -0,0 +1,204 @@
1
+ require 'sax-machine'
2
+
3
+ module PBCore
4
+ module V2
5
+
6
+ module SourceVersionGroup
7
+ def SourceVersionGroup.included(mod)
8
+ mod.attribute :source
9
+ mod.attribute :ref
10
+ mod.attribute :version
11
+ mod.attribute :annotation
12
+ end
13
+ end
14
+
15
+ module StartEndTimeGroup
16
+ def StartEndTimeGroup.included(mod)
17
+ mod.attribute :startTime, :as => :start_time
18
+ mod.attribute :endTime, :as => :end_time
19
+ mod.attribute :timeAnnotation, :as => :time_annotation
20
+ end
21
+ end
22
+
23
+ module CollectionGroup
24
+ def CollectionGroup.included(mod)
25
+ mod.attribute :collectionTitle, :as => :collection_title
26
+ mod.attribute :collectionDescription, :as => :collection_description
27
+ mod.attribute :collectionSource, :as => :collection_source
28
+ mod.attribute :collectionRef, :as => :collection_ref
29
+ mod.attribute :collectionDate, :as => :collection_date
30
+ end
31
+ end
32
+
33
+ class Base
34
+ include SAXMachine
35
+
36
+ def self.source_version_group; include PBCore::V2::SourceVersionGroup; end
37
+
38
+ def self.start_end_time_group; include PBCore::V2::StartEndTimeGroup; end
39
+
40
+ def self.collection_group; include PBCore::V2::CollectionGroup; end
41
+
42
+ def self.instantiation_group; include PBCore::V2::InstantiationGroup; end
43
+ end
44
+
45
+ class Identifier < PBCore::V2::Base
46
+ source_version_group
47
+ end
48
+
49
+ class Type < PBCore::V2::Base
50
+ source_version_group
51
+ end
52
+
53
+ class Title < PBCore::V2::Base
54
+ source_version_group
55
+ start_end_time_group
56
+
57
+ attribute :titleType, :as => :type
58
+ end
59
+
60
+ class Description < PBCore::V2::Base
61
+ start_end_time_group
62
+
63
+ attribute :descriptionType, :as => :type
64
+ attribute :descriptionTypeSource, :as => :type_source
65
+ attribute :descriptionTypeRef, :as => :type_ref
66
+ attribute :descriptionTypeVersion, :as => :type_version
67
+ attribute :descriptionTypeAnnotation, :as => :type_annotation
68
+
69
+ attribute :segmentType, :as => :segment_type
70
+ attribute :segmentTypeSource, :as => :segment_type_source
71
+ attribute :segmentTypeRef, :as => :segment_type_ref
72
+ attribute :segmentTypeVersion, :as => :segment_type_version
73
+ attribute :segmentTypeAnnotation, :as => :segment_type_annotation
74
+
75
+ attribute :annotation
76
+ end
77
+
78
+ class DateType < PBCore::V2::Base
79
+ attribute :dateType, :as => :type
80
+ end
81
+
82
+ class Subject < PBCore::V2::Base
83
+ source_version_group
84
+ start_end_time_group
85
+
86
+ attribute :subjectType, :as => :type
87
+ end
88
+
89
+ class Genre < PBCore::V2::Base
90
+ source_version_group
91
+ start_end_time_group
92
+ end
93
+
94
+ class Relation < PBCore::V2::Base
95
+ element 'relationType', :as => :type, :class => PBCore::V2::Type
96
+ element 'relationIdentifier', :as => :identifier, :class => PBCore::V2::Identifier
97
+ end
98
+
99
+ class CoverageInfo < PBCore::V2::Base
100
+ source_version_group
101
+ start_end_time_group
102
+ end
103
+
104
+ class Coverage < PBCore::V2::Base
105
+ element 'coverage', :as => :info, :class => PBCore::V2::CoverageInfo
106
+ element 'coverageType', :as=> :type
107
+ end
108
+
109
+ class Affiliate < PBCore::V2::Base
110
+ start_end_time_group
111
+
112
+ attribute :affiliation
113
+ attribute :ref
114
+ attribute :annotation
115
+ end
116
+
117
+ class Creator < PBCore::V2::Base
118
+ element 'creator', :as => :name, :class => PBCore::V2::Affiliate
119
+ element 'creatorRole', :as => :role, :class => PBCore::V2::Type
120
+ end
121
+
122
+ class ContributorType < PBCore::V2::Base
123
+ source_version_group
124
+
125
+ attribute :portrayal
126
+ end
127
+
128
+ class Contributor < PBCore::V2::Base
129
+ element 'contributer', :as => :name, :class => PBCore::V2::Affiliate
130
+ element 'contributerRole', :as => :role, :class => PBCore::V2::ContributorType
131
+ end
132
+
133
+ class Publisher < PBCore::V2::Base
134
+ element 'publisher', :as => :name, :class => PBCore::V2::Affiliate
135
+ element 'publisherRole', :as => :role, :class => PBCore::V2::Type
136
+ end
137
+
138
+ class Annotated < PBCore::V2::Base
139
+ attribute :annotation
140
+ end
141
+
142
+ class Rights < PBCore::V2::Base
143
+ start_end_time_group
144
+
145
+ element 'rightsSummary', :as => :summary, :class => PBCore::V2::Type
146
+ element 'rightsLink', :as => :link, :class => PBCore::V2::Annotated
147
+ element 'rightsEmbedded', :as => :embedded, :class => PBCore::V2::Annotated
148
+ end
149
+
150
+ class Measurement < PBCore::V2::Base
151
+ attribute :annotation
152
+ attribute :unitsOfMeasure, :as => :units
153
+ end
154
+
155
+ class Standard < PBCore::V2::Base
156
+ source_version_group
157
+
158
+ attribute :profile
159
+ end
160
+
161
+ class Annotation < PBCore::V2::Base
162
+ attribute :annotationType, :as => :annotation_type
163
+ attribute :ref
164
+ end
165
+
166
+ class ExtensionWrap < PBCore::V2::Base
167
+ attribute :annotation
168
+
169
+ element 'extensionElement', :as => :element
170
+ element 'extensionValue', :as => :value
171
+ element 'extensionAuthorityUsed', :as => :authority_used
172
+ end
173
+
174
+ class Extension < PBCore::V2::Base
175
+ element 'extensionWrap', :as => :wrap, :class => PBCore::V2::ExtensionWrap
176
+ element 'extensionEmbedded', :as => :embedded, :class => PBCore::V2::Annotated
177
+ end
178
+
179
+ class EssenceTrack < PBCore::V2::Base
180
+ element 'essenceTrackType', :as => :type
181
+ elements 'essenceTrackIdentifier', :as => :identifiers, :class => PBCore::V2::Identifier
182
+ element 'essenceTrackStandard', :as => :standard, :class => PBCore::V2::Type
183
+ element 'essenceTrackEncoding', :as => :encoding, :class => PBCore::V2::Type
184
+ element 'essenceTrackDataRate', :as => :data_rate, :class => PBCore::V2::Measurement
185
+ element 'essenceTrackFrameRate', :as => :frame_rate, :class => PBCore::V2::Measurement
186
+ element 'essenceTrackPlaybackSpeed', :as => :playback_speed, :class => PBCore::V2::Measurement
187
+ element 'essenceTrackSamplingRate', :as => :sampling_rate, :class => PBCore::V2::Measurement
188
+ element 'essenceTrackBitDepth', :as => :bit_depth
189
+ element 'essenceTrackFrameSize', :as => :frame_size, :class => PBCore::V2::Type
190
+ element 'essenceTrackAspectRatio', :as => :aspect_ration, :class => PBCore::V2::Type
191
+ element 'essenceTrackTimeStart', :as => :time_start
192
+ element 'essenceTrackDuration', :as => :duration
193
+ element 'essenceTrackLanguage', :as => :language, :class => PBCore::V2::Type
194
+ element 'essenceTrackAnnotation', :as => :annotation, :class => PBCore::V2::Annotation
195
+ elements 'essenceTrackExtension', :as => :extensions, :class =>PBCore::V2::Extension
196
+ end
197
+
198
+ class InstantiationRelation < PBCore::V2::Base
199
+ element 'instantiationRelationType', :as => :type, :class => PBCore::V2::Type
200
+ element 'instantiationRelationIdentifier', :as => :identifier, :class => PBCore::V2::Identifier
201
+ end
202
+
203
+ end
204
+ end
@@ -0,0 +1,13 @@
1
+ require 'pb_core/v2/base'
2
+ require 'pb_core/v2/description_document'
3
+
4
+ module PBCore
5
+ module V2
6
+
7
+ class Collection < PBCore::V2::Base
8
+ collection_group
9
+ elements 'pbcoreDescriptionDocument', :as => :description_documents, :class => PBCore::V2::DescriptionDocument
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,45 @@
1
+ require 'pb_core/v2/base'
2
+ require 'pb_core/v2/instantiation_document'
3
+
4
+ module PBCore
5
+ module V2
6
+
7
+ class DocumentType < PBCore::V2::Base; end
8
+
9
+ # pbcoreDescriptionDocument
10
+ class Part < PBCore::V2::DocumentType
11
+ start_end_time_group
12
+ end
13
+
14
+ class DocumentType < PBCore::V2::Base
15
+ collection_group
16
+
17
+ elements 'pbcoreAssetType', :as => :asset_types, :class => PBCore::V2::Type
18
+ elements 'pbcoreAssetDate', :as => :asset_dates, :class => PBCore::V2::DateType
19
+ elements 'pbcoreIdentifier', :as => :identifiers, :class => PBCore::V2::Identifier
20
+ elements 'pbcoreTitle', :as => :titles, :class => PBCore::V2::Title
21
+ elements 'pbcoreDescription', :as=> :descriptions, :class => PBCore::V2::Description
22
+ elements 'pbcoreSubject', :as=> :subjects, :class => PBCore::V2::Subject
23
+ elements 'pbcoreCoverage', :as => :coverages, :class => PBCore::V2::Coverage
24
+ elements 'pbcoreAudienceLevel', :as => :audience_levels, :class => PBCore::V2::Type
25
+ elements 'pbcoreAudienceRating', :as => :audience_ratings, :class => PBCore::V2::Type
26
+ elements 'pbcoreCreator', :as => :creators, :class => PBCore::V2::Creator
27
+ elements 'pbcoreContributor', :as => :contributors, :class => PBCore::V2::Contributor
28
+ elements 'pbcorePublisher', :as => :publishers, :class => PBCore::V2::Publisher
29
+ elements 'pbcoreRightsSummary', :as => :rights, :class => PBCore::V2::Rights
30
+ elements 'pbcoreInstantiation', :as => :instantiations, :class => PBCore::V2::Instantiation
31
+ elements 'pbcoreAnnotation', :as => :annotations, :class => PBCore::V2::Annotation
32
+ elements 'pbcorePart', :as => :parts, :class => PBCore::V2::Part
33
+ end
34
+
35
+ # pbcoreDescriptionDocument
36
+ class DescriptionDocument < PBCore::V2::DocumentType
37
+ end
38
+
39
+ class Collection < PBCore::V2::Base
40
+ collection_group
41
+ elements 'pbcoreDescriptionDocument', :as => :description_documents, :class => PBCore::V2::DescriptionDocument
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,48 @@
1
+ require 'pb_core/v2/base'
2
+
3
+ module PBCore
4
+ module V2
5
+
6
+ class InstantiationType < PBCore::V2::Base
7
+ end
8
+
9
+ class InstantiationPart < PBCore::V2::InstantiationType
10
+ end
11
+
12
+ class Instantiation < PBCore::V2::InstantiationType
13
+ end
14
+
15
+ class InstantiationDocument < PBCore::V2::InstantiationType
16
+ end
17
+
18
+ class InstantiationType < PBCore::V2::Base
19
+ start_end_time_group
20
+
21
+ elements 'instantiationIdentifier', :as => :identifiers, :class => PBCore::V2::Identifier
22
+ elements 'instantiationDate', :as => :dates, :class => PBCore::V2::DateType
23
+ elements 'instantiationDimensions', :as => :dimensions, :class => PBCore::V2::Measurement
24
+ element 'instantiationPhysical', :as => :physical, :class => PBCore::V2::Type
25
+ element 'instantiationDigital', :as => :digital, :class => PBCore::V2::Type
26
+ element 'instantiationStandard', :as => :standard, :class => PBCore::V2::Standard
27
+ element 'instantiationLocation', :as => :location
28
+ element 'instantiationMediaType', :as => :media_type, :class => PBCore::V2::Type
29
+ elements 'instantiationGenerations', :as => :generations, :class => PBCore::V2::Type
30
+ element 'instantiationFileSize', :as => :file_size, :class=> PBCore::V2::Measurement
31
+ element 'instantiationTimeStart', :as => :time_start
32
+ element 'instantiationDuration', :as => :duration
33
+ element 'instantiationDataRate', :as => :data_rate, :class=> PBCore::V2::Measurement
34
+ element 'instantiationColors', :as => :colors, :class=> PBCore::V2::Type
35
+ element 'instantiationTracks', :as => :tracks
36
+ element 'instantiationChannelConfiguration', :as => :channel_configuration
37
+ element 'instantiationLanguage', :as => :language, :class=> PBCore::V2::Type
38
+ element 'instantiationAlternativeModes', :as => :alternative_modes
39
+ elements 'instantiationEssenceTrack', :as => :essence_tracks, :class => PBCore::V2::EssenceTrack
40
+ elements 'instantiationRelation', :as => :relations, :class => PBCore::V2::InstantiationRelation
41
+ elements 'instantiationRights', :as => :rights, :class => PBCore::V2::Rights
42
+ elements 'instantiationAnnotation', :as => :annotations, :class => PBCore::V2::Annotation
43
+ elements 'instantiationPart', :as => :parts, :class => PBCore::V2::InstantiationPart
44
+ elements 'instantiationExtension', :as => :extensions, :class => PBCore::V2::Extension
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module PBCore
2
+ VERSION = "0.0.1"
3
+ end
data/lib/pb_core.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'sax-machine'
2
+
3
+ require "pb_core/version"
4
+ require 'pb_core/v2/base'
5
+ require 'pb_core/v2/instantiation_document'
6
+ require 'pb_core/v2/collection'
7
+
8
+ module PBCore
9
+ end
data/pb_core.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pb_core/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "pb_core"
8
+ gem.version = PBCore::VERSION
9
+ gem.authors = ["Andrew Kuklewicz"]
10
+ gem.email = ["andrew@prx.org"]
11
+ gem.description = %q{Gem for working with PBCore 2.0 XML data}
12
+ gem.summary = %q{Gem for working with PBCore 2.0 XML data}
13
+ gem.homepage = "https://github.com/PRX/pb_core"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'sax-machine'
21
+
22
+ gem.add_development_dependency 'rake'
23
+
24
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pb_core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Kuklewicz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sax-machine
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Gem for working with PBCore 2.0 XML data
47
+ email:
48
+ - andrew@prx.org
49
+ executables:
50
+ - pb_core
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - bin/pb_core
60
+ - lib/pb_core.rb
61
+ - lib/pb_core/v2/base.rb
62
+ - lib/pb_core/v2/collection.rb
63
+ - lib/pb_core/v2/description_document.rb
64
+ - lib/pb_core/v2/instantiation_document.rb
65
+ - lib/pb_core/version.rb
66
+ - pb_core.gemspec
67
+ homepage: https://github.com/PRX/pb_core
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ segments:
80
+ - 0
81
+ hash: -630219332878205399
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ segments:
89
+ - 0
90
+ hash: -630219332878205399
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 1.8.23
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: Gem for working with PBCore 2.0 XML data
97
+ test_files: []