epitools 0.4.6 → 0.4.7

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.6
1
+ 0.4.7
data/epitools.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{epitools}
8
- s.version = "0.4.6"
8
+ s.version = "0.4.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["epitron"]
12
- s.date = %q{2011-01-30}
12
+ s.date = %q{2011-02-01}
13
13
  s.description = %q{Miscellaneous utility libraries to make my life easier.}
14
14
  s.email = %q{chris@ill-logic.com}
15
15
  s.extra_rdoc_files = [
@@ -353,6 +353,25 @@ module Enumerable
353
353
  end
354
354
 
355
355
  class Object
356
+
357
+ #
358
+ # Gives you a copy of the object with its attributes changed to whatever was
359
+ # passed in the options hash.
360
+ #
361
+ # Example:
362
+ # >> cookie = Cookie.new(:size=>10, :chips=>200)
363
+ # => #<Cookie:0xffffffe @size=10, @chips=200>
364
+ # >> cookie.with(:chips=>50)
365
+ # => #<Cookie:0xfffffff @size=10, @chips=50>
366
+ #
367
+ # (All this method does is dup the object, then call "key=(value)" for each
368
+ # key/value in the options hash.)
369
+ #
370
+ def with(options={})
371
+ obj = dup
372
+ options.each { |key, value| obj.send "#{key}=", value }
373
+ obj
374
+ end
356
375
 
357
376
  #
358
377
  # Instead of:
@@ -1,4 +1,4 @@
1
- rrequire 'epitools/basetypes'
1
+ require 'epitools/basetypes'
2
2
 
3
3
  describe Object do
4
4
 
@@ -10,6 +10,17 @@ describe Object do
10
10
  # generator = enum { |y| y.yield 1 }
11
11
  # generator.next.should == 1
12
12
  #end
13
+
14
+ it "withs" do
15
+ class Cookie; attr_accessor :size, :chips; end
16
+
17
+ c = Cookie.new; c.size = 10; c.chips = 200
18
+ w = c.with(:chips=>50)
19
+
20
+ w.size.should == c.size
21
+ w.chips.should_not == c.chips
22
+ w.should_not === c
23
+ end
13
24
 
14
25
  it "in?" do
15
26
  5.in?([1,2,3,4,5,6]).should == true
@@ -60,10 +71,6 @@ describe Object do
60
71
  10.not.even?.should == false
61
72
  end
62
73
 
63
- it "__DIR__s" do
64
- __DIR__.should == File.dirname(File.expand_path(__FILE__))
65
- end
66
-
67
74
  end
68
75
 
69
76
  describe Numeric do
@@ -223,4 +230,4 @@ describe BlankSlate do
223
230
  end
224
231
 
225
232
  end
226
-
233
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epitools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 6
10
- version: 0.4.6
9
+ - 7
10
+ version: 0.4.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - epitron
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-30 00:00:00 -05:00
18
+ date: 2011-02-01 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency