tattle 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -0
- data/Manifest.txt +9 -0
- data/README +0 -0
- data/Rakefile +14 -0
- data/bin/tattle +15 -0
- data/lib/tattle.rb +87 -0
- data/lib/tattle/string_extensions.rb +7 -0
- data/lib/tattle/version.rb +9 -0
- data/test/test_tattle.rb +32 -0
- metadata +63 -0
data/CHANGELOG
ADDED
File without changes
|
data/Manifest.txt
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hoe'
|
3
|
+
require File.join(File.dirname(__FILE__), "lib/tattle/version")
|
4
|
+
|
5
|
+
Hoe.new('tattle', Tattle::VERSION::STRING) do |p|
|
6
|
+
p.rubyforge_name = 'tattle'
|
7
|
+
p.summary = 'Tattle is a little reporting script used for collecting system information from the Ruby community.'
|
8
|
+
p.description =<<EOD
|
9
|
+
Tattle is a little reporting script used for collecting system information from the Ruby community. The purpose is to help implementors of Ruby and its libraries to better understand the install footprint of the community at large. After installing the gem, you can simply run "tattle" to help add to the existing data available. Tattle sends information from Config::CONFIG to a central server which aggregates and reports the data received.
|
10
|
+
EOD
|
11
|
+
p.url = "http://tattle.rubyforge.org"
|
12
|
+
p.email = %q{chad@chadfowler.com}
|
13
|
+
p.author = ["Chad Fowler", "Jim Weirich"]
|
14
|
+
end
|
data/bin/tattle
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'tattle'
|
3
|
+
operation = ARGV.shift
|
4
|
+
$DEBUG = true if ENV['DEBUG']
|
5
|
+
case operation
|
6
|
+
when 'report'
|
7
|
+
Tattle::Collector.report
|
8
|
+
when '-h', 'help'
|
9
|
+
puts "Usage:"
|
10
|
+
puts "tattle report # Print config data without sending"
|
11
|
+
puts "tattle post # Post config data (this is the default)"
|
12
|
+
else
|
13
|
+
puts "Posting information to Tattle server. Thanks!"
|
14
|
+
Tattle::Collector.post
|
15
|
+
end
|
data/lib/tattle.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'tattle/string_extensions'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'net/http'
|
4
|
+
require 'rbconfig'
|
5
|
+
require 'fileutils'
|
6
|
+
module Tattle
|
7
|
+
class Collector
|
8
|
+
KEY_FILE = File.expand_path('~/.tattle/key')
|
9
|
+
REPORTING_URL = if ENV['LOCAL']
|
10
|
+
URI.parse('http://localhost:3000/reports/create')
|
11
|
+
else
|
12
|
+
URI.parse('http://tattle.rubygarden.org/reports/create')
|
13
|
+
end
|
14
|
+
DESIRED_CONFIG_KEYS = ['target',
|
15
|
+
'LIBRUBY',
|
16
|
+
'prefix',
|
17
|
+
'host_cpu',
|
18
|
+
'arch',
|
19
|
+
'host_os',
|
20
|
+
'build',
|
21
|
+
'LIBRUBY_SO',
|
22
|
+
'ruby_install_name',
|
23
|
+
'target_cpu',
|
24
|
+
'host_vendor',
|
25
|
+
'SHELL']
|
26
|
+
|
27
|
+
def self.post
|
28
|
+
collector = self.new
|
29
|
+
Net::HTTP.new(REPORTING_URL.host, REPORTING_URL.port).start do |http|
|
30
|
+
params = collector.system_data.to_params + ($DEBUG ? '&debug=1' : '')
|
31
|
+
response = http.post(REPORTING_URL.path, params)
|
32
|
+
if $DEBUG
|
33
|
+
p response
|
34
|
+
p response.body
|
35
|
+
end
|
36
|
+
if !collector.key && (returned_key = response.body) =~ /^\s*[[:alnum:]]{64}\s*$/
|
37
|
+
collector.key = returned_key.strip
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.report
|
43
|
+
self.new.report
|
44
|
+
end
|
45
|
+
|
46
|
+
def system_data
|
47
|
+
data = DESIRED_CONFIG_KEYS.inject({}) do |hash, key|
|
48
|
+
hash[key] = Config::CONFIG[key]
|
49
|
+
hash
|
50
|
+
end
|
51
|
+
data['report_time'] = Time.now.to_s
|
52
|
+
data['rubygems_version'] = Gem::RubyGemsVersion
|
53
|
+
data['ruby_version'] = RUBY_VERSION
|
54
|
+
data['key'] = key
|
55
|
+
data.extend(StringExtensions)
|
56
|
+
$stderr.puts data.inspect if $DEBUG
|
57
|
+
data
|
58
|
+
end
|
59
|
+
|
60
|
+
# Read key (if available)
|
61
|
+
def key
|
62
|
+
@key ||= begin
|
63
|
+
FileUtils.mkdir(File.dirname(KEY_FILE)) rescue nil
|
64
|
+
value = File.read(KEY_FILE) rescue nil
|
65
|
+
(value.nil? || value.empty?) ? nil : value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Write key
|
70
|
+
def key=(value)
|
71
|
+
@key ||= begin
|
72
|
+
FileUtils.mkdir_p File.dirname(KEY_FILE)
|
73
|
+
File.open(KEY_FILE, 'w') do |f|
|
74
|
+
f << value
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def report(io = STDOUT)
|
80
|
+
system_data.each do |key, value|
|
81
|
+
io.puts "#{key}, #{value}"
|
82
|
+
end
|
83
|
+
system_data
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
data/test/test_tattle.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'tattle'
|
3
|
+
require 'stringio'
|
4
|
+
class TattleTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@collector = Tattle::Collector.new
|
8
|
+
@io = StringIO.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_report_prints_string
|
12
|
+
assert_not_nil(@collector.report(@io))
|
13
|
+
assert_not_nil(@io.string)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_report_string_is_CSV
|
17
|
+
@collector.class.send(:attr_accessor, :system_data)
|
18
|
+
@collector.system_data = {"FOO", "bar"}
|
19
|
+
@collector.report(@io)
|
20
|
+
assert_equal("FOO, bar\n", @io.string)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_hash_to_params
|
24
|
+
hash = {}
|
25
|
+
hash['blah'] = "foo"
|
26
|
+
hash.extend(StringExtensions)
|
27
|
+
assert_equal("report[blah]=foo", hash.to_params)
|
28
|
+
hash['baz'] = 'asdf'
|
29
|
+
assert("report[blah]=foo&report[baz]=asdf" == hash.to_params ||
|
30
|
+
"report[baz]=asdf&report[blah]=foo" == hash.to_params)
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: tattle
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2006-12-08 00:00:00 -07:00
|
8
|
+
summary: Tattle is a little reporting script used for collecting system information from the Ruby community.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: chad@chadfowler.com
|
12
|
+
homepage: http://tattle.rubyforge.org
|
13
|
+
rubyforge_project: tattle
|
14
|
+
description: Tattle is a little reporting script used for collecting system information from the Ruby community. The purpose is to help implementors of Ruby and its libraries to better understand the install footprint of the community at large. After installing the gem, you can simply run "tattle" to help add to the existing data available. Tattle sends information from Config::CONFIG to a central server which aggregates and reports the data received.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Chad Fowler
|
31
|
+
- Jim Weirich
|
32
|
+
files:
|
33
|
+
- ./bin/tattle
|
34
|
+
- ./CHANGELOG
|
35
|
+
- ./lib/tattle/string_extensions.rb
|
36
|
+
- ./lib/tattle/version.rb
|
37
|
+
- ./lib/tattle.rb
|
38
|
+
- ./Manifest.txt
|
39
|
+
- ./Rakefile
|
40
|
+
- ./README
|
41
|
+
- ./test/test_tattle.rb
|
42
|
+
test_files:
|
43
|
+
- test/test_tattle.rb
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
extra_rdoc_files: []
|
47
|
+
|
48
|
+
executables:
|
49
|
+
- tattle
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
dependencies:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hoe
|
57
|
+
version_requirement:
|
58
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.1.4
|
63
|
+
version:
|