warcorrespondent 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/warcorrespondent/reporter.rb +13 -2
- data/lib/warcorrespondent/reporters/users.rb +18 -0
- data/lib/warcorrespondent/uplink.rb +2 -0
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -9,12 +9,18 @@ module WarCorrespondent
|
|
9
9
|
self.send("#{key}=",args[key])
|
10
10
|
end
|
11
11
|
end
|
12
|
-
@block = block
|
12
|
+
@block = block if block
|
13
13
|
WarCorrespondent::register_reporter(self)
|
14
14
|
end
|
15
15
|
|
16
16
|
def update
|
17
|
-
|
17
|
+
data = @block.call
|
18
|
+
data = [data] if data.class == Hash
|
19
|
+
data.map! do |e|
|
20
|
+
e[:identifier] = "#{identifier}#{e[:identifier] ? (':' + e[:identifier]) : ''}".gsub(/:+/, ':')
|
21
|
+
e
|
22
|
+
end
|
23
|
+
WarCorrespondent::update({:payload => data, :timestamp => Time.now.to_i})
|
18
24
|
end
|
19
25
|
|
20
26
|
def run
|
@@ -27,5 +33,10 @@ module WarCorrespondent
|
|
27
33
|
private
|
28
34
|
|
29
35
|
end
|
36
|
+
|
30
37
|
|
38
|
+
end
|
39
|
+
puts Dir.pwd
|
40
|
+
Dir.glob(File.dirname(__FILE__) + "/reporters/*.rb") do |i|
|
41
|
+
require i
|
31
42
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module WarCorrespondent
|
2
|
+
module Reporters
|
3
|
+
class UsersReporter < WarCorrespondent::Reporter
|
4
|
+
def initialize(args)
|
5
|
+
|
6
|
+
@block = Proc.new do
|
7
|
+
count = 0
|
8
|
+
IO.popen('who') do |p|
|
9
|
+
count = p.readlines.size
|
10
|
+
end
|
11
|
+
{:value => count, :type => "integer" }
|
12
|
+
end
|
13
|
+
|
14
|
+
super(args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'pp'
|
2
3
|
module WarCorrespondent
|
3
4
|
class Uplink
|
4
5
|
|
@@ -37,6 +38,7 @@ module WarCorrespondent
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def post(message)
|
41
|
+
pp({'secret' => secret, 'data' => message})
|
40
42
|
res = Net::HTTP.post_form(URI.parse(url),
|
41
43
|
{'secret'=>secret, 'data'=>message})
|
42
44
|
raise if res.code == 200
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Stefan Maier
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-12 00:00:00 +02:00
|
18
18
|
default_executable: warcorrespondent
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- bin/warcorrespondent
|
49
49
|
- lib/warcorrespondent.rb
|
50
50
|
- lib/warcorrespondent/reporter.rb
|
51
|
+
- lib/warcorrespondent/reporters/users.rb
|
51
52
|
- lib/warcorrespondent/uplink.rb
|
52
53
|
- test/helper.rb
|
53
54
|
- test/test_warcorrespondent.rb
|