squirtgun 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/cattr.rb +46 -0
- data/lib/squirtgun.rb +43 -0
- data/squirtgun.gemspec +7 -6
- metadata +15 -15
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ Jeweler::Tasks.new do |gem|
|
|
20
20
|
gem.summary = %Q{placeholder}
|
21
21
|
gem.description = %Q{placeholder for long description}
|
22
22
|
gem.email = "squirtgun@kerrizor.com"
|
23
|
-
gem.authors = ["Kerri Miller"]
|
23
|
+
gem.authors = ["Kerri Miller", "Chris Doyle"]
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/lib/cattr.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
class Class
|
2
|
+
def cattr_reader(*syms)
|
3
|
+
syms.flatten.each do |sym|
|
4
|
+
next if sym.is_a?(Hash)
|
5
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
6
|
+
unless defined? @@#{sym}
|
7
|
+
@@#{sym} = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.#{sym}
|
11
|
+
@@#{sym}
|
12
|
+
end
|
13
|
+
|
14
|
+
def #{sym}
|
15
|
+
@@#{sym}
|
16
|
+
end
|
17
|
+
EOS
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def cattr_writer(*syms)
|
22
|
+
options = syms.last.is_a?(Hash) ? syms.pop : {}
|
23
|
+
syms.flatten.each do |sym|
|
24
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
25
|
+
unless defined? @@#{sym}
|
26
|
+
@@#{sym} = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.#{sym}=(obj)
|
30
|
+
@@#{sym} = obj
|
31
|
+
end
|
32
|
+
|
33
|
+
#{"
|
34
|
+
def #{sym}=(obj)
|
35
|
+
@@#{sym} = obj
|
36
|
+
end
|
37
|
+
" unless options[:instance_writer] == false }
|
38
|
+
EOS
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def cattr_accessor(*syms)
|
43
|
+
cattr_reader(*syms)
|
44
|
+
cattr_writer(*syms)
|
45
|
+
end
|
46
|
+
end
|
data/lib/squirtgun.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'cattr'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class Squirtgun
|
6
|
+
|
7
|
+
class Config
|
8
|
+
cattr_accessor :listener, :listener_port, :secret_key, :project_id
|
9
|
+
|
10
|
+
def self.listener
|
11
|
+
@@listener || '174.143.25.227' # TODO: maybe there's a better way to do defaults?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.listener_port
|
15
|
+
@@listener_port || '43278'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# TODO: decide if this is a shitty name because its all Squirtgun::Squirtgun..
|
21
|
+
class Gun
|
22
|
+
require 'socket'
|
23
|
+
require 'openssl'
|
24
|
+
|
25
|
+
def report(options={})
|
26
|
+
return if options[:context].nil? or options[:value].nil?
|
27
|
+
|
28
|
+
|
29
|
+
# TODO: add message format testing? Guzzler currenlty expects [context]:[value]..
|
30
|
+
|
31
|
+
options[:project_id] ||= Squirtgun::Config.project_id
|
32
|
+
|
33
|
+
sock = UDPSocket.new
|
34
|
+
sock.send({:stat => options, :hmac => encode_packet(options[:context] + options[:value], Squirtgun::Config.secret_key)}.to_json, 0, Squirtgun::Config.listener, Squirtgun::Config.listener_port)
|
35
|
+
sock.close
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def encode_packet(data, key)
|
40
|
+
OpenSSL::HMAC.hexdigest('sha1', key, data)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/squirtgun.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{squirtgun}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = [%q{Kerri Miller}, %q{Chris Doyle}]
|
12
|
+
s.date = %q{2011-08-15}
|
13
13
|
s.description = %q{placeholder for long description}
|
14
14
|
s.email = %q{squirtgun@kerrizor.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,15 +24,16 @@ Gem::Specification.new do |s|
|
|
24
24
|
"README.rdoc",
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
|
+
"lib/cattr.rb",
|
27
28
|
"lib/squirtgun.rb",
|
28
29
|
"squirtgun.gemspec",
|
29
30
|
"test/helper.rb",
|
30
31
|
"test/test_squirtgun.rb"
|
31
32
|
]
|
32
33
|
s.homepage = %q{http://github.com/kerrizor/squirtgun}
|
33
|
-
s.licenses = [
|
34
|
-
s.require_paths = [
|
35
|
-
s.rubygems_version = %q{1.6
|
34
|
+
s.licenses = [%q{MIT}]
|
35
|
+
s.require_paths = [%q{lib}]
|
36
|
+
s.rubygems_version = %q{1.8.6}
|
36
37
|
s.summary = %q{placeholder}
|
37
38
|
|
38
39
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,25 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squirtgun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kerri Miller
|
14
|
+
- Chris Doyle
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
19
|
+
date: 2011-08-15 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
prerelease: false
|
23
22
|
type: :development
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
@@ -30,10 +29,10 @@ dependencies:
|
|
30
29
|
segments:
|
31
30
|
- 0
|
32
31
|
version: "0"
|
33
|
-
name: shoulda
|
34
32
|
version_requirements: *id001
|
35
|
-
|
33
|
+
name: shoulda
|
36
34
|
prerelease: false
|
35
|
+
- !ruby/object:Gem::Dependency
|
37
36
|
type: :development
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
@@ -46,10 +45,10 @@ dependencies:
|
|
46
45
|
- 0
|
47
46
|
- 0
|
48
47
|
version: 1.0.0
|
49
|
-
name: bundler
|
50
48
|
version_requirements: *id002
|
51
|
-
|
49
|
+
name: bundler
|
52
50
|
prerelease: false
|
51
|
+
- !ruby/object:Gem::Dependency
|
53
52
|
type: :development
|
54
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
54
|
none: false
|
@@ -62,10 +61,10 @@ dependencies:
|
|
62
61
|
- 6
|
63
62
|
- 4
|
64
63
|
version: 1.6.4
|
65
|
-
name: jeweler
|
66
64
|
version_requirements: *id003
|
67
|
-
|
65
|
+
name: jeweler
|
68
66
|
prerelease: false
|
67
|
+
- !ruby/object:Gem::Dependency
|
69
68
|
type: :development
|
70
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
70
|
none: false
|
@@ -76,8 +75,9 @@ dependencies:
|
|
76
75
|
segments:
|
77
76
|
- 0
|
78
77
|
version: "0"
|
79
|
-
name: rcov
|
80
78
|
version_requirements: *id004
|
79
|
+
name: rcov
|
80
|
+
prerelease: false
|
81
81
|
description: placeholder for long description
|
82
82
|
email: squirtgun@kerrizor.com
|
83
83
|
executables: []
|
@@ -95,11 +95,11 @@ files:
|
|
95
95
|
- README.rdoc
|
96
96
|
- Rakefile
|
97
97
|
- VERSION
|
98
|
+
- lib/cattr.rb
|
98
99
|
- lib/squirtgun.rb
|
99
100
|
- squirtgun.gemspec
|
100
101
|
- test/helper.rb
|
101
102
|
- test/test_squirtgun.rb
|
102
|
-
has_rdoc: true
|
103
103
|
homepage: http://github.com/kerrizor/squirtgun
|
104
104
|
licenses:
|
105
105
|
- MIT
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements: []
|
130
130
|
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.6
|
132
|
+
rubygems_version: 1.8.6
|
133
133
|
signing_key:
|
134
134
|
specification_version: 3
|
135
135
|
summary: placeholder
|