lines 0.1.16 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDMyYWMxNDMyYjgzY2UwMzQ3NDhlYmI2MmM2ZjBlMWViMjM5MDUwYg==
4
+ ODA2Y2ZhNTJmYzQwYTE4ZDU1NjNhNDQ4MWVhNzAxZmMwZDcyY2U4ZA==
5
5
  data.tar.gz: !binary |-
6
- OTJkNjY2ZGJiMTIwNGIwZThlNDQ4ZTRhYzU0NGY0MjNjYTk3N2M1NA==
6
+ Nzc3ZTEzMDczYmI1ZGVhNjk3YmFhOGQzODhjYjUzOTU1NDkxNjM3Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZmU2ZGI1ZDZmN2U2ZTIzMmI5ZDVjZmIyZjk1MGFmNjcxNTYzMzk1ZGEwZWY5
10
- MzEwNTU1YTc2ZWUxMGI2NDEyMDU4NDBhZTIwMWQ1MWZiNjI5Mzg4N2EzMGJl
11
- MjUxZTNmMGQ4ZWE0OTQxZTQ4NzMwMzQzY2M3YTllZmViOTVkYTQ=
9
+ YmQyNDJkZjEwMjdlOWMwMGIyMjQwYzM0Y2NhMTk0ZGNkYjk2OWZkZTg4MWQx
10
+ NTRlMjZmNDkyNzM2ZTZjODljZmFiMzNkMWM2NzI5ZjMzZmM0ODVhNTExY2Ew
11
+ MzZjN2Y2YzE4MDY4Y2QzMjUyZTk3MWZiMDFmZDUyOTUyMTUzZjg=
12
12
  data.tar.gz: !binary |-
13
- MzM5MTI0YzE5NGVlMjEzNTk2OTkwODk0MDViYzRmN2YwMjBmMDc5NGM5ZmNm
14
- MThiZTQ1NDgxNDJhOTBjNDM4NTAzODZhYjk0MjQ3MjI4YzdiY2FjN2YzMjFm
15
- NGQzODEzMmRiNzdhMWJkMmZlY2Q2OTMyZGU5ZmMxYzVkM2UyN2Y=
13
+ NDQxOTdiMTc0ODk5MjBhYjNmY2JhOTcwZDk1ZTUzNmRlODRkOTdlMGY4MGVm
14
+ NTA1NTdkYzdjYjYyODBlNTA3N2RjMGY0M2RkY2U0ODUyYTU2MjA3ZDg2YTQy
15
+ MjRkNzdhZmZiYmY3MGI1ZGEyNGQxYjU4MDU5N2I5MzQzOTllMGI=
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --format documentation --color
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
3
+ group :development do
4
+ gem 'parslet'
5
+ gem 'rdoc'
6
+ gem 'rspec'
7
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lines (0.1.16)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ blankslate (2.1.2.4)
10
+ diff-lcs (1.2.1)
11
+ json (1.7.7)
12
+ parslet (1.5.0)
13
+ blankslate (~> 2.0)
14
+ rdoc (4.0.0)
15
+ json (~> 1.4)
16
+ rspec (2.13.0)
17
+ rspec-core (~> 2.13.0)
18
+ rspec-expectations (~> 2.13.0)
19
+ rspec-mocks (~> 2.13.0)
20
+ rspec-core (2.13.0)
21
+ rspec-expectations (2.13.0)
22
+ diff-lcs (>= 1.1.3, < 2.0)
23
+ rspec-mocks (2.13.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ lines!
30
+ parslet
31
+ rdoc
32
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jonas Pfenniger
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/lines.rb CHANGED
@@ -290,7 +290,10 @@ module Lines
290
290
  s = s.to_s
291
291
  unless is_literal?(s)
292
292
  s = s.inspect
293
- s[0] = s[-1] = "'" unless s[1..-2].include?("'")
293
+ unless s[1..-2].include?("'")
294
+ s[0] = s[-1] = "'"
295
+ s.gsub!('\"', '"')
296
+ end
294
297
  end
295
298
  s
296
299
  end
data/lib/lines/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lines
2
- VERSION = "0.1.16"
2
+ VERSION = "0.1.18"
3
3
  end
data/lines.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lines/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lines"
8
+ spec.version = Lines::VERSION
9
+ spec.authors = ["Jonas Pfenniger"]
10
+ spec.email = ["jonas@pfenniger.name"]
11
+ spec.description = %q{structured logs for humans}
12
+ spec.summary = %q{Lines is an opinionated structured logging library}
13
+ spec.homepage = 'https://github.com/zimbatm/lines-ruby'
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rspec"
23
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+ require 'lines/loader'
3
+
4
+ module Lines
5
+ describe Loader do
6
+ subject { Loader }
7
+
8
+ it "can load stuff" do
9
+ expect(Loader.load 'foo=bar').to eq("foo" => "bar")
10
+ end
11
+ end
12
+
13
+ describe Parser do
14
+ let(:parser) { Lines::Parser.new }
15
+
16
+ context "value parsing" do
17
+ let(:value_parser) { parser.value }
18
+
19
+ it "parses integers" do
20
+ pending
21
+ expect(value_parser).to parse("1")
22
+ expect(value_parser).to parse("-123")
23
+ expect(value_parser).to parse("120381")
24
+ expect(value_parser).to parse("181")
25
+ end
26
+
27
+ it "parses floats" do
28
+ pending
29
+ expect(value_parser).to parse("0.1")
30
+ expect(value_parser).to parse("3.14159")
31
+ expect(value_parser).to parse("-0.00001")
32
+ end
33
+
34
+ it "parses booleans" do
35
+ pending
36
+ expect(value_parser).to parse("#t")
37
+ expect(value_parser).to parse("#f")
38
+ end
39
+
40
+ it "parses datetimes" do
41
+ pending
42
+ expect(value_parser).to parse("1979-05-27T07:32:00Z")
43
+ expect(value_parser).to parse("2013-02-24T17:26:21Z")
44
+ expect(value_parser).to_not parse("1979l05-27 07:32:00")
45
+ end
46
+
47
+ it "parses strings" do
48
+ pending
49
+ expect(value_parser).to parse('""')
50
+ expect(value_parser).to parse('"hello world"')
51
+ expect(value_parser).to parse('"hello\\nworld"')
52
+ expect(value_parser).to parse('"hello\\t\\n\\\\\\0world\\n"')
53
+ expect(value_parser).to_not parse("\"hello\nworld\"")
54
+ end
55
+ end
56
+ end
57
+
58
+ describe Transformer do
59
+
60
+ end
61
+ end
@@ -0,0 +1,142 @@
1
+ require 'spec_helper'
2
+ require 'lines'
3
+ require 'stringio'
4
+
5
+ describe Lines do
6
+ let(:outputter) { StringIO.new }
7
+ let(:output) { outputter.string }
8
+ before do
9
+ Lines.use(outputter)
10
+ end
11
+
12
+ it "logs stuff" do
13
+ Lines.log(foo: 'bar')
14
+ expect(output).to eq('foo=bar' + Lines::NL)
15
+ end
16
+
17
+ it "supports a first msg argument" do
18
+ Lines.log("this user is annoying", user: 'bob')
19
+ expect(output).to eq("msg='this user is annoying' user=bob" + Lines::NL)
20
+ end
21
+
22
+ it "logs exceptions" do
23
+ Lines.log(StandardError.new("error time!"), user: 'bob')
24
+ expect(output).to eq("ex=StandardError msg='error time!' user=bob" + Lines::NL)
25
+ end
26
+
27
+ it "logs exception backtraces when available" do
28
+ ex = (raise "foo" rescue $!)
29
+ #expect(ex).not_to eq(nil)
30
+ Lines.log(ex)
31
+ expect(output).to match(/ex=RuntimeError msg=foo backtrace=\[[^\]]+\]/)
32
+ end
33
+
34
+ it "works with anything" do
35
+ Lines.log("anything")
36
+ expect(output).to eq('msg=anything' + Lines::NL)
37
+ end
38
+
39
+ it "has global context" do
40
+ Lines.global["app"] = :self
41
+ Lines.log({})
42
+ Lines.global.replace({})
43
+ expect(output).to eq('app=self' + Lines::NL)
44
+ end
45
+
46
+ it "has contextes" do
47
+ Lines.context(foo: "bar").log(a: 'b')
48
+ expect(output).to eq('a=b foo=bar' + Lines::NL)
49
+ end
50
+
51
+ it "has contextes with blocks" do
52
+ Lines.context(foo: "bar") do |ctx|
53
+ ctx.log(a: 'b')
54
+ end
55
+ expect(output).to eq('a=b foo=bar' + Lines::NL)
56
+ end
57
+
58
+ it "has a backward-compatible logger" do
59
+ l = Lines.logger
60
+ l.info("hi")
61
+ expect(output).to eq('pri=info msg=hi' + Lines::NL)
62
+ end
63
+ end
64
+
65
+ describe Lines::Dumper do
66
+ subject { Lines::Dumper.new }
67
+ def expect_dump(obj)
68
+ expect(subject.dump obj)
69
+ end
70
+
71
+ it do
72
+ expect_dump(foo: 'bar').to eq('foo=bar')
73
+ end
74
+
75
+ it "dumps true, false and nil as #t, #f and nil" do
76
+ expect_dump(foo: true).to eq('foo=#t')
77
+ expect_dump(foo: false).to eq('foo=#f')
78
+ expect_dump(foo: nil).to eq('foo=nil')
79
+ end
80
+
81
+ it "dumps empty strings correclty" do
82
+ expect_dump(foo: '').to eq('foo=')
83
+ end
84
+
85
+ it "dumps a string with spaces surrounded by single quotes" do
86
+ expect_dump(foo: 'some" thing').to eq("foo='some\" thing'")
87
+ end
88
+
89
+ it "dumps a string with spaces and a single quote sourrounded with double quotes" do
90
+ expect_dump(foo: "foo ' bar").to eq("foo=\"foo ' bar\"")
91
+ end
92
+
93
+ it "can dump a basicobject" do
94
+ expect_dump(foo: BasicObject.new).to match(/foo=#<BasicObject:0x[0-9a-f]+>/)
95
+ end
96
+
97
+ it "can dump IO objects" do
98
+ expect_dump(foo: File.open(__FILE__)).to match(/foo=#<File:[^>]+>/)
99
+ expect_dump(foo: STDOUT).to eq("foo=#<IO:<STDOUT>>")
100
+ end
101
+
102
+ it "dumps time as ISO zulu format" do
103
+ expect_dump(foo: Time.at(1337)).to eq('foo=1970-01-01T01:22:17+01:00')
104
+ end
105
+
106
+ it "dumps symbols as strings" do
107
+ expect_dump(foo: :some_symbol).to eq('foo=some_symbol')
108
+ expect_dump(foo: :"some symbol").to eq("foo='some symbol'")
109
+ end
110
+
111
+ it "dumps numbers appropriately" do
112
+ expect_dump(foo: 10e3).to eq('foo=10000.0')
113
+ expect_dump(foo: 1).to eq('foo=1')
114
+ expect_dump(foo: -1).to eq('foo=-1')
115
+ # FIXME: don't put all the decimals
116
+ #expect_dump(foo: 4.0/3).to eq('foo=1.333')
117
+ end
118
+
119
+ it "dumps arrays appropriately" do
120
+ expect_dump(foo: [1,2,:a]).to eq('foo=[1 2 a]')
121
+ end
122
+
123
+ it "dumps [number, literal] tuples as numberliteral" do
124
+ expect_dump(foo: [3, :ms]).to eq('foo=3ms')
125
+ expect_dump(foo: [54.2, 's']).to eq('foo=54.2s')
126
+ end
127
+ end
128
+
129
+ describe Lines::UniqueIDs do
130
+ include Lines::UniqueIDs
131
+
132
+ it "generates a unique ID" do
133
+ expect(id.size).to be > 1
134
+ end
135
+
136
+ it "generates a unique ID on each call" do
137
+ id1 = id
138
+ id2 = id
139
+ expect(id1).to_not eq(id2)
140
+ end
141
+
142
+ end
@@ -0,0 +1,17 @@
1
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
2
+ RSpec.configure do |config|
3
+ config.treat_symbols_as_metadata_keys_with_true_values = true
4
+ config.run_all_when_everything_filtered = true
5
+ config.filter_run :focus
6
+
7
+ config.expect_with :rspec do |c|
8
+ c.syntax = :expect
9
+ end
10
+
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Pfenniger
@@ -9,22 +9,60 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2013-05-04 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: structured logs for humans
14
- email: jonas@pfenniger.name
42
+ email:
43
+ - jonas@pfenniger.name
15
44
  executables: []
16
45
  extensions: []
17
46
  extra_rdoc_files: []
18
47
  files:
48
+ - .rspec
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
19
52
  - README.md
53
+ - lib/lines.rb
20
54
  - lib/lines/active_record.rb
21
55
  - lib/lines/loader.rb
22
56
  - lib/lines/logger.rb
23
57
  - lib/lines/rack_logger.rb
24
58
  - lib/lines/version.rb
25
- - lib/lines.rb
59
+ - lines.gemspec
60
+ - spec/lines_loader_spec.rb
61
+ - spec/lines_spec.rb
62
+ - spec/spec_helper.rb
26
63
  homepage: https://github.com/zimbatm/lines-ruby
27
- licenses: []
64
+ licenses:
65
+ - MIT
28
66
  metadata: {}
29
67
  post_install_message:
30
68
  rdoc_options: []
@@ -45,5 +83,8 @@ rubyforge_project:
45
83
  rubygems_version: 2.0.3
46
84
  signing_key:
47
85
  specification_version: 4
48
- summary: structured logs for humans
49
- test_files: []
86
+ summary: Lines is an opinionated structured logging library
87
+ test_files:
88
+ - spec/lines_loader_spec.rb
89
+ - spec/lines_spec.rb
90
+ - spec/spec_helper.rb