rubyconf 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2013-11-01
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,8 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/rubyconf
7
+ lib/rubyconf.rb
8
+ test/test_rubyconf.rb
data/README.txt ADDED
@@ -0,0 +1,57 @@
1
+ = rubyconf
2
+
3
+ * http://github.com/rubycentral/rubyconf
4
+
5
+ == DESCRIPTION:
6
+
7
+ Tools for when you're at rubyconf!
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Post results about the wireless for us to sample to make the conf better
12
+
13
+ == SYNOPSIS:
14
+
15
+ $ rubyconf
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * Mac OS X 10.5+
20
+
21
+ == INSTALL:
22
+
23
+ * gem install rubyconf
24
+
25
+ == DEVELOPERS:
26
+
27
+ After checking out the source, run:
28
+
29
+ $ rake newb
30
+
31
+ This task will install any missing dependencies, run the tests/specs,
32
+ and generate the RDoc.
33
+
34
+ == LICENSE:
35
+
36
+ (The MIT License)
37
+
38
+ Copyright (c) 2013 Evan Phoenix
39
+
40
+ Permission is hereby granted, free of charge, to any person obtaining
41
+ a copy of this software and associated documentation files (the
42
+ 'Software'), to deal in the Software without restriction, including
43
+ without limitation the rights to use, copy, modify, merge, publish,
44
+ distribute, sublicense, and/or sell copies of the Software, and to
45
+ permit persons to whom the Software is furnished to do so, subject to
46
+ the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be
49
+ included in all copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
52
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
53
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
54
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
55
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
56
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
57
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+
7
+ Hoe.spec 'rubyconf' do
8
+ developer('Evan Phoenix', 'evan@rubycentral.org')
9
+ end
10
+
11
+ # vim: syntax=ruby
data/bin/rubyconf ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubyconf'
4
+ require 'optparse'
5
+
6
+ rc = Rubyconf.new
7
+
8
+ interval = 300
9
+
10
+ opts = OptionParser.new do |o|
11
+ o.on "--scan", "Display info about all wireless networks around" do
12
+ rc.refresh_wireless
13
+ rc.show_networks
14
+ exit
15
+ end
16
+
17
+ o.on "-i", "--interval INTEGER", "Control how often to post info (default: 300s)" do |s|
18
+ interval = s.to_i
19
+ end
20
+ end
21
+
22
+ puts "Posting details about wireless network ever #{interval} seconds..."
23
+
24
+ begin
25
+ loop do
26
+ rc.post!
27
+ sleep interval
28
+ end
29
+ rescue Interrupt
30
+ end
data/lib/rubyconf.rb ADDED
@@ -0,0 +1,109 @@
1
+ require 'plist'
2
+ require 'base64'
3
+ require 'socket'
4
+ require 'json'
5
+ require 'net/http'
6
+
7
+ class Rubyconf
8
+ VERSION = '1.0.0'
9
+
10
+ class WirelessNetwork
11
+ def initialize(data)
12
+ @data = data
13
+ end
14
+
15
+ def bssid
16
+ @data["BSSID"]
17
+ end
18
+
19
+ def channel
20
+ @data["CHANNEL"]
21
+ end
22
+
23
+ def ssid
24
+ @ssid ||= @data["SSID"].string
25
+ end
26
+
27
+ def noise
28
+ @data["NOISE"]
29
+ end
30
+
31
+ def rssi
32
+ @data["RSSI"]
33
+ end
34
+
35
+ def show
36
+ printf "%20s %4s %d\n", ssid, rssi, channel
37
+ end
38
+ end
39
+
40
+ def refresh_wireless(xml=nil)
41
+ xml ||= `airport -x -s`
42
+
43
+ out = Plist.parse_xml xml
44
+
45
+ @networks = out.map { |w| WirelessNetwork.new(w) }
46
+ end
47
+
48
+ def show_networks(filter=/./)
49
+ printf "%20s %4s %s\n", "SSID", "RSSI", "CHANNEL"
50
+ @networks.each do |n|
51
+ if n.ssid =~ filter
52
+ n.show
53
+ end
54
+ end
55
+ end
56
+
57
+ class CurrentNetwork
58
+ def initialize(data)
59
+ @data = data
60
+ end
61
+
62
+ def external
63
+ {
64
+ 'ssid' => @data['SSID'],
65
+ 'bssid' => @data['BSSID'],
66
+ 'rssi' => @data['agrCtlRSSI'].to_i,
67
+ 'noise' => @data['agrCtlNoise'].to_i,
68
+ 'channel' => @data['channel'].to_i,
69
+ 'txrate' => @data['lastTxRate'].to_i,
70
+ 'maxrate' => @data['maxRate'].to_i
71
+ }
72
+ end
73
+ end
74
+
75
+ def current_network
76
+ data = `airport -I`
77
+
78
+ vals = data.split("\n").map { |x| x.split(":", 2).map { |i| i.strip } }
79
+
80
+ CurrentNetwork.new Hash[*vals.flatten]
81
+ end
82
+
83
+ def ttg
84
+ s = TCPSocket.new "74.125.224.134", 80
85
+ start = Time.now
86
+ s << "GET / HTTP/1.0\r\n\r\n"
87
+ s.read(4)
88
+ fin = Time.now
89
+ s.close
90
+
91
+ fin - start
92
+ end
93
+
94
+ def post!
95
+ data = current_network.external
96
+
97
+ data['ttg'] = ttg
98
+
99
+ Net::HTTP.start "rubyconf-wireless.herokuapp.com", 80 do |http|
100
+ r = http.post "/sampler", JSON.dump(data)
101
+ if r.code != "200"
102
+ puts "Error posting results: #{r.inspect}"
103
+ if $DEBUG
104
+ puts r.body
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "rubyconf"
3
+
4
+ class TestRubyconf < Test::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubyconf
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Evan Phoenix
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '4.0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '4.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: hoe
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.6'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.6'
46
+ description: Tools for when you're at rubyconf!
47
+ email:
48
+ - evan@rubycentral.org
49
+ executables:
50
+ - rubyconf
51
+ extensions: []
52
+ extra_rdoc_files:
53
+ - History.txt
54
+ - Manifest.txt
55
+ - README.txt
56
+ files:
57
+ - .autotest
58
+ - History.txt
59
+ - Manifest.txt
60
+ - README.txt
61
+ - Rakefile
62
+ - bin/rubyconf
63
+ - lib/rubyconf.rb
64
+ - test/test_rubyconf.rb
65
+ - .gemtest
66
+ homepage: http://github.com/rubycentral/rubyconf
67
+ licenses: []
68
+ post_install_message:
69
+ rdoc_options:
70
+ - --main
71
+ - README.txt
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project: rubyconf
88
+ rubygems_version: 1.8.25
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Tools for when you're at rubyconf!
92
+ test_files:
93
+ - test/test_rubyconf.rb