kcrw 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +23 -0
- data/.gemtest +0 -0
- data/Manifest.txt +7 -0
- data/README.txt +34 -0
- data/Rakefile +16 -0
- data/bin/kcrw +13 -0
- data/lib/kcrw.rb +32 -0
- data/test/test_kcrw.rb +8 -0
- metadata +81 -0
data/.autotest
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.extra_files << "../some/external/dependency.rb"
|
7
|
+
#
|
8
|
+
# at.libs << ":../some/external"
|
9
|
+
#
|
10
|
+
# at.add_exception 'vendor'
|
11
|
+
#
|
12
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
13
|
+
# at.files_matching(/test_.*rb$/)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# %w(TestA TestB).each do |klass|
|
17
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Autotest.add_hook :run_command do |at|
|
22
|
+
# system "rake build"
|
23
|
+
# end
|
data/.gemtest
ADDED
File without changes
|
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
= KCRW CLI
|
2
|
+
|
3
|
+
== DESCRIPTION:
|
4
|
+
|
5
|
+
A little CLI to print out what's playing on KCRW
|
6
|
+
|
7
|
+
== INSTALL:
|
8
|
+
|
9
|
+
gem install kcrw
|
10
|
+
|
11
|
+
== LICENSE:
|
12
|
+
|
13
|
+
(The MIT License)
|
14
|
+
|
15
|
+
Copyright (c) 2012 FIX
|
16
|
+
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
18
|
+
a copy of this software and associated documentation files (the
|
19
|
+
'Software'), to deal in the Software without restriction, including
|
20
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
21
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
22
|
+
permit persons to whom the Software is furnished to do so, subject to
|
23
|
+
the following conditions:
|
24
|
+
|
25
|
+
The above copyright notice and this permission notice shall be
|
26
|
+
included in all copies or substantial portions of the Software.
|
27
|
+
|
28
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
29
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
30
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
31
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
32
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
33
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
34
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.spec 'kcrw' do
|
7
|
+
# HEY! If you fill these out in ~/.hoe_template/Rakefile.erb then
|
8
|
+
# you'll never have to touch them again!
|
9
|
+
# (delete this comment too, of course)
|
10
|
+
|
11
|
+
developer('Brett Goulder', 'brett.goulder@gmail.com')
|
12
|
+
|
13
|
+
# self.rubyforge_name = 'kcrwx' # if different than 'kcrw'
|
14
|
+
end
|
15
|
+
|
16
|
+
# vim: syntax=ruby
|
data/bin/kcrw
ADDED
data/lib/kcrw.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'main'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
class KCRW
|
6
|
+
|
7
|
+
VERSION = '1.0.0'
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@doc = Nokogiri::HTML(open("http://newmedia.kcrw.com/tracklists/index.php?channel=Live"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_artist
|
14
|
+
artist = @doc.xpath("/html/body[@id='music']/div[@id='main']/div[@class='header_kcrw']/div[@class='header-holder']/div[@class='header-area']/div[@id='channel_tab']/div[@class='channel2']/div[@id='holder_music']/div[@class='list-holder']/h3")[0].text
|
15
|
+
artist.match(/(\d\:\d{2} [a|p]m) (.+)/)[2]
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_song
|
19
|
+
@doc.xpath("/html/body[@id='music']/div[@id='main']/div[@class='header_kcrw']/div[@class='header-holder']/div[@class='header-area']/div[@id='channel_tab']/div[@class='channel2']/div[@id='holder_music']/div[@class='list-holder']/ul/li[1]/span[@class='channel_song']")[0].text
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_album
|
23
|
+
@doc.xpath("/html/body[@id='music']/div[@id='main']/div[@class='header_kcrw']/div[@class='header-holder']/div[@class='header-area']/div[@id='channel_tab']/div[@class='channel2']/div[@id='holder_music']/div[@class='list-holder']/ul/li[2]/span[@class='channel_album']")[0].text
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
"Artist: " + get_artist + "\n" +
|
28
|
+
"Song: " + get_song + "\n" +
|
29
|
+
"Album: " + get_album + "\n"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/test/test_kcrw.rb
ADDED
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kcrw
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brett Goulder
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdoc
|
16
|
+
requirement: &70248050081180 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.10'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70248050081180
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
requirement: &70248050080680 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70248050080680
|
36
|
+
description: A little CLI to print out what's playing on KCRW
|
37
|
+
email:
|
38
|
+
- brett.goulder@gmail.com
|
39
|
+
executables:
|
40
|
+
- kcrw
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files:
|
43
|
+
- Manifest.txt
|
44
|
+
- README.txt
|
45
|
+
files:
|
46
|
+
- .autotest
|
47
|
+
- Manifest.txt
|
48
|
+
- README.txt
|
49
|
+
- Rakefile
|
50
|
+
- bin/kcrw
|
51
|
+
- lib/kcrw.rb
|
52
|
+
- test/test_kcrw.rb
|
53
|
+
- .gemtest
|
54
|
+
homepage:
|
55
|
+
licenses: []
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --main
|
59
|
+
- README.txt
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project: kcrw
|
76
|
+
rubygems_version: 1.8.11
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: A little CLI to print out what's playing on KCRW
|
80
|
+
test_files:
|
81
|
+
- test/test_kcrw.rb
|