pbcore 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pbcore/version.rb +1 -1
  3. data/pbcore.gemspec +10 -2
  4. data/spec/factories/annotation.rb +9 -0
  5. data/spec/factories/asset_date.rb +23 -0
  6. data/spec/factories/asset_type.rb +7 -0
  7. data/spec/factories/audience_level.rb +7 -0
  8. data/spec/factories/audience_rating.rb +7 -0
  9. data/spec/factories/contributor.rb +9 -0
  10. data/spec/factories/contributor/contributor.rb +6 -0
  11. data/spec/factories/contributor/role.rb +6 -0
  12. data/spec/factories/coverage.rb +22 -0
  13. data/spec/factories/coverage/coverage.rb +22 -0
  14. data/spec/factories/coverage/type.rb +8 -0
  15. data/spec/factories/creator.rb +8 -0
  16. data/spec/factories/creator/creator.rb +12 -0
  17. data/spec/factories/creator/role.rb +8 -0
  18. data/spec/factories/description.rb +11 -0
  19. data/spec/factories/description_document.rb +28 -0
  20. data/spec/factories/extension.rb +11 -0
  21. data/spec/factories/extension/embedded.rb +7 -0
  22. data/spec/factories/extension/wrap.rb +11 -0
  23. data/spec/factories/extension/wrap/authority_used.rb +7 -0
  24. data/spec/factories/extension/wrap/element.rb +7 -0
  25. data/spec/factories/extension/wrap/value.rb +7 -0
  26. data/spec/factories/genre.rb +8 -0
  27. data/spec/factories/identifier.rb +10 -0
  28. data/spec/factories/instantiation.rb +34 -0
  29. data/spec/factories/instantiation/alternative_modes.rb +11 -0
  30. data/spec/factories/instantiation/annotation.rb +12 -0
  31. data/spec/factories/instantiation/channel_configuration.rb +11 -0
  32. data/spec/factories/instantiation/colors.rb +11 -0
  33. data/spec/factories/instantiation/data_rate.rb +12 -0
  34. data/spec/factories/instantiation/date.rb +12 -0
  35. data/spec/factories/instantiation/digital.rb +11 -0
  36. data/spec/factories/instantiation/dimensions.rb +12 -0
  37. data/spec/factories/instantiation/duration.rb +11 -0
  38. data/spec/factories/instantiation/essence_track.rb +29 -0
  39. data/spec/factories/instantiation/essence_track/annotation.rb +12 -0
  40. data/spec/factories/instantiation/essence_track/aspect_ratio.rb +16 -0
  41. data/spec/factories/instantiation/essence_track/bit_depth.rb +12 -0
  42. data/spec/factories/instantiation/essence_track/data_rate.rb +12 -0
  43. data/spec/factories/instantiation/essence_track/duration.rb +11 -0
  44. data/spec/factories/instantiation/essence_track/encoding.rb +11 -0
  45. data/spec/factories/instantiation/essence_track/frame_rate.rb +12 -0
  46. data/spec/factories/instantiation/essence_track/frame_size.rb +12 -0
  47. data/spec/factories/instantiation/essence_track/identifier.rb +11 -0
  48. data/spec/factories/instantiation/essence_track/language.rb +9 -0
  49. data/spec/factories/instantiation/essence_track/playback_speed.rb +12 -0
  50. data/spec/factories/instantiation/essence_track/sampling_rate.rb +12 -0
  51. data/spec/factories/instantiation/essence_track/standard.rb +11 -0
  52. data/spec/factories/instantiation/essence_track/time_start.rb +11 -0
  53. data/spec/factories/instantiation/essence_track/type.rb +11 -0
  54. data/spec/factories/instantiation/extension.rb +16 -0
  55. data/spec/factories/instantiation/file_size.rb +12 -0
  56. data/spec/factories/instantiation/generations.rb +11 -0
  57. data/spec/factories/instantiation/identifier.rb +17 -0
  58. data/spec/factories/instantiation/language.rb +13 -0
  59. data/spec/factories/instantiation/location.rb +11 -0
  60. data/spec/factories/instantiation/media_type.rb +11 -0
  61. data/spec/factories/instantiation/physical.rb +11 -0
  62. data/spec/factories/instantiation/relation.rb +12 -0
  63. data/spec/factories/instantiation/relation/identifier.rb +10 -0
  64. data/spec/factories/instantiation/relation/type.rb +9 -0
  65. data/spec/factories/instantiation/rights.rb +20 -0
  66. data/spec/factories/instantiation/rights/link.rb +7 -0
  67. data/spec/factories/instantiation/rights/summary.rb +7 -0
  68. data/spec/factories/instantiation/standard.rb +12 -0
  69. data/spec/factories/instantiation/time_start.rb +11 -0
  70. data/spec/factories/instantiation/tracks.rb +11 -0
  71. data/spec/factories/instantiation_document.rb +44 -0
  72. data/spec/factories/pbcore_content_element.rb +10 -0
  73. data/spec/factories/pbcore_element.rb +8 -0
  74. data/spec/factories/publisher.rb +10 -0
  75. data/spec/factories/publisher/publisher.rb +12 -0
  76. data/spec/factories/publisher/role.rb +8 -0
  77. data/spec/factories/relation.rb +8 -0
  78. data/spec/factories/relation/identifier.rb +10 -0
  79. data/spec/factories/relation/type.rb +9 -0
  80. data/spec/factories/rights_summary.rb +25 -0
  81. data/spec/factories/rights_summary/link.rb +11 -0
  82. data/spec/factories/rights_summary/summary.rb +11 -0
  83. data/spec/factories/subject.rb +11 -0
  84. data/spec/factories/title.rb +12 -0
  85. metadata +83 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b73a92c3b5ee2c05b18c519077beb2952ac546595eb6f12304c0e276f7af48b
4
- data.tar.gz: 7648662adcfbfd4b2e6f82e896fa49d51898353e670106264eb02e43a6a19769
3
+ metadata.gz: 1d5d477ef608efd8f417e4c31d6619485aa287e3a208a0cebfbe13a4e1e30b39
4
+ data.tar.gz: fc5dd5b45fd58f6207f133b65e1e413c076dc29f2a4c099f6bf7553e315344fa
5
5
  SHA512:
6
- metadata.gz: e5f41721756eef3d067c33725f115f7552d0ddc4ded015946afc3609eeda97228931c26c8a03892bd2fbddf54a2931dbbcc46e108a8947186ce631c38f24c35d
7
- data.tar.gz: 1c0831980ab0de12d8528ef43fef87c5718ddc291fcb75e68e472fd98a808a8b9c3571f7ef6a501dc85819f5ae5cc702c254e1ab564543aa774f86a4a17fcb45
6
+ metadata.gz: 3bfb1b44e3a55d15969e14ebbfa20ccc5a4fb281ed7993b70610c84ca063a937659f515a294f5b920e071826087e117ba499e8a4c7c45163df3fc11fb24ba486
7
+ data.tar.gz: a4b577fb1e5b6a023fa515844980f960a1414aec25af4d8898b74e422fe14261071d41cfe3be701d861d47832efbe57b1174d77fed325e56ce2d9b2c06ed8bbf
@@ -1,3 +1,3 @@
1
1
  module PBCore
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/pbcore.gemspec CHANGED
@@ -17,10 +17,18 @@ Gem::Specification.new do |spec|
17
17
  spec.license = "MIT"
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ # Excludes: Tests
21
+ # Includes:
22
+ # * All other files committed to git (using `git ls-files -z`).
23
+ # * Factories and their dependencies.
21
24
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ keep = [ 'spec/support/date_time_helpers' ]
27
+ keep += Dir.glob('spec/factories/**/*')
28
+ f.match(%r{^(spec)/}) unless keep.any?(f)
29
+ end
23
30
  end
31
+
24
32
  spec.bindir = "exe"
25
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
34
  spec.require_paths = ["lib"]
@@ -0,0 +1,9 @@
1
+ require 'pbcore'
2
+ require 'faker'
3
+
4
+ FactoryBot.define do
5
+ factory :pbcore_annotation, class: PBCore::Annotation, parent: :pbcore_content_element do
6
+ value { Faker::Quote.famous_last_words }
7
+ type { Faker::Lorem.word }
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_asset_date, class: PBCore::AssetDate, parent: :pbcore_content_element do
5
+ value { DateTimeHelpers.rand_date_time }
6
+ type { Faker::Lorem.word }
7
+
8
+ transient do
9
+ # `format` should be a valid format string accepted by DateTime#strftime.
10
+ # Pass a nil or false to skip converting the value from a DateTime object
11
+ # to ta string.
12
+ format { nil }
13
+ end
14
+
15
+ after :build do |pbcore_asset_date, evaluator|
16
+ # If a format is specified, use DateTime to parse the given date and
17
+ # re-format it.
18
+ if evaluator.format
19
+ pbcore_asset_date.value = DateTime.parse(pbcore_asset_date.value).strftime(evaluator.format)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_asset_type, class: PBCore::AssetType, parent: :pbcore_content_element do
5
+ value { PBCore::Vocab.asset_types.sample }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_audience_level, class: PBCore::AudienceLevel, parent: :pbcore_content_element do
5
+ value { ['G', 'PG', 'R', 'PG-13', 'NC-17'].sample }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_audience_rating, class: PBCore::AudienceRating, parent: :pbcore_content_element do
5
+ value { ['General', 'Empty-nester', 'K-7', 'Pre-teen'].sample }
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'pbcore'
2
+ require 'faker'
3
+
4
+ FactoryBot.define do
5
+ factory :pbcore_contributor, class: PBCore::Contributor, parent: :pbcore_element do
6
+ contributor { build(:pbcore_contributor_contributor) }
7
+ role { build(:pbcore_contributor_role ) }
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :pbcore_contributor_contributor, class: PBCore::Contributor::Contributor, parent: :pbcore_content_element do
3
+ affiliation { Faker::Company.name }
4
+ value { Faker::FunnyName.two_word_name }
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :pbcore_contributor_role, class: PBCore::Contributor::Role, parent: :pbcore_content_element do
3
+ value { Faker::Job.title }
4
+ portrayal { Faker::Movies::StarWars.character }
5
+ end
6
+ end
@@ -0,0 +1,22 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_coverage, class: PBCore::Coverage, parent: :pbcore_element do
5
+
6
+
7
+ coverage { build(:pbcore_coverage_coverage) }
8
+ type { build(:pbcore_coverage_type) }
9
+
10
+ trait :spatial do
11
+ coverage { build :pbcore_coverage_coverage, :spatial }
12
+ type { build :pbcore_coverage_type, :spatial }
13
+ end
14
+
15
+ trait :temporal do
16
+ coverage { build :pbcore_coverage_coverage, :temporal }
17
+ type { build :pbcre_coverage_type, :temporal }
18
+ end
19
+
20
+
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_coverage_coverage, class: PBCore::Coverage::Coverage, parent: :pbcore_content_element do
5
+
6
+ # TODO: Use controlled vocabularies listed here:
7
+ # http://pbcore.org/elements/coverage
8
+ value { Faker::Lorem.words.join(' ') }
9
+
10
+ trait :spatial do
11
+ source { "latitude, longitude" }
12
+ value { "#{Faker::Address.latitude}, #{Faker::Address.longitude}" }
13
+ end
14
+
15
+ trait :temporal do
16
+ source { nil }
17
+ value { rand(1950..2018) }
18
+ end
19
+
20
+
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_coverage_type, class: PBCore::Coverage::Type, parent: :pbcore_element do
5
+ # TODO: Replace with rando term from controlled vocab once we get it.
6
+ value { ["Spatial", "Temporal"].sample }
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :pbcore_creator, class: PBCore::Creator, parent: :pbcore_element do
3
+
4
+ creator { build(:pbcore_creator_creator) }
5
+ role { build(:pbcore_creator_role) }
6
+
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :pbcore_creator_creator, class: PBCore::Creator::Creator, parent: :pbcore_content_element do
3
+
4
+ affiliation { Faker::Lorem.words.join(' ') }
5
+ affiliation_ref { Faker::Internet.url }
6
+ affiliation_source { Faker::Internet.url }
7
+ affiliation_version { FakeVersionHelper.fake_version }
8
+ affiliation_annotation { Faker::Company.bs }
9
+ value { Faker::Movies::Lebowski.character }
10
+
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :pbcore_creator_role, class: PBCore::Creator::Role, parent: :pbcore_content_element do
3
+
4
+
5
+ value { Faker::Job.title }
6
+
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_description, class: PBCore::Description, parent: :pbcore_content_element do
5
+
6
+ value { Faker::Lorem.paragraph }
7
+ type { Faker::Hacker.adjective }
8
+ type_ref { Faker::Internet.url }
9
+
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_description_document, class: PBCore::DescriptionDocument, parent: :pbcore_element do
5
+
6
+
7
+ identifiers { build_list(:pbcore_identifier, rand(1..3)) }
8
+ titles { build_list(:pbcore_title, rand(1..3)) }
9
+ descriptions { build_list(:pbcore_description, rand(1..3)) }
10
+ asset_dates { build_list(:pbcore_asset_date, rand(1..3)) }
11
+ asset_types { build_list(:pbcore_asset_type, rand(1..3)) }
12
+ subjects { build_list(:pbcore_subject, rand(1..3)) }
13
+ genres { build_list(:pbcore_genre, rand(1..3)) }
14
+ relations { build_list(:pbcore_relation, rand(1..3)) }
15
+ coverages { build_list(:pbcore_coverage, rand(1..3)) }
16
+ audience_levels { build_list(:pbcore_audience_level, rand(1..3)) }
17
+ audience_ratings { build_list(:pbcore_audience_rating, rand(1..3)) }
18
+ contributors { build_list(:pbcore_contributor, rand(1..3)) }
19
+ creators { build_list(:pbcore_creator, rand(1..3)) }
20
+ publishers { build_list(:pbcore_publisher, rand(1..3)) }
21
+ rights_summaries { build_list(:pbcore_rights_summary, rand(1..3)) }
22
+ annotations { build_list(:pbcore_annotation, rand(1..3)) }
23
+ extensions { build_list(:pbcore_extension, rand(1..3)) }
24
+ instantiations { build_list(:pbcore_instantiation, rand(1..3)) }
25
+
26
+
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_extension, class: PBCore::Extension, parent: :pbcore_element do
5
+ # NOTE: <extensionWrap> and <extensionEmbedded> are mutually exclusive child
6
+ # elements of <pbcoreExtension>. However, in the factory we always choose
7
+ # <extensionWrap> by default because we can't produce round-trippable XML
8
+ # for <extensionEmbedded> because of how SAXMachine parsing works.
9
+ wrap { build(:pbcore_extension_wrap) }
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_extension_embedded, class: PBCore::Extension::Embedded, parent: :pbcore_content_element do
5
+ value { "<foo />" }
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_extension_wrap, class: PBCore::Extension::Wrap, parent: :pbcore_element do
5
+
6
+ extension_element { build(:pbcore_extension_wrap_element) }
7
+ extension_value { build(:pbcore_extension_wrap_value) }
8
+ authority_used { build(:pbcore_extension_wrap_authority_used) }
9
+
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_extension_wrap_authority_used, class: PBCore::Extension::Wrap::AuthorityUsed, parent: :pbcore_element do
5
+ value { Faker::Job.title }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_extension_wrap_element, class: PBCore::Extension::Wrap::Element, parent: :pbcore_element do
5
+ value { Faker::Job.title }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_extension_wrap_value, class: PBCore::Extension::Wrap::Value, parent: :pbcore_element do
5
+ value { Faker::Job.title }
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_genre, class: PBCore::Genre, parent: :pbcore_content_element do
5
+
6
+ value { Faker::Book.genre }
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ require 'pbcore'
2
+ require 'securerandom'
3
+
4
+ FactoryBot.define do
5
+ factory :pbcore_identifier, class: PBCore::Identifier, parent: :pbcore_content_element do
6
+
7
+ value { SecureRandom.uuid }
8
+
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_instantiation, class: PBCore::Instantiation, parent: :pbcore_element do
5
+ identifiers { build_list(:pbcore_instantiation_identifier, rand(1..3)) }
6
+ dates { build_list(:pbcore_instantiation_date, rand(1..3)) }
7
+ dimensions { build_list(:pbcore_instantiation_dimensions, rand(1..3)) }
8
+ digital { build(:pbcore_instantiation_digital) }
9
+ physical { build(:pbcore_instantiation_physical) }
10
+ standard { build(:pbcore_instantiation_standard) }
11
+ location { build(:pbcore_instantiation_location) }
12
+ media_type { build(:pbcore_instantiation_media_type) }
13
+ generations { build_list(:pbcore_instantiation_generations, rand(1..3)) }
14
+ time_start { build(:pbcore_instantiation_time_start) }
15
+ duration { build(:pbcore_instantiation_duration) }
16
+ colors { build(:pbcore_instantiation_colors) }
17
+ rights { build_list(:pbcore_instantiation_rights, rand(1..3)) }
18
+ tracks { build(:pbcore_instantiation_tracks) }
19
+ channel_configuration { build(:pbcore_instantiation_channel_configuration) }
20
+ alternative_modes { build(:pbcore_instantiation_alternative_modes) }
21
+ annotations { build_list(:pbcore_instantiation_annotation, rand(1..3)) }
22
+ essence_tracks { build_list(:pbcore_instantiation_essence_track, rand(1..3)) }
23
+ extensions { build_list(:pbcore_instantiation_extension, rand(1..3)) }
24
+ languages { build_list(:pbcore_instantiation_language, rand(1..3)) }
25
+ relations { build_list(:pbcore_instantiation_relation, rand(1..3)) }
26
+ file_size { build(:pbcore_instantiation_file_size) }
27
+ data_rate { build(:pbcore_instantiation_data_rate) }
28
+
29
+ # time attributes
30
+ start_time { DateTimeHelpers.rand_date_time }
31
+ end_time { DateTimeHelpers.rand_date_time after: start_time }
32
+ time_annotation { Faker::Movies::StarWars.quote }
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_instantiation_alternative_modes, class: PBCore::Instantiation::AlternativeModes, parent: :pbcore_content_element do
5
+
6
+
7
+ value { Faker::Lorem.words.first }
8
+
9
+
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_instantiation_annotation, class: PBCore::Instantiation::Annotation, parent: :pbcore_content_element do
5
+
6
+
7
+ value { Faker::Movies::Ghostbusters.quote }
8
+ type { Faker::Hacker.noun }
9
+
10
+
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_instantiation_channel_configuration, class: PBCore::Instantiation::ChannelConfiguration, parent: :pbcore_content_element do
5
+
6
+
7
+ value { Faker::Music.genre }
8
+
9
+
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_instantiation_colors, class: PBCore::Instantiation::Colors, parent: :pbcore_content_element do
5
+
6
+
7
+ value { Faker::Color.color_name }
8
+
9
+
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'pbcore'
2
+
3
+ FactoryBot.define do
4
+ factory :pbcore_instantiation_data_rate, class: PBCore::Instantiation::DataRate, parent: :pbcore_content_element do
5
+
6
+
7
+ value { rand(100).to_s }
8
+ units_of_measure { %w(Kbps Mbps).sample }
9
+
10
+
11
+ end
12
+ end