inkjet 0.0.5 → 0.0.6

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: 233f3dfad49a1beb08760b9103772c2cc037e3f2
4
- data.tar.gz: a317f8e4542d17291bd2d55087a0151bbcd93291
3
+ metadata.gz: 6e776686b44393fc5089001ea78be5a78b499387
4
+ data.tar.gz: ac9a4343d72fa1346fc3788029ca224b1b377eb0
5
5
  SHA512:
6
- metadata.gz: 26d2474dd3e67c76bab42f16da93c2edb0b6cf6a57cee53700f54ed3f7939bc6dfd1604270e2b64574b0edb5be2a6bf9e216e93921bc623686ba61b4a6379c52
7
- data.tar.gz: 0df47b052ec940a56960779b9a397519ce12066480111f603a40b5d4cac0a7714a422d3a98a714771187e0319793b18985db8c1331255e7caec42e91ead989a7
6
+ metadata.gz: 3ec3bca2479bff13da610174579b7cf046bb0d56fc992a9ff61348e0b09b25a3740955d555bb792aa451974655a518845ca258ce64f963f7fc02eeeb6aac76fd
7
+ data.tar.gz: 321c71f17aa648e3a92dd662b8de5e7a9d918b80f3a9f92496c2c0f72b85ef711eb547c314cd20345b802c3a46a0f8d9f0cd2b1bbb6ea64d406b6e424b089d54
data/lib/inkjet/indent.rb CHANGED
@@ -16,9 +16,10 @@ module Inkjet
16
16
  end
17
17
 
18
18
  def self.add_bindings(block)
19
- block.binding.eval("def puts(output); Inkjet::Indent.puts(output); end")
20
- block.binding.eval("def print(output); Inkjet::Indent.print(output); end")
19
+ block.binding.eval("def puts(output=''); Inkjet::Indent.puts(output); end")
20
+ block.binding.eval("def print(output=''); Inkjet::Indent.print(output); end")
21
21
  block.binding.eval("def format_with(meth, *args); Inkjet::Indent.format_with(meth, *args); end")
22
+ block.binding.eval("def undent(&block); Inkjet::Indent.undent(&block); end")
22
23
  block
23
24
  end
24
25
 
@@ -34,7 +35,21 @@ module Inkjet
34
35
  @@spaces -= args[0] || TABSTOP
35
36
  else
36
37
  spaces = args[1] || TABSTOP
37
- "#{padding(@@spaces + spaces.to_i)}#{args[0].to_s.split("\n").join("\n#{padding(@@spaces + spaces.to_i)}")}"
38
+ "#{padding(spaces.to_i)}#{args[0].to_s.split("\n").join("\n#{padding(spaces.to_i)}")}"
39
+ end
40
+ end
41
+
42
+ def self.undent(&block)
43
+ @@spaces ||= 0
44
+ if block_given?
45
+ scoped_spaces = @@spaces
46
+ @@spaces = 0
47
+ scoped_formatters = formatters.clone
48
+
49
+ add_bindings(block).call
50
+
51
+ @@formatters = scoped_formatters
52
+ @@spaces = scoped_spaces
38
53
  end
39
54
  end
40
55
 
@@ -55,12 +70,12 @@ module Inkjet
55
70
  spaces.times.map {" "}.join
56
71
  end
57
72
 
58
- def self.puts(output)
59
- STDOUT.puts apply_formatters(indent(output, 0))
73
+ def self.puts(output='')
74
+ STDOUT.puts apply_formatters(indent(output, @@spaces))
60
75
  end
61
76
 
62
- def self.print(output)
63
- STDOUT.print apply_formatters(indent(output, 0))
77
+ def self.print(output='')
78
+ STDOUT.print apply_formatters(indent(output, @@spaces))
64
79
  end
65
80
 
66
81
  module String
@@ -1,3 +1,3 @@
1
1
  module Inkjet
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inkjet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-10 00:00:00.000000000 Z
11
+ date: 2013-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport