scrolls 0.2.5 → 0.2.6

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/README.md CHANGED
@@ -55,6 +55,13 @@ This would change our log output above to:
55
55
 
56
56
  app=myapp deploy=production fn=trap signal=TERM at=exit status=0
57
57
 
58
+ You can also dynamically add some data to the global context like this:
59
+
60
+ ```ruby
61
+ Scrolls.add_global_context(hostname: `hostname`)
62
+ ```
63
+
64
+
58
65
  If we were in a file and wanted to wrap a particular point of context
59
66
  we might also do something similar to:
60
67
 
data/lib/scrolls/log.rb CHANGED
@@ -39,6 +39,11 @@ module Scrolls
39
39
  set_global_context(data)
40
40
  end
41
41
 
42
+ def add_global_context(new_data)
43
+ default_global_context unless @global_context
44
+ @global_context.update { |previous_data| previous_data.merge(new_data) }
45
+ end
46
+
42
47
  def stream=(out=nil)
43
48
  @defined = out.nil? ? false : true
44
49
 
@@ -26,6 +26,8 @@ module Scrolls
26
26
  else
27
27
  v = '"' + v.gsub('\\', '\\\\\\') + '"'
28
28
  end
29
+ elsif v =~ /=/
30
+ v = '"' + v + '"'
29
31
  end
30
32
  "#{k}=#{v}"
31
33
  end
@@ -1,3 +1,3 @@
1
1
  module Scrolls
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
data/lib/scrolls.rb CHANGED
@@ -28,6 +28,10 @@ module Scrolls
28
28
  Log.global_context
29
29
  end
30
30
  end
31
+
32
+ def add_global_context(data)
33
+ Log.add_global_context(data)
34
+ end
31
35
 
32
36
  # Public: Log data and/or wrap a block with start/finish
33
37
  #
data/test/test_parser.rb CHANGED
@@ -33,6 +33,14 @@ class TestScrollsParser < Test::Unit::TestCase
33
33
  assert_equal 's="slasher \\\\"', unparse(data)
34
34
  assert_equal data.inspect, parse(unparse(data)).inspect
35
35
 
36
+ data = {s: "x=4,y=10" }
37
+ assert_equal 's="x=4,y=10"', unparse(data)
38
+ assert_equal data.inspect, parse(unparse(data)).inspect
39
+
40
+ data = {s: "x=4, y=10" }
41
+ assert_equal 's="x=4, y=10"', unparse(data)
42
+ assert_equal data.inspect, parse(unparse(data)).inspect
43
+
36
44
  # simple value is unquoted
37
45
  data = { s: "hi" }
38
46
  assert_equal 's=hi', unparse(data)
data/test/test_scrolls.rb CHANGED
@@ -23,6 +23,13 @@ class TestScrolls < Test::Unit::TestCase
23
23
  Scrolls.log(d: "d")
24
24
  assert_equal "g=g d=d\n", @out.string
25
25
  end
26
+
27
+ def test_adding_to_global_context
28
+ Scrolls.global_context(g: "g")
29
+ Scrolls.add_global_context(h: "h")
30
+ Scrolls.log(d: "d")
31
+ assert_equal "g=g h=h d=d\n", @out.string
32
+ end
26
33
 
27
34
  def test_default_context
28
35
  Scrolls.log(data: "d")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrolls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-27 00:00:00.000000000 Z
12
+ date: 2013-07-20 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Logging, easier, more consistent.
15
15
  email: