irlp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/irlp.gemspec +26 -0
- data/lib/irlp.rb +15 -0
- data/lib/irlp/scraper.rb +102 -0
- data/lib/irlp/version.rb +3 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e0732fcfac62d175c5aa1f4326ca7bf704847d9
|
4
|
+
data.tar.gz: af24ef8518564fb2129e9da300e744e82bf627db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5984664e17173c95e5126922a763d652358727285dbb882d7d999641fa14a522cabc6eca7b5cbf06276548043c3c9b074e3184d9fb69006e6767da1f6ea74cdc
|
7
|
+
data.tar.gz: ec5629709ae378c0aaedf54f679a33bf6a0a7160126ae341259a1ecdd5f6b7d1af4713ceb254d3219169a512d64d48cbd25e70c326c971b31a5d799a91af627e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kevin Elliott
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Irlp
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'irlp'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install irlp
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/irlp.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'irlp/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "irlp"
|
8
|
+
spec.version = Irlp::VERSION
|
9
|
+
spec.authors = ["Kevin Elliott"]
|
10
|
+
spec.email = ["kevin@welikeinc.com"]
|
11
|
+
spec.description = %q{Ruby gem to interact with the Internet Radio Linking Project (IRLP), such as retrieving reflector and node status.}
|
12
|
+
spec.summary = %q{Ruby gem to interact with the Internet Radio Linking Project (IRLP).}
|
13
|
+
spec.homepage = "http://github.com/kevinelliott/irlp"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'curb'
|
22
|
+
spec.add_dependency 'nokogiri'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
data/lib/irlp.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'irlp/scraper'
|
2
|
+
require 'irlp/version'
|
3
|
+
|
4
|
+
module Irlp
|
5
|
+
BASE_URL = 'http://status.irlp.net/index.php'
|
6
|
+
URLS = {
|
7
|
+
nodes: "#{BASE_URL}?PSTART=3",
|
8
|
+
nodes_connected: "#{BASE_URL}?PSTART=2",
|
9
|
+
nodes_mini: "#{BASE_URL}?PSTART=9",
|
10
|
+
nodes_new: "#{BASE_URL}?PSTART=10",
|
11
|
+
node_detail: "#{BASE_URL}?PSTART=11",
|
12
|
+
reflectors: "#{BASE_URL}",
|
13
|
+
reflector_usage: "#{BASE_URL}?PSTART=1",
|
14
|
+
}
|
15
|
+
end
|
data/lib/irlp/scraper.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'curb'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module Irlp
|
5
|
+
class Scraper
|
6
|
+
|
7
|
+
def reflectors
|
8
|
+
reflectors = []
|
9
|
+
|
10
|
+
html = html(Irlp::URLS[:reflectors])
|
11
|
+
html.css('table tr').each_with_index do |reflector, i|
|
12
|
+
next if i < 6
|
13
|
+
cols = reflector.css('td')
|
14
|
+
reflectors << {
|
15
|
+
id: cols[0].text.to_i,
|
16
|
+
name: cols[1].text.split.join(' ')
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
reflectors.each { |r| puts "#{r[:id]}: #{r[:name]}"}
|
21
|
+
reflectors
|
22
|
+
end
|
23
|
+
|
24
|
+
def nodes
|
25
|
+
nodes = []
|
26
|
+
|
27
|
+
html = html(Irlp::URLS[:nodes])
|
28
|
+
html.css('table tr').each_with_index do |reflector, i|
|
29
|
+
next if i < 1
|
30
|
+
cols = reflector.css('td')
|
31
|
+
nodes << {
|
32
|
+
id: cols[0].text.to_i,
|
33
|
+
call_sign: cols[1].text,
|
34
|
+
city: cols[2].text,
|
35
|
+
province: cols[3].text,
|
36
|
+
country: cols[4].text,
|
37
|
+
frequency: cols[5].text,
|
38
|
+
status: cols[7].text.downcase,
|
39
|
+
status_duration: cols[8].text,
|
40
|
+
status_link: "#{Irlp::BASE_URL}/index.php?PSTART=11&nodeid=#{cols[0].text}"
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
nodes.each { |r| puts "#{r[:id]}: #{r[:call_sign]}"}
|
45
|
+
nodes
|
46
|
+
end
|
47
|
+
|
48
|
+
def node_status(id)
|
49
|
+
node = {}
|
50
|
+
|
51
|
+
node_status_url = "#{Irlp::URLS[:node_detail]}&nodeid=#{id}"
|
52
|
+
html = html(node_status_url)
|
53
|
+
html.css('table tr').each_with_index do |row, i|
|
54
|
+
data = row.css('td')[1]
|
55
|
+
case i
|
56
|
+
when 0
|
57
|
+
node[:id] = data.text.to_i
|
58
|
+
when 1
|
59
|
+
node[:call_sign] = data.text
|
60
|
+
when 2
|
61
|
+
node[:city] = data.text
|
62
|
+
when 3
|
63
|
+
node[:province] = data.text
|
64
|
+
when 4
|
65
|
+
node[:country] = data.text
|
66
|
+
when 5
|
67
|
+
node[:owner] = data.text
|
68
|
+
when 6
|
69
|
+
node[:latitude] = data.text
|
70
|
+
when 7
|
71
|
+
node[:longitude] = data.text
|
72
|
+
when 8
|
73
|
+
node[:frequency] = data.text
|
74
|
+
when 9
|
75
|
+
node[:offset] = data.text
|
76
|
+
when 10
|
77
|
+
node[:tone_squelch] = data.text
|
78
|
+
when 11
|
79
|
+
node[:avrs_status] = data.text
|
80
|
+
when 12
|
81
|
+
node[:website] = data.css('a')[0].attr(:href).text if data.css('a').size > 0
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
node
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def curl(url)
|
91
|
+
http = Curl.get(url) do |http|
|
92
|
+
http.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def html(url)
|
97
|
+
http = curl(url)
|
98
|
+
html = Nokogiri::HTML(http.body_str)
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
data/lib/irlp/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: irlp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin Elliott
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: curb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Ruby gem to interact with the Internet Radio Linking Project (IRLP),
|
70
|
+
such as retrieving reflector and node status.
|
71
|
+
email:
|
72
|
+
- kevin@welikeinc.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- irlp.gemspec
|
83
|
+
- lib/irlp.rb
|
84
|
+
- lib/irlp/scraper.rb
|
85
|
+
- lib/irlp/version.rb
|
86
|
+
homepage: http://github.com/kevinelliott/irlp
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.0.3
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Ruby gem to interact with the Internet Radio Linking Project (IRLP).
|
110
|
+
test_files: []
|