epitools 0.5.21 → 0.5.22

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: ec682c3e5cd19ec44f4df3837bf92ec26e4d7b3e
4
- data.tar.gz: f5a2728b25e66c141a1b7153e7d18de8349f2e63
3
+ metadata.gz: fe4475f902e2c9728b707d9aa36f2fd8922ea7e0
4
+ data.tar.gz: 9c86c70534eb727596fcd018afd7f7c0e4edf258
5
5
  SHA512:
6
- metadata.gz: 584de2d271d5bd5d24073caef0956207aaee12f36d9203495f1014f7aa3534316fe79d6d4a33b10b8feeb01a0b9ec4f909ae1d84a0c4e2f664c89ad2e7741f71
7
- data.tar.gz: eb2cb6d956f8c9e2727ff8a886322ac2c747c6205c0bfe7811949dd2f4deb3c9aa299b21870fc23570fee9bfdc79a7f7f98a054daae4e542b3e35afbea1c88fb
6
+ metadata.gz: 7a251525b9b9856f72e0c46644be4126bec6fb23b5cc286acefc9c1f8b23ea613c25c928d0b526baea440de6ba99a8c39a1380ac79306ded00759ae98190a09e
7
+ data.tar.gz: 7fb5bc4889d33df063834e767391586cbb2bbf59fc391f5e2eb86f422040f4d8e966864a15dabf7de62d1de752fa7a07b959ce19b380571961f42f306631fdc3
data/TODO CHANGED
@@ -6,10 +6,8 @@
6
6
  |_ Fix rename/mv
7
7
  |_ Full README with more real-world examples (grep scripts/)
8
8
  - compare folders using Path#ls_r and Path#md5
9
- |_ Group methods by type, like Pathname (does YARD have groups?)
10
- |_ String#{to_p,to_P,to_Path} ?
11
- |_ Relative Path class
12
- |_ Class hierarchy (Path, FilePath, URLPath)
9
+ |_ Documentation: categorize methods for large classes (the way Pathname does)
10
+ |_ Organize into a class hierarchy (Path, FilePath, URLPath, RelativePath)
13
11
  |_ (Un)Archivers (zip, rar, etc.)
14
12
 
15
13
  + Logger
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.21
1
+ 0.5.22
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  module Enumerable
4
2
 
5
3
  #
@@ -346,6 +344,19 @@ module Enumerable
346
344
  end
347
345
  alias_method :iter, :to_iter
348
346
 
347
+ #
348
+ # Counts how many instances of each object are in the collection,
349
+ # returning a hash.
350
+ #
351
+ # eg: [:a, :b, :c, :c, :c, :c].counts #=> {:a=>1, :b=>1, :c=>4}
352
+ #
353
+ def counts
354
+ h = Hash.of_integers
355
+ each { |x| h[x] += 1 }
356
+ h
357
+ end
358
+ alias_method :counted, :counts
359
+ alias_method :grouped, :counts
349
360
 
350
361
  end
351
362
 
@@ -24,11 +24,26 @@ class Object
24
24
  #
25
25
  # (All this method does is dup the object, then call "key=(value)" for each
26
26
  # key/value in the options hash.)
27
+ #
28
+ # == BONUS FEATURE! ==
29
+ #
30
+ # If you supply a block, it just gives you the object, and
31
+ # returns whatever your block returns.
32
+ #
33
+ # Example:
34
+ # >> {a: 10, b: 2}.with { |hash| hash[:a] / hash[:b] }
35
+ # => 5
36
+ #
37
+ # Good for chaining lots of operations together in a REPL.
27
38
  #
28
39
  def with(options={})
29
- obj = dup
30
- options.each { |key, value| obj.send "#{key}=", value }
31
- obj
40
+ if block_given?
41
+ yield self
42
+ else
43
+ obj = dup
44
+ options.each { |key, value| obj.send "#{key}=", value }
45
+ obj
46
+ end
32
47
  end
33
48
 
34
49
  #
@@ -244,14 +244,6 @@ class String
244
244
  end
245
245
  alias_method :from_marshal, :unmarshal
246
246
 
247
- #
248
- # Convert the string to a Path object (for representing files/directories).
249
- #
250
- def to_Path
251
- Path[self]
252
- end
253
- alias_method :to_P, :to_Path
254
-
255
247
  #
256
248
  # Convert this string into a string describing this many of the string.
257
249
  # (Note: Doesn't know anything about proper grammar.)
@@ -141,6 +141,21 @@ class Object
141
141
  send(method, *args, &block) if respond_to? method
142
142
  end
143
143
 
144
+ #
145
+ # Return this object. If given a block, yields this object
146
+ # and returns the result of the block.
147
+ #
148
+ # eg: stuff.group_by(&:self)
149
+ #
150
+ def self
151
+ if block_given?
152
+ yield self
153
+ else
154
+ self
155
+ end
156
+ end
157
+ alias_method :fap, :self
158
+
144
159
  end
145
160
 
146
161
  #
@@ -177,6 +192,18 @@ class Module
177
192
  end
178
193
 
179
194
 
195
+ class String
196
+
197
+ #
198
+ # Convert the string to a Path object (for representing files/directories).
199
+ #
200
+ def to_Path
201
+ Path[self]
202
+ end
203
+ alias_method :to_P, :to_Path
204
+
205
+ end
206
+
180
207
  #
181
208
  # Path("/some/path") is an alias for Path["/some/path"]
182
209
  #
@@ -324,7 +324,7 @@ describe Path do
324
324
  Path.which("ruby").should_not be_nil
325
325
  Path.which("asdfasdfhkajlsdhfkljashdf").should be_nil
326
326
  Path.which("ruby").class.should == Path
327
- Path.which("ps", "sh", "tar").should == ["/bin/ps", "/bin/sh", "/bin/tar"]
327
+ Path.which("ps", "sh", "tar").map(&:path).should == ["/bin/ps", "/bin/sh", "/usr/bin/tar"]
328
328
  end
329
329
 
330
330
  it "Path[]s another path" 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.21
4
+ version: 0.5.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - epitron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-25 00:00:00.000000000 Z
11
+ date: 2013-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.0.0
125
+ rubygems_version: 2.0.3
126
126
  signing_key:
127
127
  specification_version: 3
128
128
  summary: Not utils... METILS!