epitools 0.5.63 → 0.5.64

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01cb576c29752c5f1213210a5fde6afbb21d2b24
4
- data.tar.gz: cb4ef1ef088ffd7171cc2e4730a21e95d6d858d2
3
+ metadata.gz: c97e30eb1552bb115bad441fa21bf0c5e1a58a10
4
+ data.tar.gz: 5559b075618fdc77e4bc55ece12b42dc8cf4ad49
5
5
  SHA512:
6
- metadata.gz: 1677a2683547b51b9d3f3808859e59a2c3282130d99f35b6d7e41b9d8d0cee4ce595af177305b3450400ca1aaeed1ab05ab6a69b58b7df347ce2e20a80ecfad8
7
- data.tar.gz: 309c475a1afa44736c3e6c5baca3c458b4bd7c6d1d6762054b21d4c6a32683e7a0d1351aefe335eb563ffc04ae3566e46bb427669eaa6db4a2e8fcc4598007c7
6
+ metadata.gz: b61f7535b2d27d437bedc30197de4de5b09a4d2234f8580c33779a37b9337031e31a6e071995ffeb111ef87a195dec7502ee5aba42b15d7899d836a5980888bf
7
+ data.tar.gz: cb9807f3b5953ece8e40171aa48363042c5610a28aea82c1702f6b7ce3c2f536106294f7b06a45b42b86491715b83b05267d65b15609fdf14e46df3cd51f97fb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.63
1
+ 0.5.64
@@ -59,6 +59,14 @@ autoreq :ANSI, 'ansi'
59
59
  autoreq :BSON, 'bson'
60
60
  autoreq :JSON, 'json'
61
61
 
62
+ autoreq :AwesomePrint do
63
+ require 'awesome_print'
64
+
65
+ autoreq :Nokogiri do
66
+ require 'nokogiri'
67
+ require 'awesome_print/ext/nokogiri'
68
+ end
69
+ end
62
70
 
63
71
  ## Network stuff
64
72
 
@@ -1,3 +1,6 @@
1
+
2
+ Number = Numeric # "obj.is_a? Number" just sounds better.
3
+
1
4
  class Numeric
2
5
 
3
6
  def integer?; true; end
@@ -141,8 +141,12 @@ class String
141
141
  alias_method :indent_html, :nice_html
142
142
 
143
143
  #
144
- # Wrap the lines in the string so they're at most "width" wide.
145
- # (If no width is specified, defaults to the width of the terminal.)
144
+ # Word-wrap the string so each line is at most `width` wide.
145
+ # Returns a string, or, if a block is given, yields each
146
+ # word-wrapped line to the block.
147
+ #
148
+ # If `width` is nil, find the current width of the terminal and use that.
149
+ # If `width` is negative, subtract `width` from the terminal's current width.
146
150
  #
147
151
  def wrap(width=nil)
148
152
  if width.nil? or width < 0
@@ -150,7 +154,7 @@ class String
150
154
  _, winwidth = STDIN.winsize
151
155
 
152
156
  if width < 0
153
- width = (winwidth + width) - 1
157
+ width = (winwidth - 1) + width
154
158
  else
155
159
  width = winwidth - 1
156
160
  end
@@ -184,18 +188,26 @@ class String
184
188
  end
185
189
  end
186
190
 
191
+ alias_method :word_wrap, :wrap
192
+
193
+
187
194
  #
188
195
  # Wrap all lines at window size, and indent
189
196
  #
190
- def wrapdent(prefix, width=nil)
197
+ def wrap_and_indent(prefix, width=nil)
198
+ prefix = " "*prefix if prefix.is_a? Numeric
199
+
200
+ prefix_size = prefix.strip_color.size
201
+
191
202
  if width
192
- width = width - prefix.size
203
+ width = width - prefix_size
193
204
  else
194
- width = -prefix.size
205
+ width = -prefix_size
195
206
  end
196
207
 
197
208
  wrap(width).each_line.map { |line| prefix + line }.join
198
209
  end
210
+ alias_method :wrapdent, :wrap_and_indent
199
211
 
200
212
  #
201
213
  # Iterate over slices of the string of size `slice_width`.
@@ -747,7 +747,7 @@ end
747
747
  describe ObjectSpace do
748
748
 
749
749
  it "is Enumerable" do
750
- ObjectSpace.select { |o| o.is_a? String }.map { |o| o.class.name }.uniq.should == ["String"]
750
+ ObjectSpace.select { |o| o.is_a? ObjectSpace }.map { |o| o.class.name }.uniq.should == ["Module"]
751
751
  end
752
752
 
753
753
  end
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.63
4
+ version: 0.5.64
5
5
  platform: ruby
6
6
  authors:
7
7
  - epitron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-30 00:00:00.000000000 Z
11
+ date: 2015-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec