loganb-scribble-client 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/scribble-client.rb +1 -1
- data/lib/scribble-client/scribbler.rb +18 -14
- data/scribble-client.gemspec +2 -2
- metadata +5 -3
data/History.txt
CHANGED
data/lib/scribble-client.rb
CHANGED
@@ -12,7 +12,7 @@ class Scribbler
|
|
12
12
|
sequence_num = 0
|
13
13
|
{
|
14
14
|
:thuid => UUID.random_create.to_s,
|
15
|
-
:thseq => lambda { |
|
15
|
+
:thseq => lambda { |evt|
|
16
16
|
sequence_num += 1
|
17
17
|
}
|
18
18
|
}
|
@@ -35,15 +35,15 @@ class Scribbler
|
|
35
35
|
def event(hash)
|
36
36
|
result = {}
|
37
37
|
#Merge data from the system-wide contexts
|
38
|
-
|
39
|
-
|
38
|
+
result[:procCtx] = self.class.process_context.apply_context
|
39
|
+
result[:thdCtx] = self.class.thread_context.apply_context
|
40
40
|
|
41
41
|
#Merge the contexts on this instance
|
42
|
-
@contexts.
|
43
|
-
ctx
|
44
|
-
ctx.apply_context
|
42
|
+
@contexts.each_pair { |cname,ctx|
|
43
|
+
@contexts.delete(cname) if(ctx.empty?) #Automatically clears out useless contexts
|
44
|
+
result[cname] = ctx.apply_context
|
45
45
|
}
|
46
|
-
|
46
|
+
result[:evt] = hash
|
47
47
|
|
48
48
|
#21 == local5 facility, 6 == info priority
|
49
49
|
@syslogger.syslog(21,6,result.to_json)
|
@@ -54,7 +54,7 @@ class Scribbler
|
|
54
54
|
# If a block is supplied, the context is created for the duration of the block
|
55
55
|
# and removed afterwards (in this case the method returns the result of the block).
|
56
56
|
#
|
57
|
-
def context(name = :
|
57
|
+
def context(name = :def,&block)
|
58
58
|
ctx = @contexts[name]
|
59
59
|
if(ctx.nil?)
|
60
60
|
delete_when_finished = true
|
@@ -81,7 +81,7 @@ class Scribbler
|
|
81
81
|
def initialize(target,context = nil)
|
82
82
|
@syslogger = SyslogClient.new(target)
|
83
83
|
|
84
|
-
@contexts =
|
84
|
+
@contexts = {}
|
85
85
|
self.context.add(context) if context
|
86
86
|
end
|
87
87
|
|
@@ -110,14 +110,18 @@ class Scribbler
|
|
110
110
|
add(@init_proc.call) if(@init_proc)
|
111
111
|
end
|
112
112
|
|
113
|
-
def apply_context(
|
113
|
+
def apply_context()
|
114
|
+
ret = {}
|
114
115
|
@contexts.each_pair { |k,v|
|
115
|
-
|
116
|
-
target_hash[k] = (v.is_a? Proc) ? (v.call target_hash,self) : v
|
117
|
-
end
|
116
|
+
ret[k] = (v.is_a? Proc) ? (v.call self) : v
|
118
117
|
}
|
118
|
+
ret.empty? ? nil : ret
|
119
|
+
end
|
120
|
+
|
121
|
+
def empty?
|
122
|
+
@contexts.empty?
|
119
123
|
end
|
120
124
|
end
|
121
|
-
|
125
|
+
|
122
126
|
self.process_context
|
123
127
|
end
|
data/scribble-client.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{scribble-client}
|
5
|
-
s.version = "0.0.
|
4
|
+
s.name = %q{loganb-scribble-client}
|
5
|
+
s.version = "0.0.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Logan Bowers"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loganb-scribble-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logan Bowers
|
@@ -89,8 +89,10 @@ files:
|
|
89
89
|
- script/generate
|
90
90
|
- test/test_helper.rb
|
91
91
|
- test/test_scribble_client.rb
|
92
|
-
has_rdoc:
|
92
|
+
has_rdoc: true
|
93
93
|
homepage: http://www.example.com/
|
94
|
+
licenses: []
|
95
|
+
|
94
96
|
post_install_message: PostInstall.txt
|
95
97
|
rdoc_options:
|
96
98
|
- --main
|
@@ -112,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
114
|
requirements: []
|
113
115
|
|
114
116
|
rubyforge_project: scribble-client
|
115
|
-
rubygems_version: 1.
|
117
|
+
rubygems_version: 1.3.5
|
116
118
|
signing_key:
|
117
119
|
specification_version: 3
|
118
120
|
summary: FIX (describe your package)
|