in_our_time 0.1.1 → 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/VERSION +1 -1
- data/bin/iot +0 -1
- data/in_our_time.gemspec +1 -1
- data/lib/iot/iot.rb +42 -32
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bff39b611f74f1253f1da6118e7a345c0411948
|
4
|
+
data.tar.gz: ecb0cb3c1a64b4d8907088d0fa1d902c35da18f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 457064a6748fa01c21fb0d544a17217188f644d44195abc958251c6929053fbb6dd63eaad579acbee66d6f911e13d674b9b4b574323e31cc3a5c798d1cd96e3e
|
7
|
+
data.tar.gz: 07091b59590287984bc3d62ec8018e6d1df762307189c5c257b5dd22897f067f1165e979a3c1ab914f652d0471994e8671d76670e906d0e7e656058e2c8938ce
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/iot
CHANGED
data/in_our_time.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
spec.required_ruby_version = '>= 2.0.0'
|
21
|
-
spec.add_runtime_dependency '
|
21
|
+
spec.add_runtime_dependency 'oga', '~> 2.2'
|
22
22
|
spec.add_runtime_dependency 'colorize', '>= 0.8.1'
|
23
23
|
spec.add_development_dependency 'version', '>= 1.0.0'
|
24
24
|
end
|
data/lib/iot/iot.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'nokogiri'
|
2
1
|
require 'rss'
|
3
2
|
require 'open-uri'
|
4
3
|
require 'net/http'
|
@@ -6,6 +5,7 @@ require 'open-uri'
|
|
6
5
|
require 'yaml'
|
7
6
|
require 'fileutils'
|
8
7
|
require 'colorize'
|
8
|
+
require 'oga'
|
9
9
|
|
10
10
|
class InOurTime
|
11
11
|
|
@@ -247,19 +247,17 @@ class InOurTime
|
|
247
247
|
|
248
248
|
def parse_rss
|
249
249
|
rss_files.each do |file|
|
250
|
-
@doc =
|
251
|
-
titles = @doc.xpath(
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
links = @doc.xpath("//item//link")
|
250
|
+
@doc = Oga.parse_xml(File.open(file))
|
251
|
+
titles = @doc.xpath('rss/channel/item/title')
|
252
|
+
subtitles = @doc.xpath('rss/channel/item/itunes:subtitle')
|
253
|
+
summarys = @doc.xpath('rss/channel/item/itunes:summary')
|
254
|
+
durations = @doc.xpath('rss/channel/item/itunes:duration')
|
255
|
+
dates = @doc.xpath('rss/channel/item/pubDate')
|
256
|
+
links = @doc.xpath('rss/channel/item/link')
|
258
257
|
|
259
258
|
0.upto (titles.length - 1) do |idx|
|
260
259
|
program = {}
|
261
260
|
program[:title] = titles[idx].text
|
262
|
-
# program[:description] = descs[idx]
|
263
261
|
program[:subtitle] = subtitles[idx].text
|
264
262
|
program[:summary] = summarys[idx].text
|
265
263
|
program[:duration] = durations[idx].text
|
@@ -284,8 +282,7 @@ class InOurTime
|
|
284
282
|
def sort_titles
|
285
283
|
@sorted_titles = []
|
286
284
|
@sorted_titles = @programs.collect { |pr| pr[:title] }
|
287
|
-
|
288
|
-
@sorted_titles = @sorted_titles.sort unless @config[:sort] == :age
|
285
|
+
@sorted_titles.sort! unless @config[:sort] == :age
|
289
286
|
end
|
290
287
|
|
291
288
|
def date
|
@@ -350,14 +347,13 @@ class InOurTime
|
|
350
347
|
end
|
351
348
|
|
352
349
|
def print_playing_maybe
|
353
|
-
iot_puts ''
|
354
350
|
if @playing
|
355
|
-
iot_puts "
|
351
|
+
iot_puts "\nPlaying '#{@playing}'", @selection_colour
|
356
352
|
elsif @started.nil?
|
357
353
|
@started = true
|
358
|
-
iot_puts "? or h for instructions", @text_colour
|
354
|
+
iot_puts "\n? or h for instructions", @text_colour
|
359
355
|
else
|
360
|
-
iot_puts
|
356
|
+
iot_puts "\n"
|
361
357
|
end
|
362
358
|
end
|
363
359
|
|
@@ -451,33 +447,48 @@ class InOurTime
|
|
451
447
|
end
|
452
448
|
|
453
449
|
def reformat info
|
454
|
-
|
455
|
-
|
456
|
-
|
450
|
+
['With','Guests',
|
451
|
+
'Producer','Contributors'].map do | x|
|
452
|
+
[' ', ':'].map do |y|
|
453
|
+
[x, x.upcase].map do |z|
|
454
|
+
info = info.gsub(z + y, "\n" + z + y)
|
455
|
+
end
|
456
|
+
end
|
457
|
+
end
|
458
|
+
info
|
459
|
+
end
|
460
|
+
|
461
|
+
def top_space info
|
462
|
+
info.length - info.lstrip.length
|
463
|
+
end
|
464
|
+
|
465
|
+
def bottom_space? bottom
|
466
|
+
bottom == ' '
|
467
|
+
end
|
468
|
+
|
469
|
+
def last_line? info, top
|
470
|
+
info[top..-1].length < @config[:page_width]
|
457
471
|
end
|
458
472
|
|
459
473
|
def justify info
|
460
474
|
pages = [[],[]]
|
461
475
|
page, top, bottom = 0, 0, @config[:page_width]
|
462
476
|
loop do
|
463
|
-
|
464
|
-
|
465
|
-
break
|
466
|
-
end
|
467
|
-
loop do
|
468
|
-
break unless info[top] == ' '
|
469
|
-
top += 1 ; bottom += 1
|
470
|
-
end
|
477
|
+
shift = top_space info[top..bottom]
|
478
|
+
top, bottom = top + shift, bottom + shift
|
471
479
|
loop do
|
472
480
|
if idx = info[top..bottom].index("\n")
|
473
481
|
pages[page] << info[top..top + idx]
|
474
482
|
page,bottom,top = 1,top + idx + @config[:page_width] + 1, top + idx + 1
|
475
|
-
next
|
476
483
|
else
|
477
|
-
break if
|
484
|
+
break if bottom_space? info[bottom]
|
478
485
|
bottom -= 1
|
479
486
|
end
|
480
487
|
end
|
488
|
+
if last_line? info, top
|
489
|
+
pages[page] << info[top..-1].strip
|
490
|
+
break
|
491
|
+
end
|
481
492
|
pages[page] << info[top..bottom]
|
482
493
|
bottom, top = bottom + @config[:page_width], bottom
|
483
494
|
end
|
@@ -489,8 +500,7 @@ class InOurTime
|
|
489
500
|
prg = select_program @sorted_titles[@selected]
|
490
501
|
system 'clear'
|
491
502
|
justify(prg[:subtitle].gsub(/\s+/, ' '))[0].map{|x| iot_puts x}
|
492
|
-
iot_puts
|
493
|
-
iot_puts "Date Broadcast: #{prg[:date]}"
|
503
|
+
iot_puts "\nDate Broadcast: #{prg[:date]}"
|
494
504
|
iot_puts "Duration: #{prg[:duration].to_i/60} mins"
|
495
505
|
iot_puts "Availability: " +
|
496
506
|
(prg[:have_locally] ? "Downloaded" : "Requires Download")
|
@@ -500,7 +510,7 @@ class InOurTime
|
|
500
510
|
info = prg[:summary].gsub(/\s+/, ' ')
|
501
511
|
system 'clear'
|
502
512
|
justify(reformat(info))[0].map{|x| iot_puts x}
|
503
|
-
@info = 2
|
513
|
+
@info = justify(reformat(info))[1] == [] ? -1 : 2
|
504
514
|
elsif @info == 2
|
505
515
|
prg = select_program @sorted_titles[@selected]
|
506
516
|
info = prg[:summary].gsub(/\s+/, ' ')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: in_our_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martyn Jago
|
@@ -11,19 +11,19 @@ cert_chain: []
|
|
11
11
|
date: 2016-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: oga
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '2.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: colorize
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|