epitools 0.5.16 → 0.5.17

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.
data/README.rdoc CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  Useful miscellaneous improvements for base Ruby objects, plus some extra
4
4
  data structures and handy wrappers. (Think of it as a light-weight version
5
- of ActiveSupport. All modules are loaded on demand with `autoload`.)
5
+ of ActiveSupport.
6
+
7
+ All epitools modules (and a bunch of Ruby's stdlib) are
8
+ {loaded on demand with "autoload"}[https://github.com/epitron/epitools/blob/master/lib/epitools/autoloads.rb],
9
+ so it's really fast. (Require this in your .irbrc or .pryrc, and you'll never have to require another Ruby stdlib module again!)
6
10
 
7
11
  Enhanced base classes: {Enumerable}[http://rdoc.info/github/epitron/epitools/master/Enumerable], {Hash}[http://rdoc.info/github/epitron/epitools/master/Hash], {String}[http://rdoc.info/github/epitron/epitools/master/String], {Array}[http://rdoc.info/github/epitron/epitools/master/Array], {Object}[http://rdoc.info/github/epitron/epitools/master/Object], {Integer}[http://rdoc.info/github/epitron/epitools/master/Integer], etc.
8
12
 
@@ -32,7 +36,7 @@ or check out the rdoc: http://rdoc.info/github/epitron/epitools/master/frames
32
36
 
33
37
  == Copyright
34
38
 
35
- Copyright (c) 2009-2012 epitron
39
+ Copyright (c) 2009-2013 epitron
36
40
 
37
41
  == License
38
42
 
data/Rakefile CHANGED
@@ -7,3 +7,7 @@ end
7
7
  task :release => :build do
8
8
  system "gem push epitools-#{VERSION}.gem"
9
9
  end
10
+
11
+ task :install => :build do
12
+ system "gem install epitools-#{VERSION}.gem"
13
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.16
1
+ 0.5.17
@@ -17,6 +17,7 @@ autoload :Timeout, 'timeout'
17
17
  autoload :Find, 'find'
18
18
  autoload :Benchmark, 'benchmark'
19
19
  autoload :Tracer, 'tracer'
20
+ autoload :CSV, 'csv'
20
21
  #autoload :DelegateClass, 'delegate'
21
22
 
22
23
  # YAML is sometimes loaded improperly.
@@ -36,11 +36,11 @@ class Browser
36
36
  #
37
37
  def initialize(options={})
38
38
  @last_get = Time.at(0)
39
- @delay = options[:delay] || 1
40
- @delay_jitter = options[:delay_jitter] || 0.2
41
- @use_cache = options[:cache] || true
42
- @use_logs = options[:logs] || false
43
- @cookie_file = options[:cookiefile] || "cookies.txt"
39
+ @delay = options[:delay] || 1
40
+ @delay_jitter = options[:delay_jitter] || 0.2
41
+ @use_cache = options[:cache] == false || true
42
+ @use_logs = options[:logs] || false
43
+ @cookie_file = options[:cookiefile] || "cookies.txt"
44
44
 
45
45
  # TODO: @progress, @user_agent, @logfile, @cache_file (default location: ~/.epitools?)
46
46
 
@@ -62,6 +62,23 @@ class Hash
62
62
  dup.map_keys!(&block)
63
63
  end
64
64
 
65
+ #
66
+ # Returns a hash containing only the keys passed as arguments.
67
+ #
68
+ def slice(*keys)
69
+ dup.slice!(*keys)
70
+ end
71
+
72
+
73
+ #
74
+ # Alters the hash so it contains only the keys passed as arguments.
75
+ #
76
+ def slice!(*keys)
77
+ keys = Set.new keys
78
+ delete_if { |k,v| not keys.include? k }
79
+ self
80
+ end
81
+
65
82
  #
66
83
  # Returns a new Hash whose values default to empty arrays. (Good for collecting things!)
67
84
  #
data/lib/epitools/iter.rb CHANGED
@@ -9,6 +9,7 @@
9
9
  #
10
10
  class Iter
11
11
 
12
+
12
13
  attr_accessor :container
13
14
 
14
15
  def initialize(vals)
@@ -64,6 +65,8 @@ class Iter
64
65
  end
65
66
  end
66
67
 
68
+
69
+
67
70
  class Elem < BasicObject
68
71
 
69
72
  attr_accessor :val, :visited
@@ -159,5 +162,6 @@ class Iter
159
162
  "<Elem: #{@val.inspect}>"
160
163
  end
161
164
  end
165
+
162
166
 
163
167
  end
@@ -471,6 +471,18 @@ describe Hash do
471
471
  h.map_values! { 1 }
472
472
  h.values.should == [1,1]
473
473
  end
474
+
475
+ it "slices" do
476
+ h = @h.dup
477
+
478
+ h.slice("key1").should == {"key1" => "val1"}
479
+ h.slice("key2").should == {"key2" => "val2"}
480
+
481
+ h.slice!("key1")
482
+ h.should == {"key1" => "val1"}
483
+
484
+ h.slice("nonexistant").should == {}
485
+ end
474
486
 
475
487
  it "mkdir_p's and trees" do
476
488
  h = {}
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: epitools
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.16
5
+ version: 0.5.17
6
6
  platform: ruby
7
7
  authors:
8
8
  - epitron
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-05 00:00:00.000000000 Z
12
+ date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :development
@@ -130,3 +130,4 @@ signing_key:
130
130
  specification_version: 3
131
131
  summary: Not utils... METILS!
132
132
  test_files: []
133
+ has_rdoc: