auntie 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +49 -0
- data/LICENSE +20 -0
- data/README.md +39 -0
- data/Rakefile +24 -0
- data/bin/news +4 -0
- data/bin/radio +51 -0
- data/bin/sport +4 -0
- data/bin/tv +45 -0
- data/bin/weather +23 -0
- data/features/location.feature +8 -0
- data/features/news.feature +8 -0
- data/features/radio.feature +8 -0
- data/features/sport.feature +8 -0
- data/features/step_definitions/location_steps.rb +7 -0
- data/features/step_definitions/radio_steps.rb +1 -0
- data/features/step_definitions/tv_steps.rb +1 -0
- data/features/step_definitions/weather_steps.rb +6 -0
- data/features/support/env.rb +15 -0
- data/features/tv.feature +8 -0
- data/features/weather.feature +8 -0
- data/lib/auntie.rb +16 -0
- data/lib/bbc/location.rb +44 -0
- data/lib/bbc/news.rb +28 -0
- data/lib/bbc/now_next.rb +93 -0
- data/lib/bbc/schedule.rb +53 -0
- data/lib/bbc/shell/characters.rb +68 -0
- data/lib/bbc/shell/colors.rb +39 -0
- data/lib/bbc/shell/describe_time.rb +20 -0
- data/lib/bbc/sport.rb +33 -0
- data/lib/bbc/version.rb +7 -0
- data/lib/bbc/weather.rb +98 -0
- data/scratch +9 -0
- data/spec/bbc/location_spec.rb +45 -0
- data/spec/bbc/news_spec.rb +43 -0
- data/spec/bbc/now_next_spec.rb +53 -0
- data/spec/bbc/schedule_spec.rb +56 -0
- data/spec/bbc/sport_spec.rb +35 -0
- data/spec/bbc/version_spec.rb +18 -0
- data/spec/bbc/weather_spec.rb +41 -0
- data/spec/fixtures/3dayforecast.json +149 -0
- data/spec/fixtures/3hourlyforecast.json +265 -0
- data/spec/fixtures/location.json +12 -0
- data/spec/fixtures/news.json +31 -0
- data/spec/fixtures/now_next_radio.json +7767 -0
- data/spec/fixtures/now_next_tv.json +3471 -0
- data/spec/fixtures/schedule_radio_today.json +939 -0
- data/spec/fixtures/schedule_radio_tomorrow.json +941 -0
- data/spec/fixtures/schedule_radio_yesterday.json +1118 -0
- data/spec/fixtures/schedule_tv.json +1695 -0
- data/spec/fixtures/sport.json +38 -0
- data/spec/spec_helper.rb +13 -0
- metadata +170 -0
data/scratch
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
4
|
+
|
5
|
+
describe Location, "when first created" do
|
6
|
+
before(:each) do
|
7
|
+
@io = StringIO.new
|
8
|
+
@location = Location.new(@io)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "lists location matches for a term" do
|
12
|
+
@location.stub_chain(:open, :read) { fixture 'location.json' }
|
13
|
+
|
14
|
+
@location.find 'royston'
|
15
|
+
|
16
|
+
expect( @io.string ).to include('Barnsley')
|
17
|
+
expect( @io.string ).to include('2639017')
|
18
|
+
|
19
|
+
expect( @io.string ).to include('Hertfordshire')
|
20
|
+
expect( @io.string ).to include('2639018')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "warns when a term is too small" do
|
24
|
+
lambda {
|
25
|
+
@location.find 'ky'
|
26
|
+
}.should raise_error(SystemExit)
|
27
|
+
|
28
|
+
#TODO: Check it emits "Please use a longer search term"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "explains when no results are found" do
|
32
|
+
end
|
33
|
+
|
34
|
+
it "explains when it fails" do
|
35
|
+
@location.stub_chain(:open, :read) { 'corrupt { json' }
|
36
|
+
|
37
|
+
begin
|
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
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
4
|
+
|
5
|
+
describe News do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@io = StringIO.new
|
9
|
+
@news = News.new(@io)
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
@news = nil
|
14
|
+
@io = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "shows the latest headlines" do
|
18
|
+
@news.stub_chain(:open, :read) { fixture 'news.json' }
|
19
|
+
@news.load
|
20
|
+
|
21
|
+
expect( @io.string ).to start_with 'BBC News Headlines'
|
22
|
+
expect( @io.string ).to include "Police say Moscow school gunman has been 'neutralised'"
|
23
|
+
expect( @io.string ).to end_with "It puts the loss down to cheaper fares and weaker sterling.\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "explains when it fails" do
|
27
|
+
@news.stub_chain(:open, :read) { 'corrupt { json' }
|
28
|
+
|
29
|
+
begin
|
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"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "truncates output to the size of the shell" do
|
41
|
+
#
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
4
|
+
|
5
|
+
describe NowNext do
|
6
|
+
before(:each) do
|
7
|
+
@io = StringIO.new
|
8
|
+
@nn = NowNext.new @io
|
9
|
+
|
10
|
+
@nn.stub(:time_now) { Time.at(1391430000) }
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:each) do
|
14
|
+
@io = nil
|
15
|
+
@nn = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "shows what's on tv now" do
|
19
|
+
#TODO: Mock Time
|
20
|
+
@nn.stub_chain(:open, :read) { fixture 'now_next_tv.json' }
|
21
|
+
@nn.tv_now
|
22
|
+
|
23
|
+
expect(@io.string).to include 'Saints and Scroungers'
|
24
|
+
expect(@io.string).to include 'Arthur'
|
25
|
+
expect(@io.string).to include 'Seo Alba (This is Alba)'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "shows what's on tv next" do
|
29
|
+
@nn.stub_chain(:open, :read) { fixture 'now_next_tv.json' }
|
30
|
+
|
31
|
+
@nn.tv_next
|
32
|
+
|
33
|
+
expect(@io.string).to match(/On now\s+One\s+Bargain Hunt/)
|
34
|
+
expect(@io.string).to match(/6 hours\s+Three\s+Great Movie Mistakes/)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "shows what's on radio now" do
|
38
|
+
@nn.stub_chain(:open, :read) { fixture 'now_next_radio.json' }
|
39
|
+
|
40
|
+
@nn.radio_now
|
41
|
+
|
42
|
+
expect(@io.string).to include "Fearne Cotton"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "shows what's on radio next" do
|
46
|
+
@nn.stub_chain(:open, :read) { fixture 'now_next_radio.json' }
|
47
|
+
|
48
|
+
@nn.radio_next
|
49
|
+
|
50
|
+
expect(@io.string).to match(/40 mins\s+Radio 6 Music\s+Radcliffe and Maconie/)
|
51
|
+
expect(@io.string).to match(/5 hours\s+Radio 5 live sports extra\s+Coming up on 5 live sports extra/)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
4
|
+
|
5
|
+
describe Schedule do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@io = StringIO.new
|
9
|
+
@schedule = Schedule.new @io
|
10
|
+
@schedule.stub(:time_now) { Time.at 1391435797 }
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:each) do
|
14
|
+
@io = nil
|
15
|
+
@schedule = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "lists todays schedule for BBC One" do
|
19
|
+
@schedule.stub_chain(:open, :read) { fixture 'schedule_tv.json' }
|
20
|
+
|
21
|
+
channel = { :id => "bbcone" }
|
22
|
+
@schedule.load channel
|
23
|
+
|
24
|
+
expect(@io.string).to include '13:45 Doctors'
|
25
|
+
expect(@io.string).to include '23:40 The Graham Norton Show'
|
26
|
+
expect(@io.string).to include '00:30 Joins BBC News'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "lists todays schedule for Radio Six Musix" do
|
30
|
+
@schedule.stub_chain(:open, :read) { fixture 'schedule_radio_today.json' }
|
31
|
+
|
32
|
+
station = { :id => "6music" }
|
33
|
+
@schedule.load station
|
34
|
+
|
35
|
+
expect(@io.string).to include '13:00 Radcliffe and Maconie'
|
36
|
+
expect(@io.string).to include '05:00 Chris Hawkins'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "lists yesterday's schedule for Radio Six Music" do
|
40
|
+
@schedule.stub_chain(:open, :read) { fixture 'schedule_radio_yesterday.json' }
|
41
|
+
|
42
|
+
station = { :id => "6music" }
|
43
|
+
@schedule.load station
|
44
|
+
|
45
|
+
expect(@io.string).to include '20:00 Stuart Maconie\'s Freak Zone'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "lists tomorrow's schedule for Radio Six Music" do
|
49
|
+
@schedule.stub_chain(:open, :read) { fixture 'schedule_radio_tomorrow.json' }
|
50
|
+
|
51
|
+
station = { :id => "6music" }
|
52
|
+
@schedule.load station
|
53
|
+
|
54
|
+
expect(@io.string).to include '13:00 Radcliffe and Maconie'
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
4
|
+
|
5
|
+
describe Sport do
|
6
|
+
before(:each) do
|
7
|
+
@io = StringIO.new
|
8
|
+
@sport = Sport.new(@io)
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:each) do
|
12
|
+
@sport = nil
|
13
|
+
@io = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it "shows the latest headlines" do
|
17
|
+
@sport.stub_chain(:open, :read) { fixture 'sport.json' }
|
18
|
+
@sport.headlines
|
19
|
+
|
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
|
+
end
|
24
|
+
|
25
|
+
it "explains when it fails" do
|
26
|
+
@sport.stub_chain(:open, :read) { 'corrupt { json' }
|
27
|
+
|
28
|
+
begin
|
29
|
+
@sport.headlines
|
30
|
+
rescue SystemExit
|
31
|
+
end
|
32
|
+
|
33
|
+
expect(@io.string).to end_with "Unable to download sport\n"
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
4
|
+
|
5
|
+
describe AUNTIE, "when asked" do
|
6
|
+
it "provides a human readable name for the application" do
|
7
|
+
AUNTIE::NAME.should_not be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "shows the semantic version of the application" do
|
11
|
+
AUNTIE::VERSION.should =~ /\d+\.\d+\.\d+/
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has a user agent which includes the application name and version" do
|
15
|
+
AUNTIE::USER_AGENT.should =~ /\d+\.\d+\.\d+/
|
16
|
+
AUNTIE::USER_AGENT.should =~ /#{AUNTIE::NAME}/
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
4
|
+
|
5
|
+
describe Weather do
|
6
|
+
before(:each) do
|
7
|
+
@io = StringIO.new
|
8
|
+
@weather = Weather.new('w3', @io)
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:each) do
|
12
|
+
@weather = nil
|
13
|
+
@io = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it "shows the hourly forecast" do
|
17
|
+
@weather.stub_chain(:open, :read) { fixture '3hourlyforecast.json' }
|
18
|
+
@weather.hourly
|
19
|
+
|
20
|
+
expect( @io.string ).to start_with "\nThe next 24 hours in SE1"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "shows the daily forecast" do
|
24
|
+
@weather.stub_chain(:open, :read) { fixture '3dayforecast.json' }
|
25
|
+
@weather.daily
|
26
|
+
|
27
|
+
expect( @io.string ).to start_with "\nThe next 3 days in London"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "explains when it fails" do
|
31
|
+
@weather.stub_chain(:open, :read) { 'corrupt } json {' }
|
32
|
+
|
33
|
+
begin
|
34
|
+
@weather.hourly
|
35
|
+
rescue SystemExit
|
36
|
+
end
|
37
|
+
|
38
|
+
expect(@io.string).to end_with "Unable to download the weather\n"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
{
|
2
|
+
"forecastContent": {
|
3
|
+
"forecasts": [
|
4
|
+
{
|
5
|
+
"date": "2014-02-03T00:00:00.000Z",
|
6
|
+
"day": {
|
7
|
+
"humidityPercent": 72,
|
8
|
+
"maxTemperature": {
|
9
|
+
"centigrade": 9,
|
10
|
+
"fahrenheit": 48
|
11
|
+
},
|
12
|
+
"pressureMillibars": 1004,
|
13
|
+
"sunrise": "2014-02-03T07:36:00Z",
|
14
|
+
"visibility": "Good",
|
15
|
+
"weatherCode": 3,
|
16
|
+
"weatherSymbol": {
|
17
|
+
"mobile": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/3.gif",
|
18
|
+
"webMedium": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_56_icons/en_on_light_bg/3.gif",
|
19
|
+
"webSmall": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/3.gif"
|
20
|
+
},
|
21
|
+
"weatherType": "Sunny Intervals",
|
22
|
+
"wind": {
|
23
|
+
"direction": "SSE",
|
24
|
+
"directionDesc": "South South Easterly",
|
25
|
+
"windspeed": {
|
26
|
+
"kph": 23,
|
27
|
+
"mph": 14
|
28
|
+
}
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"dayName": "Monday",
|
32
|
+
"dayNameAbbreviation": "Mon",
|
33
|
+
"night": {
|
34
|
+
"minTemperature": {
|
35
|
+
"centigrade": 4,
|
36
|
+
"fahrenheit": 39
|
37
|
+
},
|
38
|
+
"sunset": "2014-02-03T16:53:00Z",
|
39
|
+
"weatherCode": 2,
|
40
|
+
"weatherSymbol": {
|
41
|
+
"mobile": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/2.gif",
|
42
|
+
"webMedium": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_56_icons/en_on_light_bg/2.gif",
|
43
|
+
"webSmall": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/2.gif"
|
44
|
+
},
|
45
|
+
"weatherType": "Partly Cloudy"
|
46
|
+
}
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"date": "2014-02-04T00:00:00.000Z",
|
50
|
+
"day": {
|
51
|
+
"humidityPercent": 75,
|
52
|
+
"maxTemperature": {
|
53
|
+
"centigrade": 9,
|
54
|
+
"fahrenheit": 48
|
55
|
+
},
|
56
|
+
"pressureMillibars": 1003,
|
57
|
+
"sunrise": "2014-02-04T07:35:00Z",
|
58
|
+
"visibility": "Good",
|
59
|
+
"weatherCode": 3,
|
60
|
+
"weatherSymbol": {
|
61
|
+
"mobile": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/3.gif",
|
62
|
+
"webMedium": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_56_icons/en_on_light_bg/3.gif",
|
63
|
+
"webSmall": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/3.gif"
|
64
|
+
},
|
65
|
+
"weatherType": "Sunny Intervals",
|
66
|
+
"wind": {
|
67
|
+
"direction": "S",
|
68
|
+
"directionDesc": "Southerly",
|
69
|
+
"windspeed": {
|
70
|
+
"kph": 21,
|
71
|
+
"mph": 13
|
72
|
+
}
|
73
|
+
}
|
74
|
+
},
|
75
|
+
"dayName": "Tuesday",
|
76
|
+
"dayNameAbbreviation": "Tue",
|
77
|
+
"night": {
|
78
|
+
"minTemperature": {
|
79
|
+
"centigrade": 5,
|
80
|
+
"fahrenheit": 41
|
81
|
+
},
|
82
|
+
"sunset": "2014-02-04T16:55:00Z",
|
83
|
+
"weatherCode": 12,
|
84
|
+
"weatherSymbol": {
|
85
|
+
"mobile": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/12.gif",
|
86
|
+
"webMedium": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_56_icons/en_on_light_bg/12.gif",
|
87
|
+
"webSmall": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/12.gif"
|
88
|
+
},
|
89
|
+
"weatherType": "Light Rain"
|
90
|
+
}
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"date": "2014-02-05T00:00:00.000Z",
|
94
|
+
"day": {
|
95
|
+
"humidityPercent": 76,
|
96
|
+
"maxTemperature": {
|
97
|
+
"centigrade": 10,
|
98
|
+
"fahrenheit": 50
|
99
|
+
},
|
100
|
+
"pressureMillibars": 983,
|
101
|
+
"sunrise": "2014-02-05T07:33:00Z",
|
102
|
+
"visibility": "Moderate",
|
103
|
+
"weatherCode": 15,
|
104
|
+
"weatherSymbol": {
|
105
|
+
"mobile": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/15.gif",
|
106
|
+
"webMedium": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_56_icons/en_on_light_bg/15.gif",
|
107
|
+
"webSmall": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/15.gif"
|
108
|
+
},
|
109
|
+
"weatherType": "Heavy Rain",
|
110
|
+
"wind": {
|
111
|
+
"direction": "S",
|
112
|
+
"directionDesc": "Southerly",
|
113
|
+
"windspeed": {
|
114
|
+
"kph": 34,
|
115
|
+
"mph": 21
|
116
|
+
}
|
117
|
+
}
|
118
|
+
},
|
119
|
+
"dayName": "Wednesday",
|
120
|
+
"dayNameAbbreviation": "Wed",
|
121
|
+
"night": {
|
122
|
+
"minTemperature": {
|
123
|
+
"centigrade": 6,
|
124
|
+
"fahrenheit": 43
|
125
|
+
},
|
126
|
+
"sunset": "2014-02-05T16:57:00Z",
|
127
|
+
"weatherCode": 7,
|
128
|
+
"weatherSymbol": {
|
129
|
+
"mobile": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/7.gif",
|
130
|
+
"webMedium": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_56_icons/en_on_light_bg/7.gif",
|
131
|
+
"webSmall": "http://static.bbci.co.uk/weather/0.5.265/images/icons/individual_40_icons/en_on_light_bg/7.gif"
|
132
|
+
},
|
133
|
+
"weatherType": "Light Cloud"
|
134
|
+
}
|
135
|
+
}
|
136
|
+
],
|
137
|
+
"location": {
|
138
|
+
"continent": null,
|
139
|
+
"country": "United Kingdom",
|
140
|
+
"county": null,
|
141
|
+
"id": "2643743",
|
142
|
+
"latitude": "51.521",
|
143
|
+
"locationName": "London",
|
144
|
+
"longitude": "-0.108",
|
145
|
+
"state": null,
|
146
|
+
"timezoneName": "Europe/London"
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|