poms 2.0.1 → 2.1.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.todo.reek +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/circle.yml +12 -0
- data/lib/poms.rb +2 -2
- data/lib/poms/api/uris/schedule.rb +18 -4
- data/lib/poms/fields.rb +18 -7
- data/lib/poms/version.rb +1 -1
- data/poms.gemspec +1 -0
- metadata +17 -4
- data/bin/ci-run +0 -57
- data/bin/ci-setup +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 159b27be6905d2411787cdf6e467f9740ec7fad8
|
4
|
+
data.tar.gz: 383b7e756c3fa5e19a9772aab2321d1f1e3beff2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18424ff4b9cde70eb7c8fc88f327364a017546109852c9c5fd9111e2f85abe2f38c9949badcf704d261ae683c2cb88192f52fb1ef0bcb5bc42ac6a0b89aad990
|
7
|
+
data.tar.gz: da656995685bcd795fd4e99e149486bb05c6900e976d4151113882476f716439e563ba2be88a1a471868b31d5c51e988d891c0c2cfbc05190b35138c826ee084
|
data/.rubocop.yml
CHANGED
data/.todo.reek
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Poms Release notes
|
2
2
|
|
3
|
+
## 2.1.0
|
4
|
+
|
5
|
+
* Allow `schedule_events` to accept a block which allows you to filter the events.
|
6
|
+
* The `scheduled_now` and `scheduled_next` functions always return the most recent and upcoming shows. They shouldn't return nil anymore, even if something is not live at the moment (during a commercial break for instance).
|
7
|
+
|
3
8
|
## 2.0.1
|
4
9
|
|
5
10
|
* Fix search parameter `type`. This didn't get picked up properly before, but is now used in the search.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[
|
1
|
+
[](https://circleci.com/gh/brightin/poms)
|
2
2
|
|
3
3
|
# Poms
|
4
4
|
|
data/circle.yml
ADDED
data/lib/poms.rb
CHANGED
@@ -87,7 +87,7 @@ module Poms
|
|
87
87
|
Poms::Api::JsonClient.get(
|
88
88
|
Poms::Api::Uris::Schedule.now(config.base_uri, channel),
|
89
89
|
config.credentials
|
90
|
-
)
|
90
|
+
).fetch('items').first
|
91
91
|
end
|
92
92
|
|
93
93
|
# Fetches the event for the next broadcast on a given channel
|
@@ -97,7 +97,7 @@ module Poms
|
|
97
97
|
Poms::Api::JsonClient.get(
|
98
98
|
Poms::Api::Uris::Schedule.next(config.base_uri, channel),
|
99
99
|
config.credentials
|
100
|
-
)
|
100
|
+
).fetch('items').first
|
101
101
|
end
|
102
102
|
|
103
103
|
def reset_config
|
@@ -10,15 +10,29 @@ module Poms
|
|
10
10
|
module_function
|
11
11
|
|
12
12
|
def now(base_uri, channel)
|
13
|
-
uri_for_path(
|
13
|
+
uri_for_path(
|
14
|
+
base_uri,
|
15
|
+
"/channel/#{channel}",
|
16
|
+
stop: Time.now.iso8601,
|
17
|
+
sort: 'desc',
|
18
|
+
max: 1
|
19
|
+
)
|
14
20
|
end
|
15
21
|
|
16
22
|
def next(base_uri, channel)
|
17
|
-
uri_for_path(
|
23
|
+
uri_for_path(
|
24
|
+
base_uri,
|
25
|
+
"/channel/#{channel}",
|
26
|
+
start: Time.now.iso8601,
|
27
|
+
sort: 'asc',
|
28
|
+
max: 1
|
29
|
+
)
|
18
30
|
end
|
19
31
|
|
20
|
-
def uri_for_path(base_uri, path = nil)
|
21
|
-
base_uri.merge(path: "#{API_PATH}#{path}")
|
32
|
+
def uri_for_path(base_uri, path = nil, query = {})
|
33
|
+
uri = base_uri.merge(path: "#{API_PATH}#{path}")
|
34
|
+
uri.query_values = query
|
35
|
+
uri
|
22
36
|
end
|
23
37
|
|
24
38
|
private_class_method :uri_for_path
|
data/lib/poms/fields.rb
CHANGED
@@ -71,16 +71,28 @@ module Poms
|
|
71
71
|
parent.first['index'] if parent.present?
|
72
72
|
end
|
73
73
|
|
74
|
+
# Returns an array of start and end times for the scheduled events for
|
75
|
+
# this item. It returns an empty array if no events are found. You can pass
|
76
|
+
# in a block to filter the events on data that is not returned, like
|
77
|
+
# channel.
|
78
|
+
#
|
79
|
+
# @param item The Poms hash
|
74
80
|
def schedule_events(item)
|
75
81
|
events = item.fetch('scheduleEvents', [])
|
76
|
-
events
|
77
|
-
|
78
|
-
'starts_at' => Timestamp.to_datetime(event['start']),
|
79
|
-
'ends_at' => Timestamp.to_datetime(event['start'] + event['duration'])
|
80
|
-
}
|
81
|
-
end
|
82
|
+
events = yield(events) if block_given?
|
83
|
+
events.map { |event| hash_event(event) }
|
82
84
|
end
|
83
85
|
|
86
|
+
# Turns the event into a hash.
|
87
|
+
def hash_event(event)
|
88
|
+
{
|
89
|
+
'starts_at' => Timestamp.to_datetime(event.fetch('start')),
|
90
|
+
'ends_at' => Timestamp.to_datetime(event.fetch('start') +
|
91
|
+
event.fetch('duration'))
|
92
|
+
}
|
93
|
+
end
|
94
|
+
private_class_method :hash_event
|
95
|
+
|
84
96
|
# Poms has arrays of hashes for some types that have a value and type. This
|
85
97
|
# is a way to access those simply.
|
86
98
|
#
|
@@ -98,7 +110,6 @@ module Poms
|
|
98
110
|
return unless res
|
99
111
|
res['value']
|
100
112
|
end
|
101
|
-
|
102
113
|
private_class_method :value_of_type
|
103
114
|
end
|
104
115
|
end
|
data/lib/poms/version.rb
CHANGED
data/poms.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'rubocop-rspec'
|
27
27
|
spec.add_development_dependency 'rubocop'
|
28
28
|
spec.add_development_dependency 'simplecov'
|
29
|
+
spec.add_development_dependency 'timecop'
|
29
30
|
spec.add_development_dependency 'vcr'
|
30
31
|
spec.add_development_dependency 'webmock'
|
31
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Kruijsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: timecop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: vcr
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,11 +209,10 @@ files:
|
|
195
209
|
- LICENSE.txt
|
196
210
|
- README.md
|
197
211
|
- Rakefile
|
198
|
-
- bin/ci-run
|
199
|
-
- bin/ci-setup
|
200
212
|
- bin/reek
|
201
213
|
- bin/rspec
|
202
214
|
- bin/rubocop
|
215
|
+
- circle.yml
|
203
216
|
- examples/fetch.rb
|
204
217
|
- examples/search.rb
|
205
218
|
- lib/poms.rb
|
data/bin/ci-run
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#!/bin/bash --login
|
2
|
-
#
|
3
|
-
# Usage: bin/ci-run [--help|--job N]
|
4
|
-
#
|
5
|
-
# Run all tasks required for a Continuous Integration job. Also see ci-setup.
|
6
|
-
#
|
7
|
-
# Options:
|
8
|
-
#
|
9
|
-
# --job N May be used for CI parallelisation. Use this number to do only part
|
10
|
-
# of the usual work, for example by invoking different test scripts.
|
11
|
-
# --help Display this message.
|
12
|
-
#
|
13
|
-
# Examples:
|
14
|
-
#
|
15
|
-
# Run all the tests for this project:
|
16
|
-
#
|
17
|
-
# bin/ci-run
|
18
|
-
#
|
19
|
-
# Run only part of the test suite:
|
20
|
-
#
|
21
|
-
# bin/ci-run --job 1
|
22
|
-
|
23
|
-
set -e
|
24
|
-
|
25
|
-
# Run the actual tests for this project. The exit code of this function is
|
26
|
-
# determines the outcome of the CI build.
|
27
|
-
#
|
28
|
-
# TODO adapt the Rake command invokation below into something that makes sense for
|
29
|
-
# your particular project.
|
30
|
-
run_tests() {
|
31
|
-
# RVM is not activated in non-login shells, so we do so manually.
|
32
|
-
RUBY_VERSION=$(cat .ruby-version)
|
33
|
-
echo "Using Ruby $RUBY_VERSION"
|
34
|
-
source $(rvm $RUBY_VERSION do rvm env --path)
|
35
|
-
|
36
|
-
set -x
|
37
|
-
bundle exec rubocop
|
38
|
-
bundle exec reek
|
39
|
-
bundle exec rspec
|
40
|
-
}
|
41
|
-
|
42
|
-
# Print help for this script by printing its top comment block (without the
|
43
|
-
# comment markers).
|
44
|
-
show_help() {
|
45
|
-
awk '/^# Usage/,/^$/' $0 | cut -c 3-
|
46
|
-
exit 1
|
47
|
-
}
|
48
|
-
|
49
|
-
if [[ $# -ge 1 ]]
|
50
|
-
then
|
51
|
-
case $1 in
|
52
|
-
"--job" ) run_tests $2;;
|
53
|
-
* ) show_help;;
|
54
|
-
esac
|
55
|
-
else
|
56
|
-
run_tests
|
57
|
-
fi
|
data/bin/ci-setup
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/bin/bash --login
|
2
|
-
#
|
3
|
-
# Usage: bin/ci-setup [--help]
|
4
|
-
#
|
5
|
-
# Set up a Codeship CI VM for running a test suite. Also see ci-run.
|
6
|
-
#
|
7
|
-
# Options:
|
8
|
-
#
|
9
|
-
# --help Display this message.
|
10
|
-
|
11
|
-
set -e
|
12
|
-
|
13
|
-
# Perform the steps necessary to set up the CI environment for testing. This
|
14
|
-
# should include languages, services, package managers, environment, etc.
|
15
|
-
setup() {
|
16
|
-
set -x
|
17
|
-
# Read the required version of Ruby from the Gemfile and use RVM to install it
|
18
|
-
rvm use $(cat .ruby-version) --install
|
19
|
-
|
20
|
-
# To use Node.js as Javascript runtime, uncomment the following lines.
|
21
|
-
# nvm install 0.12
|
22
|
-
# nvm use 0.12
|
23
|
-
|
24
|
-
# If the project has a package.json file and javascript dependencies, you can
|
25
|
-
# install them here.
|
26
|
-
# npm install
|
27
|
-
|
28
|
-
# Install Ruby dependencies with Bundler.
|
29
|
-
bundle install
|
30
|
-
|
31
|
-
set +x
|
32
|
-
}
|
33
|
-
|
34
|
-
# Print help for this script by printing its top comment block (without the
|
35
|
-
# comment markers).
|
36
|
-
show_help() {
|
37
|
-
awk '/^# Usage/,/^$/' $0 | cut -c 3-
|
38
|
-
exit 1
|
39
|
-
}
|
40
|
-
|
41
|
-
if [[ $# -ge 1 ]]
|
42
|
-
then
|
43
|
-
show_help
|
44
|
-
else
|
45
|
-
setup
|
46
|
-
fi
|