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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 441d02e0372d8c97303950bdf5d570c9dfa49e2d
4
- data.tar.gz: 5ddfa720d5d750ab2ddcef66470d1bc7813d8f54
3
+ metadata.gz: d4080136a8e85e82ad9f3013e5e83c1222b3a820
4
+ data.tar.gz: 0b0ab04564fc8cfc3843dd1597ec20be6251d485
5
5
  SHA512:
6
- metadata.gz: 2f6f9b60fc8fc735cbbc6afeaead00f06f52e9fd3dd2959107ff8a5c33997ff0a30f21e61bb99b59e68a699a527584dee90ba9733159f9cbe6aa923185aa5d55
7
- data.tar.gz: abdf754b0f3e4e6ac454d5bad73c3993fbb3921cb652caece084b208d7be31afe2db14e80d72353558814c65c17c7a02d3b3989bbbd3ab14526bb4b3fb28f56e
6
+ metadata.gz: 9ace65895484af23d118109ea0ef2fe434e0793096616e936e3d4f2fb8f1e41891ca5e2f84a447db911f63e265e2391b22db2b06d9d74952ebfaa9ecb1d18e90
7
+ data.tar.gz: bfb16df6b8f7f4d6feed1d6f56f8d1a8ddf1208bf29e960a2e0b677e87688de43817af39845881c4d715e8d432bb8930122df243abab06544e3cfd1641dda572
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.50
1
+ 0.5.51
@@ -12,6 +12,7 @@ autoload :Curses, 'curses'
12
12
  autoload :DateTime, 'date'
13
13
  autoload :Date, 'date'
14
14
  autoload :Open3, 'open3'
15
+ autoload :OpenStruct, 'ostruct'
15
16
  autoload :Timeout, 'timeout'
16
17
  autoload :Find, 'find'
17
18
  autoload :Benchmark, 'benchmark'
@@ -159,4 +159,3 @@ def autoinstall(*packages)
159
159
  cmd(["sudo apt-get install ?", packages.join(' ')])
160
160
  end
161
161
  end
162
-
@@ -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, ignore=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
- _, width = STDIN.winsize
113
- width -= 1
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
- strings.join("\n")
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(amount=2)
144
- lines.map { |line| (" "*amount) + line }.join ''
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
  #
@@ -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) { |io| io.read }
214
- result.empty? ? nil : result
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 shell, but includes stderr in the result.
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]) { |io| io.read }
223
- result.empty? ? nil : result
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
@@ -1192,6 +1192,13 @@ class Path
1192
1192
  end
1193
1193
  end
1194
1194
 
1195
+ #
1196
+ # No-op (returns self)
1197
+ #
1198
+ def to_Path
1199
+ self
1200
+ end
1201
+
1195
1202
  end
1196
1203
 
1197
1204
 
data/lib/epitools/wm.rb CHANGED
@@ -49,6 +49,8 @@ module WM
49
49
  current
50
50
  end
51
51
 
52
+ alias_method :active?, :current?
53
+
52
54
  def windows
53
55
  @windows ||= WM.windows.select { |w| w.desktop_id == num }
54
56
  end
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.50
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-04-25 00:00:00.000000000 Z
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.0.14
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: