rumbrl 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07a6a2a240ee65e47ad44c9b0578285a078a4542
4
- data.tar.gz: 46f4580f7b3fde5dbbadedf707ef468d43496ee1
3
+ metadata.gz: 9df154c45e87dfaba90a89c8b7d27b72d892bc32
4
+ data.tar.gz: 37d72e10c60b45e74703cc2ac2eed95081228d16
5
5
  SHA512:
6
- metadata.gz: 97c2bf4d0af6e1c4c60eb5e19048d5ce732c7d702249c13ea520acb5bcc6dbda1fd24ccb9d65631ad60e5027f0157710a541bf3f32a45522a4e1abd067a3608a
7
- data.tar.gz: 6f0e513f48c72bf75bec290629806d73d0fbe269ea8ce0a42ac929fc7a064011bec5f20db7af4c2188289c1bced0e1be1b91cbde57cdf85c5722287a5b03501f
6
+ metadata.gz: ec8067e052e6da3f7067b1a4881755b096a92f7b1c9a6f522e5939462c5480e46213df15bd34d9ee6220d052874b0445fa00665ef04cae3b1bfcce4ce35f562d
7
+ data.tar.gz: 72295fd53f6704373a10fc771b6d24e8620abb6b4fe1531f643ca645ca7a32cce1b92227ca04a253c96870dbe45604f03b8fee4ea7b9b07e4b04508f3fa62da2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rumbrl (0.2.3)
4
+ rumbrl (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,4 +1,5 @@
1
1
  require 'rumbrl/log'
2
+ require 'rumbrl/smash'
2
3
 
3
4
  module Rumbrl
4
5
  # Behance specific logger
@@ -13,6 +14,7 @@ module Rumbrl
13
14
 
14
15
  def method_missing(name, channel, message, **args)
15
16
  format = BASE_LOG_FORMAT
17
+ args = Smash.flatten(args)
16
18
  args.each do |k, v|
17
19
  format += " #{k.to_s.upcase}='#{v.to_s.gsub("'", '"')}'"
18
20
  end
data/lib/rumbrl/smash.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  module Rumbrl
2
2
  # serializes & flattens hashes
3
3
  class Smash
4
- def self.face(namespace: '', **target)
4
+ def self.flatten(namespace: '', **target)
5
5
  res = {}
6
6
  # flattens a hash
7
7
  target.each do |k, v|
8
8
  cur_nspace = build_namespace(namespace, k)
9
9
  if v.is_a? Hash
10
- res.update face(**v, namespace: cur_nspace)
10
+ res.update flatten(**v, namespace: cur_nspace)
11
11
  next
12
12
  end
13
13
  res[cur_nspace.to_sym] = v
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version const for gem
4
4
  module Rumbrl
5
- VERSION = '0.2.3'
5
+ VERSION = '0.3.0'
6
6
  end
@@ -35,9 +35,11 @@ describe Rumbrl::Grumble do
35
35
  log = Rumbrl::Grumble.new('path/to/log', 'weekly', 123)
36
36
 
37
37
  line = /\[.*\] LEVEL='INFO' CHANNEL='channel' MESSAGE='msg' FOO='bar'\n/
38
+ hash = { foo: 'bar' }
38
39
  expect_any_instance_of(Logger::LogDevice).to receive(:write).with(line)
40
+ expect(Rumbrl::Smash).to receive(:flatten).with(hash).and_return(hash)
39
41
 
40
- log.info('channel', 'msg', foo: 'bar')
42
+ log.info('channel', 'msg', hash)
41
43
  end
42
44
  end
43
45
  end
@@ -1,16 +1,16 @@
1
1
  require_relative '../spec_helper'
2
2
 
3
3
  describe Rumbrl::Smash do
4
- describe '.face' do
4
+ describe '.flatten' do
5
5
  it 'does not change flat hash' do
6
6
  target = { bar: 'foo' }
7
- expect(Rumbrl::Smash.face(target)).to eql target
7
+ expect(Rumbrl::Smash.flatten(target)).to eql target
8
8
  end
9
9
 
10
10
  it 'flattens nested hashes with namespaced keys' do
11
11
  target = { bar: 'foo', baz: { wee: 'boo' } }
12
12
  flattened = { bar: 'foo', baz_wee: 'boo' }
13
- expect(Rumbrl::Smash.face(target)).to eql flattened
13
+ expect(Rumbrl::Smash.flatten(target)).to eql flattened
14
14
  end
15
15
  end
16
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumbrl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chr0n1x