korekuto 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/korekuto.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{korekuto}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["retr0h"]
12
- s.date = %q{2009-10-10}
12
+ s.date = %q{2009-10-13}
13
13
  s.description = %q{Data collector}
14
14
  s.email = %q{john@dewey.ws}
15
15
  s.extra_rdoc_files = [
data/lib/korekuto.rb CHANGED
@@ -6,7 +6,7 @@ require 'httparty'
6
6
  class Collector
7
7
  include HTTParty
8
8
 
9
- base_uri 'setsuju.heroku.com'
9
+ base_uri ENV['base_uri'] || 'setsuju.heroku.com'
10
10
  headers 'Content-Type' => 'application/json'
11
11
  end
12
12
 
@@ -30,11 +30,10 @@ private
30
30
  # Collect information about the dyno.
31
31
  def collect
32
32
  {
33
- Mac.addr => {
34
- :public_ip => PublicIp.get('/automation/n09230945.asp', :timeout => 2),
35
- :local_ip => ENV['LOCAL_IP'],
36
- :url => ENV['URL'],
37
- }
33
+ :mac => Mac.addr,
34
+ :public_ip => PublicIp.get('/automation/n09230945.asp', :timeout => 2),
35
+ :local_ip => ENV['LOCAL_IP'],
36
+ :url => ENV['URL'],
38
37
  }
39
38
  end
40
39
  end
@@ -1,25 +1,46 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- { 'collector' => 'setsuju.heroku.com', 'public_ip' => 'www.whatismyip.com' }.each do |k,v|
4
- clazz = Kernel.const_get(k.split('_').map {|w| w.capitalize}.join)
5
-
6
- describe clazz do
7
- subject { clazz }
3
+ describe Collector do
4
+ describe :with_defaults do
5
+ subject { Collector }
8
6
 
9
7
  it "has included modules" do
10
8
  subject.include?(HTTParty).should be_true
11
9
  end
12
10
 
13
11
  it "has a base_uri" do
14
- subject.base_uri.should == "http://#{v}"
12
+ subject.base_uri.should == "http://setsuju.heroku.com"
13
+ end
14
+
15
+ it "sets headers" do
16
+ subject.headers.should == {'Content-Type' => 'application/json'}
15
17
  end
18
+ end
16
19
 
17
- case clazz
18
- when Collector
19
- it "sets headers" do
20
- subject.headers.should == {'Content-Type' => 'application/json'}
21
- end
20
+ describe :without_defaults do
21
+ before(:each) do
22
+ ENV['base_uri'] = 'example.com'
23
+
24
+ Object.send(:remove_const, 'Collector')
25
+ load 'korekuto.rb'
22
26
  end
27
+
28
+ it "has a different base_uri when specified" do
29
+
30
+ Collector.base_uri.should == "http://example.com"
31
+ end
32
+ end
33
+ end
34
+
35
+ describe PublicIp do
36
+ subject { PublicIp }
37
+
38
+ it "has included modules" do
39
+ subject.include?(HTTParty).should be_true
40
+ end
41
+
42
+ it "has a base_uri" do
43
+ subject.base_uri.should == "http://www.whatismyip.com"
23
44
  end
24
45
  end
25
46
 
@@ -53,8 +74,9 @@ describe Korekuto do
53
74
  PublicIp.should_receive(:get).with('/automation/n09230945.asp', :timeout => 2).and_return('192.0.2.0')
54
75
  Mac.should_receive(:addr).and_return(:mac_address)
55
76
 
56
- hash = Korekuto.send(:collect)[:mac_address]
77
+ hash = Korekuto.send(:collect)
57
78
 
79
+ hash[:mac].should == :mac_address
58
80
  hash[:public_ip].should == '192.0.2.0'
59
81
  hash[:local_ip].should == '192.0.2.1'
60
82
  hash[:url].should == 'test.example.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: korekuto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - retr0h
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-10 00:00:00 -07:00
12
+ date: 2009-10-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency