auntie 0.1.0 → 0.2.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.lock +1 -1
- data/README.md +11 -7
- data/Rakefile +51 -2
- data/bin/news +5 -0
- data/bin/sport +5 -0
- data/bin/weather +23 -5
- data/features/step_definitions/location_steps.rb +2 -2
- data/lib/auntie.rb +2 -1
- data/lib/bbc/news.rb +5 -2
- data/lib/bbc/now_next.rb +1 -2
- data/lib/bbc/schedule.rb +4 -5
- data/lib/bbc/version.rb +1 -1
- data/lib/bbc/weather.rb +3 -3
- data/spec/bbc/news_spec.rb +8 -3
- data/spec/bbc/schedule_spec.rb +11 -2
- metadata +6 -6
- data/scratch +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fed4976f396372cbd6c5b4c71ced8a439b06f6a6
|
4
|
+
data.tar.gz: 6713d54954ef44ba9326eb15995c7a7b8788d05b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7365a73fb95203fe90a2af2d1533207f118f8a0ce251a6a0f0d2f9e1491f9daba0a77746034833fd4478178b443a8ef9308879c96f507b9480e2ef34861638d
|
7
|
+
data.tar.gz: d02f68b2fb542075f5f1723ae713c42a36964ae49affada31992e947da2c854313caf81366e86aef620d84ab8a6d36cacf8da43dc723ae6305a0e56542653fc6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# Auntie
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/simongregory/auntie)
|
4
|
+
[](https://codeclimate.com/github/simongregory/auntie)
|
4
5
|
|
5
|
-
|
6
|
+
A Ruby Gem for accessing [BBC]() Weather, TV, Radio, News and Sport feeds.
|
7
|
+
|
8
|
+
## Install
|
6
9
|
|
7
10
|
gem install auntie
|
8
11
|
|
9
|
-
|
12
|
+
## Use
|
10
13
|
|
11
14
|
weather # lists the weather for the next 24 hours
|
12
15
|
|
@@ -22,18 +25,19 @@ A Ruby Gem for accessing [BBC]() weather, tv, radio, news and sport feeds.
|
|
22
25
|
|
23
26
|
sport # the latest sport headlines
|
24
27
|
|
25
|
-
|
28
|
+
## zsh integration
|
26
29
|
|
27
|
-
|
30
|
+
[zsh][] shell completion can be added to the `tv`, `radio` and `weather` tools. Radio, for example, can be enabled by creating a file called `_radio` with the following contents:
|
28
31
|
|
29
32
|
#compdef radio
|
30
33
|
compadd `radio help -c`
|
31
34
|
|
32
|
-
and source it via your .zshrc file.
|
35
|
+
and source it via your .zshrc file.
|
33
36
|
|
34
|
-
|
37
|
+
## Licence
|
35
38
|
|
36
39
|
[MIT][], see accomanying [LICENSE](LICENSE) document
|
37
40
|
|
38
41
|
[BBC]: http://www.bbc.co.uk/
|
39
42
|
[MIT]: http://opensource.org/licenses/MIT
|
43
|
+
[zsh]: http://zsh.sourceforge.net
|
data/Rakefile
CHANGED
@@ -8,9 +8,21 @@ require 'cucumber/rake/task'
|
|
8
8
|
|
9
9
|
CLEAN << 'tmp'
|
10
10
|
|
11
|
+
#############################################################################
|
12
|
+
#
|
13
|
+
# Test tasks
|
14
|
+
#
|
15
|
+
#############################################################################
|
16
|
+
|
17
|
+
desc 'Run features and generate HTML report'
|
18
|
+
Cucumber::Rake::Task.new(:features_html) do |t|
|
19
|
+
t.cucumber_opts = "features --format html -o results.html --format progress -x"
|
20
|
+
t.fork = false
|
21
|
+
end
|
22
|
+
|
11
23
|
desc 'Run features'
|
12
24
|
Cucumber::Rake::Task.new(:features) do |t|
|
13
|
-
t.cucumber_opts = "features --format
|
25
|
+
t.cucumber_opts = "features --format progress -x"
|
14
26
|
t.fork = false
|
15
27
|
end
|
16
28
|
|
@@ -19,6 +31,43 @@ RSpec::Core::RakeTask.new(:spec) do |t|
|
|
19
31
|
t.rspec_opts = %w[--color]
|
20
32
|
end
|
21
33
|
|
22
|
-
|
34
|
+
#############################################################################
|
35
|
+
#
|
36
|
+
# Packaging tasks
|
37
|
+
#
|
38
|
+
#############################################################################
|
39
|
+
|
40
|
+
gem_name = AUNTIE::NAME
|
41
|
+
gem_version = AUNTIE::VERSION
|
42
|
+
|
43
|
+
desc "Build, tag and release the gem"
|
44
|
+
task :release do
|
45
|
+
puts ""
|
46
|
+
print "Are you sure you want to release #{gem_name} #{gem_version}? [y/N] "
|
47
|
+
exit unless STDIN.gets.index(/y/i) == 0
|
23
48
|
|
49
|
+
unless `git branch` =~ /^\* master$/
|
50
|
+
puts "You must be on the master branch to release!"
|
51
|
+
exit!
|
52
|
+
end
|
53
|
+
|
54
|
+
# Build gem and upload
|
55
|
+
sh "gem build #{gem_name}.gemspec"
|
56
|
+
sh "gem push #{gem_name}-#{gem_version}.gem"
|
57
|
+
sh "rm #{gem_name}-#{gem_version}.gem"
|
58
|
+
|
59
|
+
# Commit
|
60
|
+
sh "git commit --allow-empty -a -m 'v#{gem_version}'"
|
61
|
+
sh "git tag v#{gem_version}"
|
62
|
+
sh "git push origin master"
|
63
|
+
sh "git push origin v#{gem_version}"
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Build and install the gem"
|
67
|
+
task :install do
|
68
|
+
sh "gem build #{gem_name}.gemspec"
|
69
|
+
sh "gem install #{gem_name}-#{gem_version}.gem"
|
70
|
+
end
|
71
|
+
|
72
|
+
task :t => [:spec]
|
24
73
|
task :default => [:spec, :features]
|
data/bin/news
CHANGED
data/bin/sport
CHANGED
data/bin/weather
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'auntie'
|
3
3
|
|
4
|
+
if ARGV[0] == 'help' && ARGV[1] == '-c'
|
5
|
+
puts "--location-search\n--hourly\n--daily" #loc-search doesn't seem to be compatible with zsh completion?
|
6
|
+
exit
|
7
|
+
end
|
8
|
+
|
4
9
|
if ['help', '-h', '--help'].include? ARGV[0]
|
5
10
|
puts 'Useage: weather <Postcode or BBC location id>'
|
6
|
-
puts ' '
|
7
|
-
puts
|
11
|
+
puts ' --location-search <place>'
|
12
|
+
puts ' --hourly <Postcode or BBC location id>'
|
13
|
+
puts ' --daily <Postcode or BBC location id>'
|
8
14
|
exit
|
9
15
|
end
|
10
16
|
|
11
|
-
if ARGV[0] == '
|
17
|
+
if ARGV[0] == '--location-search'
|
12
18
|
place = ARGV[1..-1].join(' ')
|
13
19
|
|
14
20
|
abort "Please specify a location to search for." if place.empty?
|
@@ -18,6 +24,18 @@ if ARGV[0] == 'loc'
|
|
18
24
|
exit
|
19
25
|
end
|
20
26
|
|
21
|
-
location
|
27
|
+
def location
|
28
|
+
ARGV[0] ||= '2643743' #Default to London.
|
29
|
+
end
|
30
|
+
|
31
|
+
action = ARGV[0]
|
22
32
|
|
23
|
-
|
33
|
+
if action == '--daily'
|
34
|
+
ARGV.shift
|
35
|
+
Weather.new(location).daily
|
36
|
+
elsif action == '--hourly'
|
37
|
+
ARGV.shift
|
38
|
+
Weather.new(location).hourly
|
39
|
+
else
|
40
|
+
Weather.new(location).hourly
|
41
|
+
end
|
data/lib/auntie.rb
CHANGED
data/lib/bbc/news.rb
CHANGED
@@ -6,8 +6,7 @@ class News
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def load
|
9
|
-
cols =
|
10
|
-
|
9
|
+
cols = console_columns
|
11
10
|
@io.puts 'BBC News Headlines'
|
12
11
|
data['entries'].each { |news_item|
|
13
12
|
@io.puts news_item['headline'][0..cols-1]
|
@@ -25,4 +24,8 @@ class News
|
|
25
24
|
exit
|
26
25
|
end
|
27
26
|
end
|
27
|
+
|
28
|
+
def console_columns
|
29
|
+
IO.console.winsize[1]
|
30
|
+
end
|
28
31
|
end
|
data/lib/bbc/now_next.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
class NowNext
|
4
|
-
def initialize(io=
|
4
|
+
def initialize(io=STDOUT)
|
5
5
|
@io = io
|
6
6
|
end
|
7
7
|
|
@@ -80,7 +80,6 @@ class NowNext
|
|
80
80
|
programmes.sort_by! { |p| p.starts }
|
81
81
|
|
82
82
|
programmes.each { |p| @io.puts sprintf "%-#{first}s %-#{second}s %s", p.starts_in, p.channel, p.title }
|
83
|
-
|
84
83
|
end
|
85
84
|
|
86
85
|
def format_channel name
|
data/lib/bbc/schedule.rb
CHANGED
@@ -16,27 +16,26 @@ class Schedule
|
|
16
16
|
period = channel[:period] ||= ''
|
17
17
|
|
18
18
|
url = "http://www.bbc.co.uk/#{station}/programmes/schedules#{region}#{period}.json"
|
19
|
-
|
20
19
|
raw = open(url, 'UserAgent' => AUNTIE::USER_AGENT).read
|
21
20
|
data = JSON.parse(raw)
|
22
21
|
|
23
|
-
list data
|
22
|
+
list data, period
|
24
23
|
end
|
25
24
|
|
26
|
-
def list data
|
25
|
+
def list data, period
|
27
26
|
now = time_now
|
28
27
|
|
29
28
|
data['schedule']['day']['broadcasts'].each do |e|
|
30
29
|
|
31
30
|
ends = Time.parse(e['end'])
|
31
|
+
next if ends < now unless period == '/yesterday'
|
32
32
|
|
33
33
|
title = e['programme']['display_titles']['title']
|
34
34
|
#synopsis = e['programme']['short_synopsis']
|
35
35
|
|
36
36
|
starts = Time.parse(e['start'])
|
37
37
|
|
38
|
-
starts_at = starts.strftime("%H:%M")
|
39
|
-
#starts_at = starts.strftime("%I:%M%P")
|
38
|
+
starts_at = starts.strftime("%H:%M") # "%I:%M%P"
|
40
39
|
desc = "#{starts_at} #{title}"
|
41
40
|
|
42
41
|
if (starts < now) && (ends > now)
|
data/lib/bbc/version.rb
CHANGED
data/lib/bbc/weather.rb
CHANGED
@@ -48,7 +48,7 @@ class Weather
|
|
48
48
|
location = feed['forecastContent']['location']['locationName']
|
49
49
|
|
50
50
|
@io.puts "\nThe next 3 days in #{location}\n\n"
|
51
|
-
@io.puts "Day
|
51
|
+
@io.puts "Day Weather Max#{degrees_c} Wind"
|
52
52
|
|
53
53
|
feed['forecastContent']['forecasts'].each { |e|
|
54
54
|
day = sprintf "%-10s", e['dayName']
|
@@ -69,9 +69,9 @@ class Weather
|
|
69
69
|
n_temp = e['night']['minTemperature']['centigrade']
|
70
70
|
n_temp = "#{n_temp}\xC2\xB0C" unless n_temp.nil?
|
71
71
|
|
72
|
-
night_desc = sprintf "%-
|
72
|
+
night_desc = sprintf "%-17s %-3s", n_weather, n_temp
|
73
73
|
|
74
|
-
@io.puts "#{yellow day} #{day_desc} #{cyan '
|
74
|
+
@io.puts "#{yellow day} #{day_desc} #{cyan 'Night'} #{white night_desc}"
|
75
75
|
}
|
76
76
|
end
|
77
77
|
|
data/spec/bbc/news_spec.rb
CHANGED
@@ -15,16 +15,16 @@ describe News do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "shows the latest headlines" do
|
18
|
+
@news.stub(:console_columns).and_return(120)
|
18
19
|
@news.stub_chain(:open, :read) { fixture 'news.json' }
|
19
20
|
@news.load
|
20
21
|
|
21
22
|
expect( @io.string ).to start_with 'BBC News Headlines'
|
22
23
|
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
24
|
end
|
25
25
|
|
26
26
|
it "explains when it fails" do
|
27
|
-
@news.stub_chain(:open, :read)
|
27
|
+
@news.stub_chain(:open, :read).and_return('corrupt { json')
|
28
28
|
|
29
29
|
begin
|
30
30
|
@news.load
|
@@ -38,6 +38,11 @@ describe News do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "truncates output to the size of the shell" do
|
41
|
-
|
41
|
+
@news.stub(:console_columns).and_return(80)
|
42
|
+
@news.stub_chain(:open, :read) { fixture 'news.json' }
|
43
|
+
|
44
|
+
@news.load
|
45
|
+
|
46
|
+
expect( @io.string ).to end_with "in the last quarter. It put\n"
|
42
47
|
end
|
43
48
|
end
|
data/spec/bbc/schedule_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Schedule do
|
|
7
7
|
before(:each) do
|
8
8
|
@io = StringIO.new
|
9
9
|
@schedule = Schedule.new @io
|
10
|
-
@schedule.stub(:time_now)
|
10
|
+
@schedule.stub(:time_now).and_return(Time.at 1391435797) #13:56:37
|
11
11
|
end
|
12
12
|
|
13
13
|
after(:each) do
|
@@ -26,6 +26,15 @@ describe Schedule do
|
|
26
26
|
expect(@io.string).to include '00:30 Joins BBC News'
|
27
27
|
end
|
28
28
|
|
29
|
+
it "what is on now is the first in the list" do
|
30
|
+
@schedule.stub_chain(:open, :read) { fixture 'schedule_tv.json' }
|
31
|
+
|
32
|
+
channel = { :id => "bbcone" }
|
33
|
+
@schedule.load channel
|
34
|
+
|
35
|
+
expect(@io.string).to start_with "\e[92m13:45 Doctors"
|
36
|
+
end
|
37
|
+
|
29
38
|
it "lists todays schedule for Radio Six Musix" do
|
30
39
|
@schedule.stub_chain(:open, :read) { fixture 'schedule_radio_today.json' }
|
31
40
|
|
@@ -39,7 +48,7 @@ describe Schedule do
|
|
39
48
|
it "lists yesterday's schedule for Radio Six Music" do
|
40
49
|
@schedule.stub_chain(:open, :read) { fixture 'schedule_radio_yesterday.json' }
|
41
50
|
|
42
|
-
station = { :id => "6music" }
|
51
|
+
station = { :id => "6music", :period => "/yesterday" }
|
43
52
|
@schedule.load station
|
44
53
|
|
45
54
|
expect(@io.string).to include '20:00 Stuart Maconie\'s Freak Zone'
|
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.2.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-02-
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -123,7 +123,6 @@ files:
|
|
123
123
|
- LICENSE
|
124
124
|
- Rakefile
|
125
125
|
- README.md
|
126
|
-
- scratch
|
127
126
|
- spec/bbc/location_spec.rb
|
128
127
|
- spec/bbc/news_spec.rb
|
129
128
|
- spec/bbc/now_next_spec.rb
|
@@ -143,8 +142,9 @@ files:
|
|
143
142
|
- spec/fixtures/schedule_tv.json
|
144
143
|
- spec/fixtures/sport.json
|
145
144
|
- spec/spec_helper.rb
|
146
|
-
homepage:
|
147
|
-
licenses:
|
145
|
+
homepage: https://github.com/simongregory/auntie
|
146
|
+
licenses:
|
147
|
+
- MIT
|
148
148
|
metadata: {}
|
149
149
|
post_install_message:
|
150
150
|
rdoc_options: []
|
@@ -166,5 +166,5 @@ rubyforge_project:
|
|
166
166
|
rubygems_version: 2.0.14
|
167
167
|
signing_key:
|
168
168
|
specification_version: 4
|
169
|
-
summary: BBC
|
169
|
+
summary: BBC News, Weather, Sport, and TV & Radio schedules right in your shell
|
170
170
|
test_files: []
|