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 +4 -4
- data/lib/inkjet/indent.rb +22 -7
- data/lib/inkjet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e776686b44393fc5089001ea78be5a78b499387
|
4
|
+
data.tar.gz: ac9a4343d72fa1346fc3788029ca224b1b377eb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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,
|
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,
|
77
|
+
def self.print(output='')
|
78
|
+
STDOUT.print apply_formatters(indent(output, @@spaces))
|
64
79
|
end
|
65
80
|
|
66
81
|
module String
|
data/lib/inkjet/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2013-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|