auntie 0.2.0 → 0.3.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/Gemfile +5 -0
- data/Gemfile.lock +22 -1
- data/README.md +7 -4
- data/bin/auntie +26 -0
- data/bin/news +1 -1
- data/bin/radio +15 -18
- data/bin/sport +1 -1
- data/bin/tv +13 -13
- data/bin/weather +7 -6
- data/features/step_definitions/location_steps.rb +2 -2
- data/features/step_definitions/weather_steps.rb +1 -1
- data/features/support/env.rb +1 -1
- data/lib/bbc/location.rb +14 -10
- data/lib/bbc/news.rb +9 -8
- data/lib/bbc/now_next.rb +24 -24
- data/lib/bbc/schedule.rb +12 -13
- data/lib/bbc/shell/characters.rb +32 -22
- data/lib/bbc/shell/colors.rb +39 -32
- data/lib/bbc/shell/describe_time.rb +23 -13
- data/lib/bbc/sport.rb +11 -9
- data/lib/bbc/version.rb +3 -1
- data/lib/bbc/weather.rb +29 -27
- data/spec/bbc/colors_spec.rb +18 -0
- data/spec/bbc/describe_time_spec.rb +69 -0
- data/spec/bbc/location_spec.rb +22 -22
- data/spec/bbc/news_spec.rb +8 -17
- data/spec/bbc/now_next_spec.rb +12 -4
- data/spec/bbc/schedule_spec.rb +10 -11
- data/spec/bbc/shell_symbols_spec.rb +49 -0
- data/spec/bbc/sport_spec.rb +7 -12
- data/spec/bbc/version_spec.rb +5 -5
- data/spec/bbc/weather_spec.rb +7 -13
- data/spec/spec_helper.rb +8 -2
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b52477f5f746d84a915062f1e8e753a67699e05
|
4
|
+
data.tar.gz: 52dfbb1a107163110d67c12c131f1ef7109b668c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 623f37227d3a316507bb4f58a99b34563ef643f74f3df3d3b2d37a4c7f8568820c4b3e3ee10e9023e7144b3b5a6cd1d643d96d651e131ad03cc9feb76b653ef4
|
7
|
+
data.tar.gz: 88df1f09a00642f50866efff98076b0413bdcfed27e1a4b1924140ed0a75c936a38f95534fd4b6bf2e0bcb48a6a708d8ad2c757faed538a73f45b2e68a108c5e
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
auntie (0.
|
4
|
+
auntie (0.3.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -15,19 +15,30 @@ GEM
|
|
15
15
|
builder (3.1.4)
|
16
16
|
childprocess (0.2.3)
|
17
17
|
ffi (~> 1.0.6)
|
18
|
+
coveralls (0.7.0)
|
19
|
+
multi_json (~> 1.3)
|
20
|
+
rest-client
|
21
|
+
simplecov (>= 0.7)
|
22
|
+
term-ansicolor
|
23
|
+
thor
|
18
24
|
cucumber (1.2.1)
|
19
25
|
builder (>= 2.1.2)
|
20
26
|
diff-lcs (>= 1.1.3)
|
21
27
|
gherkin (~> 2.11.0)
|
22
28
|
json (>= 1.4.6)
|
23
29
|
diff-lcs (1.1.3)
|
30
|
+
docile (1.1.3)
|
24
31
|
ffi (1.0.11)
|
25
32
|
gherkin (2.11.5)
|
26
33
|
json (>= 1.4.6)
|
27
34
|
json (1.7.5)
|
35
|
+
mime-types (2.1)
|
36
|
+
multi_json (1.8.4)
|
28
37
|
rake (0.9.2.2)
|
29
38
|
rdoc (3.12)
|
30
39
|
json (~> 1.4)
|
40
|
+
rest-client (1.6.7)
|
41
|
+
mime-types (>= 1.16)
|
31
42
|
rspec (2.11.0)
|
32
43
|
rspec-core (~> 2.11.0)
|
33
44
|
rspec-expectations (~> 2.11.0)
|
@@ -36,6 +47,15 @@ GEM
|
|
36
47
|
rspec-expectations (2.11.3)
|
37
48
|
diff-lcs (~> 1.1.3)
|
38
49
|
rspec-mocks (2.11.3)
|
50
|
+
simplecov (0.8.2)
|
51
|
+
docile (~> 1.1.0)
|
52
|
+
multi_json
|
53
|
+
simplecov-html (~> 0.8.0)
|
54
|
+
simplecov-html (0.8.0)
|
55
|
+
term-ansicolor (1.2.2)
|
56
|
+
tins (~> 0.8)
|
57
|
+
thor (0.18.1)
|
58
|
+
tins (0.13.2)
|
39
59
|
|
40
60
|
PLATFORMS
|
41
61
|
ruby
|
@@ -44,6 +64,7 @@ DEPENDENCIES
|
|
44
64
|
anticipate
|
45
65
|
aruba
|
46
66
|
auntie!
|
67
|
+
coveralls
|
47
68
|
rake
|
48
69
|
rdoc
|
49
70
|
rspec
|
data/README.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
# Auntie
|
2
|
-
|
3
1
|
[](https://travis-ci.org/simongregory/auntie)
|
2
|
+
[](https://coveralls.io/r/simongregory/auntie)
|
4
3
|
[](https://codeclimate.com/github/simongregory/auntie)
|
4
|
+
[](https://gemnasium.com/simongregory/auntie)
|
5
|
+
[](http://badge.fury.io/rb/auntie)
|
6
|
+
|
7
|
+
# Auntie
|
5
8
|
|
6
9
|
A Ruby Gem for accessing [BBC]() Weather, TV, Radio, News and Sport feeds.
|
7
10
|
|
@@ -20,9 +23,9 @@ A Ruby Gem for accessing [BBC]() Weather, TV, Radio, News and Sport feeds.
|
|
20
23
|
radio # what is on Radio 1 today
|
21
24
|
radio next # what is on the wireless next
|
22
25
|
radio six # what is on Radio Six Music
|
23
|
-
|
26
|
+
|
24
27
|
news # the latest news headlines
|
25
|
-
|
28
|
+
|
26
29
|
sport # the latest sport headlines
|
27
30
|
|
28
31
|
## zsh integration
|
data/bin/auntie
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
SAY_HELLO=<<EOM
|
4
|
+
auntie is a collection of tools for accessing BBC Weather, TV, Radio, News and Sport
|
5
|
+
|
6
|
+
Useage:
|
7
|
+
|
8
|
+
weather # lists the weather for the next 24 hours
|
9
|
+
|
10
|
+
tv # what is on BBC One today
|
11
|
+
tv two # what is on BBC Two today
|
12
|
+
tv now # list of all programmes being broadcast on tv now
|
13
|
+
tv next # list of all programmes being broadcast on tv next
|
14
|
+
|
15
|
+
radio # what is on Radio 1 today
|
16
|
+
radio six # what is on Radio Six Music
|
17
|
+
radio now # what is on the wireless now
|
18
|
+
radio next # what is on the wireless next
|
19
|
+
|
20
|
+
news # the latest news headlines
|
21
|
+
|
22
|
+
sport # the latest sport headlines
|
23
|
+
|
24
|
+
EOM
|
25
|
+
|
26
|
+
puts SAY_HELLO
|
data/bin/news
CHANGED
data/bin/radio
CHANGED
@@ -2,28 +2,28 @@
|
|
2
2
|
require 'auntie'
|
3
3
|
|
4
4
|
channels = {
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
5
|
+
one: { id: 'radio1', region: '/england' },
|
6
|
+
onextra: { id: '1xtra' },
|
7
|
+
two: { id: 'radio2' },
|
8
|
+
three: { id: 'radio3' },
|
9
|
+
four: { id: 'radio4', region: '/fm' },
|
10
|
+
fourextra: { id: 'radio4extra' },
|
11
|
+
five: { id: '5live' },
|
12
|
+
six: { id: '6music' },
|
13
|
+
asian: { id: 'asiannetwork' },
|
14
|
+
worldservice: { id: 'worldserviceradio' }
|
15
15
|
}
|
16
16
|
|
17
17
|
channel = ARGV[0] || :one
|
18
18
|
|
19
19
|
if ARGV[0] == 'help' && ARGV[1] == '-c'
|
20
|
-
channels.each { |k,v| puts k }
|
20
|
+
channels.each { |k, v| puts k }
|
21
21
|
puts "now\nnext"
|
22
22
|
exit
|
23
23
|
end
|
24
24
|
|
25
|
-
if
|
26
|
-
puts 'Useage: radio
|
25
|
+
if %w( help -h --help).include? ARGV[0]
|
26
|
+
puts 'Useage: radio [station]'
|
27
27
|
exit
|
28
28
|
end
|
29
29
|
|
@@ -37,13 +37,10 @@ if ARGV[0] == 'next'
|
|
37
37
|
exit
|
38
38
|
end
|
39
39
|
|
40
|
-
if channels.
|
40
|
+
if channels.key? channel.to_sym
|
41
41
|
|
42
42
|
selection = channels[channel.to_sym]
|
43
|
-
|
44
|
-
if ['yesterday', 'today', 'tomorrow'].include? ARGV[1]
|
45
|
-
selection[:period] = '/'+ARGV[1]
|
46
|
-
end
|
43
|
+
selection[:period] = '/' + ARGV[1] if %w(yesterday today tomorrow).include? ARGV[1]
|
47
44
|
|
48
45
|
Schedule.new.load selection
|
49
46
|
else
|
data/bin/sport
CHANGED
data/bin/tv
CHANGED
@@ -2,29 +2,29 @@
|
|
2
2
|
require 'auntie'
|
3
3
|
|
4
4
|
channels = {
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
5
|
+
one: { id: 'bbcone', region: '/london' },
|
6
|
+
two: { id: 'bbctwo', region: '/england' },
|
7
|
+
three: { id: 'bbcthree' },
|
8
|
+
four: { id: 'bbcfour' },
|
9
|
+
cbeebies: { id: 'cbeebies' },
|
10
|
+
cbbc: { id: 'cbbc' },
|
11
|
+
news: { id: 'bbcnews' },
|
12
|
+
parliament: { id: 'parliament' },
|
13
|
+
alba: { id: 'alba' }
|
14
14
|
}
|
15
15
|
|
16
16
|
channel = ARGV[0] || :one
|
17
17
|
|
18
18
|
if ARGV[0] == 'help' && ARGV[1] == '-c'
|
19
|
-
channels.each { |k,v| puts k }
|
19
|
+
channels.each { |k, v| puts k }
|
20
20
|
puts "now\nnext"
|
21
21
|
exit
|
22
22
|
end
|
23
23
|
|
24
|
-
helps =
|
24
|
+
helps = %w(help -h --help)
|
25
25
|
|
26
26
|
if helps.include? ARGV[0]
|
27
|
-
puts 'Useage: tv
|
27
|
+
puts 'Useage: tv [channel]'
|
28
28
|
exit
|
29
29
|
end
|
30
30
|
|
@@ -38,7 +38,7 @@ if ARGV[0] == 'next'
|
|
38
38
|
exit
|
39
39
|
end
|
40
40
|
|
41
|
-
if channels.
|
41
|
+
if channels.key? channel.to_sym
|
42
42
|
Schedule.new.load channels[channel.to_sym]
|
43
43
|
else
|
44
44
|
puts "'#{channel}' is an unknown channel"
|
data/bin/weather
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
require 'auntie'
|
3
3
|
|
4
4
|
if ARGV[0] == 'help' && ARGV[1] == '-c'
|
5
|
-
|
5
|
+
# loc-search doesn't seem to be compatible with zsh completion?
|
6
|
+
puts "--location-search\n--hourly\n--daily"
|
6
7
|
exit
|
7
8
|
end
|
8
9
|
|
9
|
-
if
|
10
|
+
if %w(help -h --help).include? ARGV[0]
|
10
11
|
puts 'Useage: weather <Postcode or BBC location id>'
|
11
|
-
puts ' --location-search <place>'
|
12
|
+
puts ' --location-search <place name>'
|
12
13
|
puts ' --hourly <Postcode or BBC location id>'
|
13
14
|
puts ' --daily <Postcode or BBC location id>'
|
14
15
|
exit
|
@@ -17,15 +18,15 @@ end
|
|
17
18
|
if ARGV[0] == '--location-search'
|
18
19
|
place = ARGV[1..-1].join(' ')
|
19
20
|
|
20
|
-
abort
|
21
|
-
place =
|
21
|
+
abort 'Please specify a location to search for.' if place.empty?
|
22
|
+
place = 'Hadfield' if place.downcase == 'royston vasey'
|
22
23
|
|
23
24
|
Location.new.find(place)
|
24
25
|
exit
|
25
26
|
end
|
26
27
|
|
27
28
|
def location
|
28
|
-
ARGV[0] ||= '2643743'
|
29
|
+
ARGV[0] ||= '2643743' # Default to London.
|
29
30
|
end
|
30
31
|
|
31
32
|
action = ARGV[0]
|
data/features/support/env.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'aruba/cucumber'
|
2
2
|
|
3
3
|
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
4
|
-
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
4
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'lib')
|
5
5
|
|
6
6
|
Before do
|
7
7
|
# Using "announce" causes massive warnings on 1.9.2
|
data/lib/bbc/location.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
# Discovers BBC location ids
|
4
|
+
#
|
3
5
|
class Location
|
4
|
-
|
6
|
+
include ShellColors
|
7
|
+
|
8
|
+
def initialize(io = STDOUT)
|
5
9
|
@io = io
|
6
10
|
end
|
7
11
|
|
8
12
|
def find(place)
|
9
|
-
|
13
|
+
fail 'Please use a longer search term' if place.length < 3
|
10
14
|
|
11
15
|
@io.print "Searching for #{place}..."
|
12
16
|
|
@@ -14,16 +18,16 @@ class Location
|
|
14
18
|
end
|
15
19
|
|
16
20
|
def url(term)
|
17
|
-
|
21
|
+
escaped = URI.encode(term)
|
22
|
+
"http://www.bbc.co.uk/locator/default/en-GB/autocomplete.json?search=#{escaped}&filter=domestic&ptrt=/"
|
18
23
|
end
|
19
24
|
|
20
25
|
def load(place)
|
21
26
|
begin
|
22
|
-
|
23
|
-
|
27
|
+
raw = open(url(place), 'UserAgent' => AUNTIE::USER_AGENT).read
|
28
|
+
data = JSON.parse(raw)
|
24
29
|
rescue
|
25
|
-
|
26
|
-
exit
|
30
|
+
raise 'Unable to download location data'
|
27
31
|
end
|
28
32
|
|
29
33
|
@io.print "\r"
|
@@ -31,13 +35,13 @@ class Location
|
|
31
35
|
if data.empty?
|
32
36
|
@io.puts "No locations found matching '#{place}' "
|
33
37
|
else
|
34
|
-
@io.puts sprintf
|
38
|
+
@io.puts sprintf '%-42s %-10s', 'Place', 'ID'
|
35
39
|
data.each do |e|
|
36
40
|
name = e['fullName'].split(',')
|
37
|
-
place = light_green(name[0]+ ',') + green(name[1])
|
41
|
+
place = light_green(name[0] + ',') + green(name[1])
|
38
42
|
id = cyan e['id']
|
39
43
|
|
40
|
-
@io.puts sprintf
|
44
|
+
@io.puts sprintf '%-60s %-10s', place, id
|
41
45
|
end
|
42
46
|
end
|
43
47
|
end
|
data/lib/bbc/news.rb
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
# Provides a list of the latest BBC News headlines
|
4
|
+
#
|
3
5
|
class News
|
4
|
-
def initialize(io=STDOUT)
|
6
|
+
def initialize(io = STDOUT)
|
5
7
|
@io = io
|
6
8
|
end
|
7
9
|
|
8
10
|
def load
|
9
11
|
cols = console_columns
|
10
12
|
@io.puts 'BBC News Headlines'
|
11
|
-
data['entries'].each
|
12
|
-
@io.puts news_item['headline'][0..cols-1]
|
13
|
-
|
13
|
+
data['entries'].each do |news_item|
|
14
|
+
@io.puts news_item['headline'][0..cols - 1]
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
18
|
private
|
17
19
|
|
18
20
|
def data
|
19
21
|
begin
|
20
|
-
|
21
|
-
|
22
|
+
raw = open('http://www.bbc.co.uk/news/10284448/ticker.sjson', 'UserAgent' => AUNTIE::USER_AGENT).read
|
23
|
+
JSON.parse(raw)
|
22
24
|
rescue
|
23
|
-
|
24
|
-
exit
|
25
|
+
raise 'Unable to download news'
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
data/lib/bbc/now_next.rb
CHANGED
@@ -1,33 +1,37 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
# Lists what is airing now and next accross BBC Radio and Television stations
|
4
|
+
#
|
3
5
|
class NowNext
|
4
|
-
|
6
|
+
include Timings
|
7
|
+
|
8
|
+
def initialize(io = STDOUT)
|
5
9
|
@io = io
|
6
10
|
end
|
7
11
|
|
8
12
|
def tv_now
|
9
|
-
@fmt =
|
13
|
+
@fmt = '%-18s %s'
|
10
14
|
load 'tv'
|
11
15
|
|
12
16
|
on_now
|
13
17
|
end
|
14
18
|
|
15
19
|
def tv_next
|
16
|
-
@fmt =
|
20
|
+
@fmt = '%-18s %s'
|
17
21
|
load 'tv'
|
18
22
|
|
19
23
|
on_next
|
20
24
|
end
|
21
25
|
|
22
26
|
def radio_now
|
23
|
-
@fmt =
|
27
|
+
@fmt = '%-32s %s'
|
24
28
|
load 'radio'
|
25
29
|
|
26
30
|
on_now
|
27
31
|
end
|
28
32
|
|
29
33
|
def radio_next
|
30
|
-
@fmt =
|
34
|
+
@fmt = '%-32s %s'
|
31
35
|
load 'radio'
|
32
36
|
|
33
37
|
on_next
|
@@ -37,56 +41,52 @@ class NowNext
|
|
37
41
|
|
38
42
|
Programme = Struct.new(:channel, :title, :starts, :starts_in)
|
39
43
|
|
40
|
-
def load
|
44
|
+
def load(medium)
|
41
45
|
begin
|
42
|
-
|
43
|
-
|
46
|
+
raw = open("http://www.bbc.co.uk/iplayer/ion/multinownext/service_type/#{medium}/simulcast_only/1/format/json", 'UserAgent' => AUNTIE::USER_AGENT).read
|
47
|
+
@data = JSON.parse(raw)
|
44
48
|
rescue
|
45
|
-
|
46
|
-
exit
|
49
|
+
raise "Unable to download #{medium} schedules"
|
47
50
|
end
|
48
51
|
end
|
49
52
|
|
50
53
|
def on_now
|
51
|
-
@data['blocklist'].each
|
54
|
+
@data['blocklist'].each do |e|
|
52
55
|
channel = format_channel e['title']
|
53
56
|
programme = e['now'][0]['episode']['passionsite_title'] rescue next
|
54
57
|
|
55
58
|
@io.puts sprintf @fmt, channel, programme
|
56
|
-
|
59
|
+
end
|
57
60
|
end
|
58
61
|
|
59
62
|
def on_next
|
60
63
|
programmes = []
|
61
64
|
|
62
|
-
first = 9
|
63
65
|
second = 0
|
64
66
|
|
65
|
-
@data['blocklist'].each
|
67
|
+
@data['blocklist'].each do |e|
|
66
68
|
p = Programme.new
|
67
69
|
p.channel = format_channel e['title']
|
68
70
|
|
69
71
|
p.title = e['next'][0]['episode']['passionsite_title'] rescue ''
|
70
72
|
p.starts = Time.parse(e['next'][0]['start_time_iso']) rescue ''
|
71
73
|
|
72
|
-
#next_start = starts.strftime("%H:%M")
|
74
|
+
# next_start = starts.strftime("%H:%M")
|
73
75
|
p.starts_in = how_long_between(time_now, p.starts)
|
74
76
|
|
75
|
-
second = p.channel.length+3 if p.channel.length > second
|
77
|
+
second = p.channel.length + 3 if p.channel.length > second
|
76
78
|
|
77
79
|
programmes << p
|
78
|
-
|
80
|
+
end
|
79
81
|
|
80
82
|
programmes.sort_by! { |p| p.starts }
|
81
83
|
|
82
|
-
programmes.each
|
83
|
-
|
84
|
-
|
85
|
-
def format_channel name
|
86
|
-
name.gsub(/^BBC | (London|England|Channel)/,'')
|
84
|
+
programmes.each do |p|
|
85
|
+
@io.puts sprintf("%-9s %-#{second}s %s", p.starts_in, p.channel, p.title)
|
86
|
+
end
|
87
87
|
end
|
88
88
|
|
89
|
-
def
|
90
|
-
|
89
|
+
def format_channel(name)
|
90
|
+
name.gsub(/^BBC | (London|England|Channel)/, '')
|
91
91
|
end
|
92
92
|
end
|