poms 1.2.2 → 2.0.0.a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +17 -0
  3. data/.rubocop.yml +24 -0
  4. data/.ruby-version +1 -0
  5. data/.todo.reek +50 -0
  6. data/CHANGELOG.md +1 -0
  7. data/Gemfile +4 -0
  8. data/README.md +54 -6
  9. data/bin/ci-run +57 -0
  10. data/bin/ci-setup +46 -0
  11. data/bin/reek +16 -0
  12. data/bin/rspec +16 -0
  13. data/bin/rubocop +16 -0
  14. data/examples/fetch.rb +16 -0
  15. data/examples/search.rb +17 -0
  16. data/lib/poms.rb +84 -156
  17. data/lib/poms/api/auth.rb +42 -22
  18. data/lib/poms/api/client.rb +58 -0
  19. data/lib/poms/api/drivers/net_http.rb +69 -0
  20. data/lib/poms/api/json_client.rb +35 -0
  21. data/lib/poms/api/pagination_client.rb +67 -0
  22. data/lib/poms/api/request.rb +29 -31
  23. data/lib/poms/api/response.rb +31 -0
  24. data/lib/poms/api/search.rb +38 -0
  25. data/lib/poms/api/uris.rb +10 -0
  26. data/lib/poms/api/uris/media.rb +41 -0
  27. data/lib/poms/api/uris/schedule.rb +28 -0
  28. data/lib/poms/configuration.rb +59 -0
  29. data/lib/poms/errors.rb +26 -0
  30. data/lib/poms/fields.rb +26 -3
  31. data/lib/poms/timestamp.rb +10 -3
  32. data/lib/poms/version.rb +1 -1
  33. data/poms.gemspec +10 -11
  34. metadata +59 -128
  35. data/Gemfile.lock +0 -120
  36. data/lib/poms/base.rb +0 -8
  37. data/lib/poms/broadcast.rb +0 -55
  38. data/lib/poms/builder.rb +0 -92
  39. data/lib/poms/builderless/broadcast.rb +0 -37
  40. data/lib/poms/builderless/clip.rb +0 -36
  41. data/lib/poms/connect.rb +0 -11
  42. data/lib/poms/has_ancestors.rb +0 -54
  43. data/lib/poms/has_base_attributes.rb +0 -29
  44. data/lib/poms/merged_series.rb +0 -28
  45. data/lib/poms/poms_error.rb +0 -5
  46. data/lib/poms/schedule_event.rb +0 -34
  47. data/lib/poms/season.rb +0 -13
  48. data/lib/poms/series.rb +0 -12
  49. data/lib/poms/views.rb +0 -52
  50. data/spec/fabricators/poms_fabricator.rb +0 -44
  51. data/spec/fixtures/poms_broadcast.json +0 -318
  52. data/spec/fixtures/poms_broadcast_multiple_schedule_events.json +0 -354
  53. data/spec/fixtures/poms_broadcast_pippi.json +0 -180
  54. data/spec/fixtures/poms_group.json +0 -1087
  55. data/spec/fixtures/poms_series.json +0 -49
  56. data/spec/fixtures/poms_single_broadcast_by_channel.json +0 -136
  57. data/spec/fixtures/poms_zapp.json +0 -47363
  58. data/spec/fixtures/vcr_cassettes/poms/builderless/broadcast_starts_at/returns_a_datetime.yml +0 -53
  59. data/spec/fixtures/vcr_cassettes/poms/builderless/clip/has_a_position.yml +0 -43
  60. data/spec/fixtures/vcr_cassettes/poms/builderless/clip/has_a_title.yml +0 -43
  61. data/spec/fixtures/vcr_cassettes/poms/builderless/clip/has_a_video_url.yml +0 -43
  62. data/spec/fixtures/vcr_cassettes/poms/builderless/clip/has_an_image_id.yml +0 -43
  63. data/spec/fixtures/vcr_cassettes/poms/fetch_broadcasts_fetch_current_broadcast_fetches_the_current_broadcast.yml +0 -60
  64. data/spec/fixtures/vcr_cassettes/poms/fetch_broadcasts_fetch_next_broadcast_and_key_fetches_the_current_broadcast.yml +0 -68
  65. data/spec/fixtures/vcr_cassettes/poms/fetch_broadcasts_fetch_next_broadcast_and_key_returns_the_key.yml +0 -68
  66. data/spec/fixtures/vcr_cassettes/poms/merged_series/turns_the_json_into_a_hash.yml +0 -46
  67. data/spec/fixtures/vcr_cassettes/poms_fetch/a_broadcast_has_scheduled_events_with_last_with_starts_at.yml +0 -43
  68. data/spec/fixtures/vcr_cassettes/poms_fetch/a_clip_has_a_title.yml +0 -43
  69. data/spec/fixtures/vcr_cassettes/poms_fetch/an_aankeiler_has_images.yml +0 -43
  70. data/spec/fixtures/vcr_cassettes/poms_fetch_broadcasts_for_serie/returns_nil_when_a_broadcast_does_not_exist.yml +0 -42
  71. data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast/has_a_mid.yml +0 -51
  72. data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast/has_a_title.yml +0 -51
  73. data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast/has_scheduled_events_with_last_with_starts_at.yml +0 -51
  74. data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast_and_key/has_a_broadcast_with_a_mid.yml +0 -51
  75. data/spec/fixtures/vcr_cassettes/poms_fetch_current_broadcast_and_key/has_a_key.yml +0 -51
  76. data/spec/fixtures/vcr_cassettes/poms_fetch_descendant_mids/returns_a_list_of_mids.yml +0 -42
  77. data/spec/fixtures/vcr_cassettes/poms_fetch_descendants_for_serie/builds_a_list_of_broadcasts.yml +0 -102755
  78. data/spec/fixtures/vcr_cassettes/poms_fetch_group/has_a_child_with_a_media_type.yml +0 -448
  79. data/spec/fixtures/vcr_cassettes/poms_fetch_group/has_a_child_with_a_title.yml +0 -448
  80. data/spec/fixtures/vcr_cassettes/poms_fetch_playlist_clips/creates_an_array_of_clips.yml +0 -1051
  81. data/spec/integration/poms_spec.rb +0 -87
  82. data/spec/lib/poms/api/auth_spec.rb +0 -34
  83. data/spec/lib/poms/api/request_spec.rb +0 -30
  84. data/spec/lib/poms/broadcast_spec.rb +0 -49
  85. data/spec/lib/poms/builder_spec.rb +0 -53
  86. data/spec/lib/poms/builderless/broadcast_spec.rb +0 -11
  87. data/spec/lib/poms/builderless/clip_spec.rb +0 -20
  88. data/spec/lib/poms/fields_spec.rb +0 -63
  89. data/spec/lib/poms/merged_series_spec.rb +0 -26
  90. data/spec/lib/poms/schedule_event_spec.rb +0 -15
  91. data/spec/lib/poms/timestamp_spec.rb +0 -13
  92. data/spec/lib/poms/views_spec.rb +0 -38
  93. data/spec/lib/poms_spec.rb +0 -137
  94. data/spec/spec_helper.rb +0 -32
@@ -1,137 +0,0 @@
1
- require 'timecop'
2
- require 'spec_helper'
3
-
4
- describe Poms do
5
- describe '#fetch' do
6
- let(:response) { File.read 'spec/fixtures/poms_broadcast.json' }
7
-
8
- before do
9
- stub_request(:get, 'http://docs.poms.omroep.nl/media/KRO_1614405')
10
- .to_return(body: response)
11
- end
12
-
13
- it 'fetches a broadcast' do
14
- expect(Poms.fetch_raw_json('KRO_1614405')).to eq(JSON.parse response)
15
- end
16
-
17
- it 'fetches a broadcast and parses it correctly' do
18
- expect(Poms::Builder).to receive(:process_hash).with(JSON.parse response)
19
- Poms.fetch('KRO_1614405')
20
- end
21
-
22
- it 'fetches a group' do
23
- response = File.read 'spec/fixtures/poms_broadcast.json'
24
- url = 'http://docs.poms.omroep.nl/media/_design/media/_view/by-group?include_docs=true&key=%22POMS_S_NPO_823012%22&reduce=false'
25
- stub_request(:get, url).to_return(body: response)
26
- expect(Poms.fetch_group('POMS_S_NPO_823012')).to eq(JSON.parse response)
27
- end
28
-
29
- it 'returns nil when a broadcast does not exits' do
30
- stub_request(:get, 'http://docs.poms.omroep.nl/media/BLA')
31
- .to_return(status: [404, 'Not Found'])
32
- expect(Poms.fetch('BLA')).to eq(nil)
33
- end
34
- end
35
-
36
- describe '#fetch_playlist_clips' do
37
- it 'creates an array of clips' do
38
- expect(Poms.fetch_playlist_clips('POMS_S_NPO_818759').size).to eq(23)
39
- end
40
- end
41
-
42
- describe '#fetch_broadcasts_for_serie' do
43
- it 'returns nil when a broadcast does not exist' do
44
- stub_request(:get, 'http://docs.poms.omroep.nl/media/_design/media/_view/by-ancestor-and-type?reduce=false&key=[%22BLA%22,%22BROADCAST%22]&include_docs=true')
45
- .to_return(status: [404, 'Not Found'])
46
- expect(Poms.fetch_broadcasts_for_serie('BLA')).to eq([])
47
- end
48
- end
49
-
50
- describe '#upcoming_broadcasts' do
51
- let(:response) { File.read 'spec/fixtures/poms_zapp.json' }
52
- let(:start_time) { Time.parse '2013-05-28 17:32:10 +0200' }
53
- let(:end_time) { Time.parse '2013-06-11 17:32:50 +0200' }
54
-
55
- before do
56
- path = 'http://docs.poms.omroep.nl/media/_design/media/_view/broadcasts-by-broadcaster-and-start?startkey=[%22Zapp%22,1369755130000]&endkey=[%22Zapp%22,1370964770000]&reduce=false&include_docs=true'
57
- stub_request(:get, path).to_return(body: response)
58
- end
59
-
60
- it 'fetches all broadcast by zapp and parses it correctly' do
61
- expect(Poms::Builder).to receive(:process_hash).exactly(136).times
62
- Poms.upcoming_broadcasts('zapp', start_time, end_time)
63
- end
64
- end
65
-
66
- describe 'fetch broadcasts' do
67
- let(:response) do
68
- File.read 'spec/fixtures/poms_single_broadcast_by_channel.json'
69
- end
70
-
71
- before do
72
- Timecop.freeze(DateTime.strptime('1410969127', '%s'))
73
- end
74
-
75
- after do
76
- Timecop.return
77
- end
78
-
79
- describe '#fetch_current_broadcast' do
80
- before do
81
- path = 'http://docs.poms.omroep.nl/media/_design/media/_view/broadcasts-by-channel-and-start?startkey=[%22NED3%22,1410969127000]&endkey=[%22NED3%22,1410882727000]&reduce=false&include_docs=true&descending=true&limit=1'
82
- stub_request(:get, path).to_return(body: response)
83
- end
84
-
85
- it 'fetches the current broadcast' do
86
- expect(Poms::Builder).to receive(:process_hash).exactly(0).times
87
- Poms.fetch_current_broadcast('NED3')
88
- end
89
- end
90
-
91
- describe '#fetch_current_broadcast_and_key' do
92
- before do
93
- path = 'http://docs.poms.omroep.nl/media/_design/media/_view/broadcasts-by-channel-and-start?startkey=[%22NED3%22,1410969127000]&endkey=[%22NED3%22,1410882727000]&reduce=false&include_docs=true&descending=true&limit=1'
94
- stub_request(:get, path).to_return(body: response)
95
- end
96
-
97
- it 'fetches the current broadcast' do
98
- expect(Poms::Builder).to receive(:process_hash).exactly(1).times
99
- Poms.fetch_current_broadcast_and_key('NED3')
100
- end
101
-
102
- it 'returns the key' do
103
- expect(Poms.fetch_current_broadcast_and_key('NED3')[:key])
104
- .to eq(['NED3', 1_410_966_671_000])
105
- end
106
- end
107
-
108
- describe '#fetch_next_broadcast' do
109
- before do
110
- path = 'http://docs.poms.omroep.nl/media/_design/media/_view/broadcasts-by-channel-and-start?startkey=[%22NED3%22,1410969127000]&endkey=[%22NED3%22,1411055527000]&reduce=false&include_docs=true&limit=1'
111
- stub_request(:get, path).to_return(body: response)
112
- end
113
-
114
- it 'fetches the next broadcast' do
115
- expect(Poms::Builder).to receive(:process_hash).exactly(1).times
116
- Poms.fetch_next_broadcast('NED3')
117
- end
118
- end
119
-
120
- describe '#fetch_next_broadcast_and_key' do
121
- before do
122
- path = 'http://docs.poms.omroep.nl/media/_design/media/_view/broadcasts-by-channel-and-start?startkey=[%22NED3%22,1410969127000]&endkey=[%22NED3%22,1411055527000]&reduce=false&include_docs=true&descending=true&limit=1'
123
- stub_request(:get, path).to_return(body: response)
124
- end
125
-
126
- it 'fetches the current broadcast' do
127
- expect(Poms::Builder).to receive(:process_hash).exactly(1).times
128
- Poms.fetch_next_broadcast_and_key('NED3')
129
- end
130
-
131
- it 'returns the key' do
132
- expect(Poms.fetch_next_broadcast_and_key('NED3')[:key])
133
- .to eq(['NED3', 1_410_969_900_000])
134
- end
135
- end
136
- end
137
- end
data/spec/spec_helper.rb DELETED
@@ -1,32 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'webmock/rspec'
4
- require 'fabrication'
5
- require 'vcr'
6
- require 'timecop'
7
- require 'poms'
8
-
9
- WebMock.disable_net_connect!
10
-
11
- VCR.configure do |config|
12
- config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
13
- config.hook_into :webmock
14
- end
15
-
16
- RSpec.configure do |config|
17
- config.around(:each) do |example|
18
- options = example.metadata[:vcr] || {}
19
- if options[:record] == :skip
20
- VCR.turned_off(&example)
21
- else
22
- name = example.metadata[:full_description]
23
- .split(/\s+/, 2).join('/')
24
- .underscore.gsub(%r{[^\w\/]+}, '_')
25
- VCR.use_cassette(name, options, &example)
26
- end
27
- end
28
-
29
- config.before(:suite) do
30
- Timecop.freeze Time.utc(2015, 10, 6, 12)
31
- end
32
- end