lines 0.1.18 → 0.1.19

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODA2Y2ZhNTJmYzQwYTE4ZDU1NjNhNDQ4MWVhNzAxZmMwZDcyY2U4ZA==
4
+ MjI0OWIzNjUxNDMzZjFiOGFjYjQ2NWY0YzBiMGFkNGRiNTkyM2Q1YQ==
5
5
  data.tar.gz: !binary |-
6
- Nzc3ZTEzMDczYmI1ZGVhNjk3YmFhOGQzODhjYjUzOTU1NDkxNjM3Mw==
6
+ Y2EzOWYzNDlmZjkyMGRlZDJkNWFjNGU0NjYyNzU1YTZkYzUwYjlkNg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YmQyNDJkZjEwMjdlOWMwMGIyMjQwYzM0Y2NhMTk0ZGNkYjk2OWZkZTg4MWQx
10
- NTRlMjZmNDkyNzM2ZTZjODljZmFiMzNkMWM2NzI5ZjMzZmM0ODVhNTExY2Ew
11
- MzZjN2Y2YzE4MDY4Y2QzMjUyZTk3MWZiMDFmZDUyOTUyMTUzZjg=
9
+ NGY3YTIwMmExZDM0OGI3OTQ4YTA3ZmJiODkyNzUzMzIxMTZiYmFmMWEyYmUy
10
+ NWM4YTQ4M2VlNjc5ZDlmNmEwZDM2MTZkYWI0NDJiYjA3YjBhZTlhMGI1MDAx
11
+ YzNkMmMwNmJiZGU0MTc4YjM0MzhkN2VkOGMzZDBiN2U1MmVkZjI=
12
12
  data.tar.gz: !binary |-
13
- NDQxOTdiMTc0ODk5MjBhYjNmY2JhOTcwZDk1ZTUzNmRlODRkOTdlMGY4MGVm
14
- NTA1NTdkYzdjYjYyODBlNTA3N2RjMGY0M2RkY2U0ODUyYTU2MjA3ZDg2YTQy
15
- MjRkNzdhZmZiYmY3MGI1ZGEyNGQxYjU4MDU5N2I5MzQzOTllMGI=
13
+ NTcwMTE4YmIxMmU2MTE3YTZhY2Q5NzNlMDg4NTBhODY5N2MxMTY2NWVjYzli
14
+ NGNjMzE1ZWFmMDBjNGQ0NTE1NDFhMDY3YWI4MDQ3MDQ0MmMxY2ZjMTliMzU5
15
+ ZTUxM2Y1OWQ5NmQ5MGQwZThmODNhOWFhYWQwYzkwYWEyODBjOTY=
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - jruby-19mode
7
+ - rbx-19mode
data/Gemfile CHANGED
@@ -3,5 +3,8 @@ gemspec
3
3
  group :development do
4
4
  gem 'parslet'
5
5
  gem 'rdoc'
6
+ end
7
+ group :test do
6
8
  gem 'rspec'
9
+ gem 'rake'
7
10
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lines (0.1.16)
4
+ lines (0.1.18)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -11,6 +11,7 @@ GEM
11
11
  json (1.7.7)
12
12
  parslet (1.5.0)
13
13
  blankslate (~> 2.0)
14
+ rake (0.9.2.2)
14
15
  rdoc (4.0.0)
15
16
  json (~> 1.4)
16
17
  rspec (2.13.0)
@@ -26,7 +27,9 @@ PLATFORMS
26
27
  ruby
27
28
 
28
29
  DEPENDENCIES
30
+ bundler (~> 1.3)
29
31
  lines!
30
32
  parslet
33
+ rake
31
34
  rdoc
32
35
  rspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  Lines - structured logs for humans
2
2
  ==================================
3
+ [![Build
4
+ Status](https://travis-ci.org/zimbatm/lines-ruby.png)](https://travis-ci.org/zimbatm/lines-ruby)
3
5
 
4
6
  An oppinionated logging library that implement the
5
7
  [lines](https://github.com/zimbatm/lines) format.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new
3
+ task default: :spec
4
+
data/lib/lines.rb CHANGED
@@ -237,16 +237,24 @@ module Lines
237
237
  @mapping[klass] = rule
238
238
  end
239
239
 
240
+ attr_accessor :max_depth
241
+
240
242
  protected
241
243
 
242
244
  attr_reader :mapping
243
245
 
244
246
  def initialize
245
247
  @mapping = {}
248
+ @max_depth = 3
246
249
  end
247
250
 
248
- def objenc_internal(x)
249
- x.map{|k,v| "#{keyenc(k)}=#{valenc(v)}" }.join(' ')
251
+ def objenc_internal(x, depth=0)
252
+ depth += 1
253
+ if depth > max_depth
254
+ '...'
255
+ else
256
+ x.map{|k,v| "#{keyenc(k)}=#{valenc(v, depth)}" }.join(' ')
257
+ end
250
258
  end
251
259
 
252
260
  def keyenc(k)
@@ -257,10 +265,10 @@ module Lines
257
265
  end
258
266
  end
259
267
 
260
- def valenc(x)
268
+ def valenc(x, depth)
261
269
  case x
262
- when Hash then objenc(x)
263
- when Array then arrenc(x)
270
+ when Hash then objenc(x, depth)
271
+ when Array then arrenc(x, depth)
264
272
  when String, Symbol then strenc(x)
265
273
  when Numeric then numenc(x)
266
274
  when Time, Date then timeenc(x)
@@ -272,16 +280,19 @@ module Lines
272
280
  end
273
281
  end
274
282
 
275
- def objenc(x)
276
- '{' + objenc_internal(x) + '}'
283
+ def objenc(x, depth)
284
+ '{' + objenc_internal(x, depth) + '}'
277
285
  end
278
286
 
279
- def arrenc(a)
287
+ def arrenc(a, depth)
288
+ depth += 1
280
289
  # num + unit. Eg: 3ms
281
290
  if a.size == 2 && a.first.kind_of?(Numeric) && is_literal?(a.last.to_s)
282
291
  numenc(a.first) + strenc(a.last)
292
+ elsif depth > max_depth
293
+ '[...]'
283
294
  else
284
- '[' + a.map{|x| valenc(x)}.join(' ') + ']'
295
+ '[' + a.map{|x| valenc(x, depth)}.join(' ') + ']'
285
296
  end
286
297
  end
287
298
 
@@ -320,7 +331,7 @@ module Lines
320
331
  end
321
332
 
322
333
  def timeenc(t)
323
- t.iso8601
334
+ t.utc.iso8601
324
335
  end
325
336
 
326
337
  def is_literal?(s)
data/lib/lines/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lines
2
- VERSION = "0.1.18"
2
+ VERSION = "0.1.19"
3
3
  end
data/spec/lines_spec.rb CHANGED
@@ -95,12 +95,12 @@ describe Lines::Dumper do
95
95
  end
96
96
 
97
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>>")
98
+ expect_dump(foo: File.open(__FILE__)).to match(/foo='?#<File:[^>]+>'?/)
99
+ expect_dump(foo: STDOUT).to match(/^foo=(?:#<IO:<STDOUT>>|'#<IO:fd 1>')$/)
100
100
  end
101
101
 
102
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')
103
+ expect_dump(foo: Time.at(1337)).to eq('foo=1970-01-01T00:22:17Z')
104
104
  end
105
105
 
106
106
  it "dumps symbols as strings" do
@@ -124,6 +124,12 @@ describe Lines::Dumper do
124
124
  expect_dump(foo: [3, :ms]).to eq('foo=3ms')
125
125
  expect_dump(foo: [54.2, 's']).to eq('foo=54.2s')
126
126
  end
127
+
128
+ it "knows how to handle circular dependencies" do
129
+ x = {}
130
+ x[:x] = x
131
+ expect_dump(x).to eq('x={x={x={...}}}')
132
+ end
127
133
  end
128
134
 
129
135
  describe Lines::UniqueIDs do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Pfenniger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-04 00:00:00.000000000 Z
11
+ date: 2013-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -46,10 +46,12 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - .rspec
49
+ - .travis.yml
49
50
  - Gemfile
50
51
  - Gemfile.lock
51
52
  - LICENSE.txt
52
53
  - README.md
54
+ - Rakefile
53
55
  - lib/lines.rb
54
56
  - lib/lines/active_record.rb
55
57
  - lib/lines/loader.rb