scrolls 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -0
- data/lib/scrolls/log.rb +5 -0
- data/lib/scrolls/parser.rb +2 -0
- data/lib/scrolls/version.rb +1 -1
- data/lib/scrolls.rb +4 -0
- data/test/test_parser.rb +8 -0
- data/test/test_scrolls.rb +7 -0
- metadata +2 -2
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
|
|
data/lib/scrolls/parser.rb
CHANGED
data/lib/scrolls/version.rb
CHANGED
data/lib/scrolls.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2013-07-20 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Logging, easier, more consistent.
|
15
15
|
email:
|