press 0.4 → 0.5

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- press (0.4)
4
+ press (0.5)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/press.rb CHANGED
@@ -2,6 +2,10 @@ require "press/printer"
2
2
 
3
3
  module Press
4
4
 
5
+ def ctx(data)
6
+ Printer.ctx = data
7
+ end
8
+
5
9
  def pd(*data, &blk)
6
10
  Printer.pd *data, &blk
7
11
  end
data/lib/press/printer.rb CHANGED
@@ -3,6 +3,14 @@ require "time"
3
3
  module Press
4
4
  module Printer
5
5
 
6
+ def self.ctx
7
+ @ctx ||= {}
8
+ end
9
+
10
+ def self.ctx=(data)
11
+ @ctx = data
12
+ end
13
+
6
14
  def self.pd(*data, &blk)
7
15
  write $stdout, hashify(*data, {}), &blk
8
16
  end
@@ -20,7 +28,7 @@ module Press
20
28
  end
21
29
 
22
30
  def self.hashify(*data, initial)
23
- data.compact.reduce(initial) { |d, v| d.merge v }
31
+ data.compact.reduce(ctx.merge(initial)) { |d, v| d.merge v }
24
32
  end
25
33
 
26
34
  def self.stringify(data)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: press
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
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: 2012-05-24 00:00:00.000000000Z
12
+ date: 2012-05-31 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Data and exception printer.
15
15
  email: mark.fine@gmail.com