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
data/spec/bbc/location_spec.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__),
|
3
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
4
4
|
|
5
|
-
describe Location,
|
5
|
+
describe Location, 'when first created' do
|
6
6
|
before(:each) do
|
7
7
|
@io = StringIO.new
|
8
8
|
@location = Location.new(@io)
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
after(:each) do
|
12
|
+
@location = nil
|
13
|
+
@io = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'lists location matches for a term' do
|
12
17
|
@location.stub_chain(:open, :read) { fixture 'location.json' }
|
13
18
|
|
14
19
|
@location.find 'royston'
|
15
20
|
|
16
|
-
expect(
|
17
|
-
expect(
|
21
|
+
expect(@io.string).to include('Barnsley')
|
22
|
+
expect(@io.string).to include('2639017')
|
18
23
|
|
19
|
-
expect(
|
20
|
-
expect(
|
24
|
+
expect(@io.string).to include('Hertfordshire')
|
25
|
+
expect(@io.string).to include('2639018')
|
21
26
|
end
|
22
27
|
|
23
|
-
it
|
24
|
-
|
25
|
-
@location.find 'ky'
|
26
|
-
}.should raise_error(SystemExit)
|
27
|
-
|
28
|
-
#TODO: Check it emits "Please use a longer search term"
|
28
|
+
it 'warns when a term is too small' do
|
29
|
+
expect { @location.find 'ky' }.to raise_error('Please use a longer search term')
|
29
30
|
end
|
30
31
|
|
31
|
-
it
|
32
|
+
it 'explains when no results are found' do
|
33
|
+
@location.stub_chain(:open, :read) { '{}' }
|
34
|
+
|
35
|
+
@location.find 'Royston Vasey'
|
36
|
+
|
37
|
+
expect(@io.string).to include("No locations found matching 'Royston Vasey'")
|
32
38
|
end
|
33
39
|
|
34
|
-
it
|
40
|
+
it 'explains when it fails' do
|
35
41
|
@location.stub_chain(:open, :read) { 'corrupt { json' }
|
36
42
|
|
37
|
-
|
38
|
-
@location.find 'Royston Vasey'
|
39
|
-
rescue SystemExit
|
40
|
-
end
|
41
|
-
|
42
|
-
expect(@io.string).to end_with "Unable to download location data\n"
|
43
|
+
expect { @location.find 'Royston Vasey' }.to raise_error('Unable to download location data')
|
43
44
|
end
|
44
45
|
end
|
45
|
-
|
data/spec/bbc/news_spec.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__),
|
3
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
4
4
|
|
5
5
|
describe News do
|
6
|
-
|
7
6
|
before(:each) do
|
8
7
|
@io = StringIO.new
|
9
8
|
@news = News.new(@io)
|
@@ -14,35 +13,27 @@ describe News do
|
|
14
13
|
@io = nil
|
15
14
|
end
|
16
15
|
|
17
|
-
it
|
16
|
+
it 'shows the latest headlines' do
|
18
17
|
@news.stub(:console_columns).and_return(120)
|
19
18
|
@news.stub_chain(:open, :read) { fixture 'news.json' }
|
20
19
|
@news.load
|
21
20
|
|
22
|
-
expect(
|
23
|
-
expect(
|
21
|
+
expect(@io.string).to start_with 'BBC News Headlines'
|
22
|
+
expect(@io.string).to include "Police say Moscow school gunman has been 'neutralised'"
|
24
23
|
end
|
25
24
|
|
26
|
-
it
|
25
|
+
it 'explains when it fails' do
|
27
26
|
@news.stub_chain(:open, :read).and_return('corrupt { json')
|
28
27
|
|
29
|
-
|
30
|
-
@news.load
|
31
|
-
rescue SystemExit
|
32
|
-
end
|
33
|
-
|
34
|
-
#Unsure why this doesn't work with abort.
|
35
|
-
#expect(@news.load).to raise_error(SystemExit, "Unable to download news")
|
36
|
-
|
37
|
-
expect(@io.string).to end_with "Unable to download news\n"
|
28
|
+
expect { @news.load }.to raise_error('Unable to download news')
|
38
29
|
end
|
39
30
|
|
40
|
-
it
|
31
|
+
it 'truncates output to the size of the shell' do
|
41
32
|
@news.stub(:console_columns).and_return(80)
|
42
33
|
@news.stub_chain(:open, :read) { fixture 'news.json' }
|
43
34
|
|
44
35
|
@news.load
|
45
36
|
|
46
|
-
expect(
|
37
|
+
expect(@io.string).to end_with "in the last quarter. It put\n"
|
47
38
|
end
|
48
39
|
end
|
data/spec/bbc/now_next_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__),
|
3
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
4
4
|
|
5
5
|
describe NowNext do
|
6
6
|
before(:each) do
|
7
7
|
@io = StringIO.new
|
8
8
|
@nn = NowNext.new @io
|
9
9
|
|
10
|
-
@nn.stub(:time_now) { Time.at(
|
10
|
+
@nn.stub(:time_now) { Time.at(1_391_430_000) }
|
11
11
|
end
|
12
12
|
|
13
13
|
after(:each) do
|
@@ -16,7 +16,6 @@ describe NowNext do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "shows what's on tv now" do
|
19
|
-
#TODO: Mock Time
|
20
19
|
@nn.stub_chain(:open, :read) { fixture 'now_next_tv.json' }
|
21
20
|
@nn.tv_now
|
22
21
|
|
@@ -39,7 +38,7 @@ describe NowNext do
|
|
39
38
|
|
40
39
|
@nn.radio_now
|
41
40
|
|
42
|
-
expect(@io.string).to include
|
41
|
+
expect(@io.string).to include 'Fearne Cotton'
|
43
42
|
end
|
44
43
|
|
45
44
|
it "shows what's on radio next" do
|
@@ -50,4 +49,13 @@ describe NowNext do
|
|
50
49
|
expect(@io.string).to match(/40 mins\s+Radio 6 Music\s+Radcliffe and Maconie/)
|
51
50
|
expect(@io.string).to match(/5 hours\s+Radio 5 live sports extra\s+Coming up on 5 live sports extra/)
|
52
51
|
end
|
52
|
+
|
53
|
+
it 'explains when it fails' do
|
54
|
+
@nn.stub_chain(:open, :read) { 'corrupt { json' }
|
55
|
+
|
56
|
+
expect { @nn.radio_now }.to raise_error('Unable to download radio schedules')
|
57
|
+
expect { @nn.radio_next }.to raise_error('Unable to download radio schedules')
|
58
|
+
expect { @nn.tv_next }.to raise_error('Unable to download tv schedules')
|
59
|
+
expect { @nn.tv_now }.to raise_error('Unable to download tv schedules')
|
60
|
+
end
|
53
61
|
end
|
data/spec/bbc/schedule_spec.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__),
|
3
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
4
4
|
|
5
5
|
describe Schedule do
|
6
|
-
|
7
6
|
before(:each) do
|
8
7
|
@io = StringIO.new
|
9
8
|
@schedule = Schedule.new @io
|
10
|
-
@schedule.stub(:time_now).and_return(Time.at
|
9
|
+
@schedule.stub(:time_now).and_return(Time.at 1_391_435_797) # 13:56:37
|
11
10
|
end
|
12
11
|
|
13
12
|
after(:each) do
|
@@ -15,10 +14,10 @@ describe Schedule do
|
|
15
14
|
@schedule = nil
|
16
15
|
end
|
17
16
|
|
18
|
-
it
|
17
|
+
it 'lists todays schedule for BBC One' do
|
19
18
|
@schedule.stub_chain(:open, :read) { fixture 'schedule_tv.json' }
|
20
19
|
|
21
|
-
channel = { :
|
20
|
+
channel = { id: 'bbcone' }
|
22
21
|
@schedule.load channel
|
23
22
|
|
24
23
|
expect(@io.string).to include '13:45 Doctors'
|
@@ -26,19 +25,19 @@ describe Schedule do
|
|
26
25
|
expect(@io.string).to include '00:30 Joins BBC News'
|
27
26
|
end
|
28
27
|
|
29
|
-
it
|
28
|
+
it 'what is on now is the first in the list' do
|
30
29
|
@schedule.stub_chain(:open, :read) { fixture 'schedule_tv.json' }
|
31
30
|
|
32
|
-
channel = { :
|
31
|
+
channel = { id: 'bbcone' }
|
33
32
|
@schedule.load channel
|
34
33
|
|
35
34
|
expect(@io.string).to start_with "\e[92m13:45 Doctors"
|
36
35
|
end
|
37
36
|
|
38
|
-
it
|
37
|
+
it 'lists todays schedule for Radio Six Music' do
|
39
38
|
@schedule.stub_chain(:open, :read) { fixture 'schedule_radio_today.json' }
|
40
39
|
|
41
|
-
station = { :
|
40
|
+
station = { id: '6music' }
|
42
41
|
@schedule.load station
|
43
42
|
|
44
43
|
expect(@io.string).to include '13:00 Radcliffe and Maconie'
|
@@ -48,7 +47,7 @@ describe Schedule do
|
|
48
47
|
it "lists yesterday's schedule for Radio Six Music" do
|
49
48
|
@schedule.stub_chain(:open, :read) { fixture 'schedule_radio_yesterday.json' }
|
50
49
|
|
51
|
-
station = { :
|
50
|
+
station = { id: '6music', period: '/yesterday' }
|
52
51
|
@schedule.load station
|
53
52
|
|
54
53
|
expect(@io.string).to include '20:00 Stuart Maconie\'s Freak Zone'
|
@@ -57,7 +56,7 @@ describe Schedule do
|
|
57
56
|
it "lists tomorrow's schedule for Radio Six Music" do
|
58
57
|
@schedule.stub_chain(:open, :read) { fixture 'schedule_radio_tomorrow.json' }
|
59
58
|
|
60
|
-
station = { :
|
59
|
+
station = { id: '6music' }
|
61
60
|
@schedule.load station
|
62
61
|
|
63
62
|
expect(@io.string).to include '13:00 Radcliffe and Maconie'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
4
|
+
|
5
|
+
describe ShellCharacters, 'character conversion to symbols escaped for terminal output' do
|
6
|
+
it 'converts cardinal compass points to symbols' do
|
7
|
+
points = %w(N NE E SE S SW W NW)
|
8
|
+
symbols = %w(↑ ↗ → ↘ ↓ ↙ ← ↖)
|
9
|
+
|
10
|
+
points.zip(symbols).each do |p, s|
|
11
|
+
expect(ShellCharacters.symbol_for_compass(p)).to eq(s)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'converts ordinal compass points to symbols' do
|
16
|
+
points = %w(NE SE SW NW)
|
17
|
+
symbols = %w(↗ ↘ ↙ ↖)
|
18
|
+
|
19
|
+
points.zip(symbols).each do |p, s|
|
20
|
+
expect(ShellCharacters.symbol_for_compass(p)).to eq(s)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'rounds secondary intercardinal points to the closest cardinal' do
|
25
|
+
points = %w(NNE ENE ESE SSE SSW WSW WNW NNW)
|
26
|
+
symbols = %w( ↑ → → ↓ ↓ ← ← ↑)
|
27
|
+
|
28
|
+
points.zip(symbols).each do |p, s|
|
29
|
+
expect(ShellCharacters.symbol_for_compass(p)).to eq(s)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'defaults to north when a compass point description is not recognised' do
|
35
|
+
expect(ShellCharacters.symbol_for_compass('')).to eq('↑')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'has degrees centigrade' do
|
39
|
+
expect(ShellCharacters.degrees_c).to eq('°C')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'has degrees farenheit' do
|
43
|
+
expect(ShellCharacters.degrees_f).to eq('°F')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'draws blocks' do
|
47
|
+
expect(ShellCharacters.square_block).to eq('█')
|
48
|
+
end
|
49
|
+
end
|
data/spec/bbc/sport_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__),
|
3
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
4
4
|
|
5
5
|
describe Sport do
|
6
6
|
before(:each) do
|
@@ -13,23 +13,18 @@ describe Sport do
|
|
13
13
|
@io = nil
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'shows the latest headlines' do
|
17
17
|
@sport.stub_chain(:open, :read) { fixture 'sport.json' }
|
18
18
|
@sport.headlines
|
19
19
|
|
20
|
-
expect(
|
21
|
-
expect(
|
22
|
-
expect(
|
20
|
+
expect(@io.string).to include 'Winter olympics'
|
21
|
+
expect(@io.string).to include 'Leeds boss'
|
22
|
+
expect(@io.string).to include 'American football'
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it 'explains when it fails' do
|
26
26
|
@sport.stub_chain(:open, :read) { 'corrupt { json' }
|
27
27
|
|
28
|
-
|
29
|
-
@sport.headlines
|
30
|
-
rescue SystemExit
|
31
|
-
end
|
32
|
-
|
33
|
-
expect(@io.string).to end_with "Unable to download sport\n"
|
28
|
+
expect { @sport.headlines }.to raise_error 'Unable to download sport data'
|
34
29
|
end
|
35
30
|
end
|
data/spec/bbc/version_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__),
|
3
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
4
4
|
|
5
|
-
describe AUNTIE,
|
6
|
-
it
|
5
|
+
describe AUNTIE, 'when asked' do
|
6
|
+
it 'provides a human readable name for the application' do
|
7
7
|
AUNTIE::NAME.should_not be_nil
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'shows the semantic version of the application' do
|
11
11
|
AUNTIE::VERSION.should =~ /\d+\.\d+\.\d+/
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'has a user agent which includes the application name and version' do
|
15
15
|
AUNTIE::USER_AGENT.should =~ /\d+\.\d+\.\d+/
|
16
16
|
AUNTIE::USER_AGENT.should =~ /#{AUNTIE::NAME}/
|
17
17
|
end
|
data/spec/bbc/weather_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__),
|
3
|
+
require File.join(File.dirname(__FILE__), '/../spec_helper')
|
4
4
|
|
5
5
|
describe Weather do
|
6
6
|
before(:each) do
|
@@ -13,29 +13,23 @@ describe Weather do
|
|
13
13
|
@io = nil
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'shows the hourly forecast' do
|
17
17
|
@weather.stub_chain(:open, :read) { fixture '3hourlyforecast.json' }
|
18
18
|
@weather.hourly
|
19
19
|
|
20
|
-
expect(
|
20
|
+
expect(@io.string).to start_with "\nThe next 24 hours in SE1"
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'shows the daily forecast' do
|
24
24
|
@weather.stub_chain(:open, :read) { fixture '3dayforecast.json' }
|
25
25
|
@weather.daily
|
26
26
|
|
27
|
-
expect(
|
27
|
+
expect(@io.string).to start_with "\nThe next 3 days in London"
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
30
|
+
it 'explains when it fails' do
|
31
31
|
@weather.stub_chain(:open, :read) { 'corrupt } json {' }
|
32
32
|
|
33
|
-
|
34
|
-
@weather.hourly
|
35
|
-
rescue SystemExit
|
36
|
-
end
|
37
|
-
|
38
|
-
expect(@io.string).to end_with "Unable to download the weather\n"
|
33
|
+
expect { @weather.hourly }.to raise_error 'Unable to download the weather'
|
39
34
|
end
|
40
|
-
|
41
35
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
$LOAD_PATH.push File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
$LOAD_PATH.push File.dirname(__FILE__)
|
5
|
+
|
6
|
+
require 'coveralls'
|
7
|
+
Coveralls.wear!
|
8
|
+
|
9
|
+
# require 'simplecov'
|
10
|
+
# SimpleCov.start
|
5
11
|
|
6
12
|
require 'auntie'
|
7
13
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auntie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Gregory
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description: BBC News, Weather, Sport, and TV & Radio schedules right in your shell
|
84
84
|
email: simon.gregory@bbc.co.uk
|
85
85
|
executables:
|
86
86
|
- weather
|
@@ -88,9 +88,11 @@ executables:
|
|
88
88
|
- radio
|
89
89
|
- news
|
90
90
|
- sport
|
91
|
+
- auntie
|
91
92
|
extensions: []
|
92
93
|
extra_rdoc_files: []
|
93
94
|
files:
|
95
|
+
- bin/auntie
|
94
96
|
- bin/news
|
95
97
|
- bin/radio
|
96
98
|
- bin/sport
|
@@ -123,10 +125,13 @@ files:
|
|
123
125
|
- LICENSE
|
124
126
|
- Rakefile
|
125
127
|
- README.md
|
128
|
+
- spec/bbc/colors_spec.rb
|
129
|
+
- spec/bbc/describe_time_spec.rb
|
126
130
|
- spec/bbc/location_spec.rb
|
127
131
|
- spec/bbc/news_spec.rb
|
128
132
|
- spec/bbc/now_next_spec.rb
|
129
133
|
- spec/bbc/schedule_spec.rb
|
134
|
+
- spec/bbc/shell_symbols_spec.rb
|
130
135
|
- spec/bbc/sport_spec.rb
|
131
136
|
- spec/bbc/version_spec.rb
|
132
137
|
- spec/bbc/weather_spec.rb
|