epitools 0.5.50 → 0.5.51
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/epitools/autoloads.rb +1 -0
- data/lib/epitools/clitools.rb +0 -1
- data/lib/epitools/core_ext/string.rb +37 -7
- data/lib/epitools/minimal.rb +9 -5
- data/lib/epitools/path.rb +7 -0
- data/lib/epitools/wm.rb +2 -0
- data/spec/term_spec.rb +20 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4080136a8e85e82ad9f3013e5e83c1222b3a820
|
4
|
+
data.tar.gz: 0b0ab04564fc8cfc3843dd1597ec20be6251d485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ace65895484af23d118109ea0ef2fe434e0793096616e936e3d4f2fb8f1e41891ca5e2f84a447db911f63e265e2391b22db2b06d9d74952ebfaa9ecb1d18e90
|
7
|
+
data.tar.gz: bfb16df6b8f7f4d6feed1d6f56f8d1a8ddf1208bf29e960a2e0b677e87688de43817af39845881c4d715e8d432bb8930122df243abab06544e3cfd1641dda572
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.51
|
data/lib/epitools/autoloads.rb
CHANGED
data/lib/epitools/clitools.rb
CHANGED
@@ -106,11 +106,16 @@ class String
|
|
106
106
|
# Wrap the lines in the string so they're at most "width" wide.
|
107
107
|
# (If no width is specified, defaults to the width of the terminal.)
|
108
108
|
#
|
109
|
-
def wrap(width=nil,
|
110
|
-
if width.nil?
|
109
|
+
def wrap(width=nil, strip_ansi=true)
|
110
|
+
if width.nil? or width < 0
|
111
111
|
require 'io/console'
|
112
|
-
_,
|
113
|
-
|
112
|
+
_, winwidth = STDIN.winsize
|
113
|
+
|
114
|
+
if width < 0
|
115
|
+
width = (winwidth + width) - 1
|
116
|
+
else
|
117
|
+
width = winwidth - 1
|
118
|
+
end
|
114
119
|
end
|
115
120
|
|
116
121
|
return self if size <= width
|
@@ -134,14 +139,39 @@ class String
|
|
134
139
|
end
|
135
140
|
end
|
136
141
|
|
137
|
-
|
142
|
+
if block_given?
|
143
|
+
strings.each { |s| yield s }
|
144
|
+
else
|
145
|
+
strings.join("\n")
|
146
|
+
end
|
138
147
|
end
|
139
148
|
|
140
149
|
#
|
141
150
|
# Indent all the lines in the string by "amount" of spaces.
|
142
151
|
#
|
143
|
-
def indent(
|
144
|
-
|
152
|
+
def indent(prefix=" ", strip_ansi=true)
|
153
|
+
prefix = (" " * prefix) if prefix.is_an? Integer
|
154
|
+
|
155
|
+
if block_given?
|
156
|
+
lines.each { |line| yield prefix + line }
|
157
|
+
else
|
158
|
+
lines.each { |line| prefix + line }.join ''
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
#
|
163
|
+
# Wrap all lines at window size, and indent
|
164
|
+
#
|
165
|
+
def wrapdent(prefix, width=nil)
|
166
|
+
prefix_size = prefix.strip_ansi.size
|
167
|
+
|
168
|
+
if width
|
169
|
+
width = width - prefix_size
|
170
|
+
else
|
171
|
+
width = -prefix_size
|
172
|
+
end
|
173
|
+
|
174
|
+
wrap(width).map { |line| line + prefix }.join("\n")
|
145
175
|
end
|
146
176
|
|
147
177
|
#
|
data/lib/epitools/minimal.rb
CHANGED
@@ -210,17 +210,21 @@ module Kernel
|
|
210
210
|
# but doesn't require shell ecaping arguments.)
|
211
211
|
#
|
212
212
|
def run(*cmd)
|
213
|
-
result = IO.popen(cmd)
|
214
|
-
|
213
|
+
result = IO.popen(cmd) do |io|
|
214
|
+
block_given? ? yield(io) : io.read
|
215
|
+
end
|
216
|
+
String === result && result.empty? ? nil : result
|
215
217
|
end
|
216
218
|
alias_method :backtick, :run
|
217
219
|
|
218
220
|
#
|
219
|
-
# Same as
|
221
|
+
# Same as Kernel#run, but includes stderr in the result.
|
220
222
|
#
|
221
223
|
def run_with_stderr(*cmd)
|
222
|
-
result = IO.popen(cmd, err: [:child, :out])
|
223
|
-
|
224
|
+
result = IO.popen(cmd, err: [:child, :out]) do |io|
|
225
|
+
block_given? ? yield(io) : io.read
|
226
|
+
end
|
227
|
+
String === result && result.empty? ? nil : result
|
224
228
|
end
|
225
229
|
alias_method :backtick_with_stderr, :run_with_stderr
|
226
230
|
|
data/lib/epitools/path.rb
CHANGED
data/lib/epitools/wm.rb
CHANGED
data/spec/term_spec.rb
CHANGED
@@ -26,6 +26,26 @@ describe Term do
|
|
26
26
|
table.by_columns.should_not be_nil
|
27
27
|
table.by_rows.should_not be_nil
|
28
28
|
|
29
|
+
Term::Table do |table|
|
30
|
+
100.times do |n|
|
31
|
+
table.row do
|
32
|
+
col "#{n}."
|
33
|
+
col "A" * rand(10)
|
34
|
+
col "B" * rand(10)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Term::Table[
|
40
|
+
[1,2,3],
|
41
|
+
[4,5,6]
|
42
|
+
]
|
43
|
+
|
44
|
+
table = Term::Table.new
|
45
|
+
table.rows = [ [1,2,3], [4,5,6] ]
|
46
|
+
table.rows << [1,2,3]
|
47
|
+
table.rows << [4,5,6]
|
48
|
+
table.add_row [1,2,3,4,5]
|
29
49
|
end
|
30
50
|
|
31
51
|
it "tables nothing" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epitools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.51
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- epitron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -125,9 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.2.2
|
129
129
|
signing_key:
|
130
130
|
specification_version: 3
|
131
131
|
summary: Not utils... METILS!
|
132
132
|
test_files: []
|
133
|
-
has_rdoc:
|