echo_link 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 934bc3f9140e9e7d05752813f4ad4cf73a6c603a
4
+ data.tar.gz: 31a9cdb3b1d4fdddbb644e5eb1968d6525793dd7
5
+ SHA512:
6
+ metadata.gz: 49151a16a869d8ce35afe718e5eb3ccf0741eac7fa8a1894ef7fd1f9f3020a74db8781be87aac7ba83dfb5a55e01a498d109d99146e8441e8384a785b38b4396
7
+ data.tar.gz: 848fcf36c3e98fe79068790928057428fa5d3914c9b35632b8e65069e992a12605dcbc1daf291e303bca26d67c365f95e8ee1e07f66de1c618dad8a3f92a55c1
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in irlp.gemspec
4
+ gemspec
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,42 @@
1
+ # echo_link
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/echo_link.png)](http://badge.fury.io/rb/echo_link)
4
+
5
+ Retrieve information from the EchoLink network, such as link status and logins.
6
+
7
+ The [EchoLink](http://www.echolink.org/) is a network of amateur radio repeaters and software clients that are linked together across regions via the Internet using VoIP. The EchoLink allows people to make contact with others across the world without needing long distance (DX) equipment and licenses.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'echo_link'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install echo_link
22
+
23
+ ## Usage
24
+
25
+ ### Get links
26
+
27
+ ```ruby
28
+ EchoLink::Scraper.new.links
29
+ ```
30
+
31
+ which returns an `Array` of `Hash`es similar to:
32
+
33
+ ```ruby
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/echo_link.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 'echo_link/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "echo_link"
8
+ spec.version = EchoLink::VERSION
9
+ spec.authors = ["Kevin Elliott"]
10
+ spec.email = ["kevin@welikeinc.com"]
11
+ spec.description = %q{Ruby gem to interact with the EchoLink, such as retrieving link status.}
12
+ spec.summary = %q{Ruby gem to interact with the EchoLink.}
13
+ spec.homepage = "http://github.com/kevinelliott/echo_link"
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
@@ -0,0 +1,67 @@
1
+ require 'curb'
2
+ require 'nokogiri'
3
+
4
+ module EchoLink
5
+ class Scraper
6
+
7
+
8
+ def links
9
+ links = []
10
+
11
+ first_page_url = "#{EchoLink::URLS[:all_links]}&offset=0"
12
+ html = html(first_page_url)
13
+ links += links_from_table(html.css('table')[5])
14
+
15
+ p = html.css('table').first.css('tr')[1].css('td').first.css('p').first
16
+ total_links = p.css('b')[2].text.to_i
17
+ per_page = 100
18
+ page_count = (total_links / per_page.to_f).ceil
19
+
20
+ (2..page_count).each do |num|
21
+ offset = per_page * (num - 1)
22
+ page_url = "#{EchoLink::URLS[:all_links]}&offset=#{offset}"
23
+
24
+ html = html(page_url)
25
+ links += links_from_table(html.css('table')[5])
26
+ end
27
+ links
28
+ end
29
+
30
+ def links_from_table(table)
31
+ links = []
32
+ table.css('tr').each_with_index do |tr, i|
33
+ next if i == 0
34
+ tds = tr.css('td')
35
+ links << {
36
+ id: tds[2].text.to_i,
37
+ call_sign: tds[0].text,
38
+ location: tds[3].text,
39
+ grid: tds[4].text,
40
+ frequency: tds[5].text,
41
+ tone_squelch: tds[6].text,
42
+ power: tds[7].text,
43
+ haat: tds[8].text,
44
+ antenna: tds[9].text,
45
+ status: tds[10].text,
46
+ comment: tds[11].text,
47
+ status_last_update_at: tds[12].text
48
+ }
49
+ end
50
+ links
51
+ end
52
+
53
+ private
54
+
55
+ def curl(url)
56
+ http = Curl.get(url) do |http|
57
+ 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'
58
+ end
59
+ end
60
+
61
+ def html(url)
62
+ http = curl(url)
63
+ html = Nokogiri::HTML(http.body_str)
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,3 @@
1
+ module EchoLink
2
+ VERSION = "0.0.1"
3
+ end
data/lib/echo_link.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'echo_link/scraper'
2
+ require 'echo_link/version'
3
+
4
+ module EchoLink
5
+ BASE_URL = 'http://www.echolink.org'
6
+ URLS = {
7
+ logins: "#{BASE_URL}/logins.jsp",
8
+ all_links: "#{BASE_URL}/links.jsp?title=&d=1&sel=all&lat_fix=&lon_fix=&lat_deg=&lat_min=&lat_NS=&lon_deg=&lon_min=&lon_EW=&gs=",
9
+ active_links: "#{BASE_URL}/links.jsp?title=&d=2&sel=all&lat_fix=&lon_fix=&lat_deg=&lat_min=&lat_NS=&lon_deg=&lon_min=&lon_EW=&gs="
10
+ }
11
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: echo_link
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-28 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 EchoLink, such as retrieving link status.
70
+ email:
71
+ - kevin@welikeinc.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - echo_link.gemspec
82
+ - lib/echo_link.rb
83
+ - lib/echo_link/scraper.rb
84
+ - lib/echo_link/version.rb
85
+ homepage: http://github.com/kevinelliott/echo_link
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.1.10
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Ruby gem to interact with the EchoLink.
109
+ test_files: []