loganb-scribble-client 0.0.3 → 0.0.4

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/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.0.4 2009-05-28
2
+
3
+ * Contexts are now isolated into their own namespaces rather than overlap each other
4
+
1
5
  == 0.0.3 2009-05-28
2
6
 
3
7
  * Fixed an issue were SyslogClient barfs if no one is listening on the other end
@@ -6,5 +6,5 @@ Dir["#{File.dirname(__FILE__)}/scribble-client/**/*.rb"].sort.each { |lib|
6
6
  }
7
7
 
8
8
  module ScribbleClient
9
- VERSION = '0.0.3'
9
+ VERSION = '0.0.4'
10
10
  end
@@ -12,7 +12,7 @@ class Scribbler
12
12
  sequence_num = 0
13
13
  {
14
14
  :thuid => UUID.random_create.to_s,
15
- :thseq => lambda { |ctx,evt|
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
- (self.class.process_context.apply_context result)
39
- (self.class.thread_context.apply_context result)
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.keys.reverse_each { |k|
43
- ctx = @contexts[k]
44
- ctx.apply_context result
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
- (result.merge! hash)
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 = :default,&block)
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 = SequencedHash.new
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(target_hash)
113
+ def apply_context()
114
+ ret = {}
114
115
  @contexts.each_pair { |k,v|
115
- unless (target_hash.key? k)
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
@@ -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.3"
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.3
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: false
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.2.0
117
+ rubygems_version: 1.3.5
116
118
  signing_key:
117
119
  specification_version: 3
118
120
  summary: FIX (describe your package)