kitchensink 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,6 +18,8 @@ script/destroy
18
18
  script/generate
19
19
  script/txt2html
20
20
  setup.rb
21
+ spec/spec_helper.rb
22
+ spec/patches/enumerable_spec.rb
21
23
  tasks/deployment.rake
22
24
  tasks/environment.rake
23
25
  tasks/website.rake
@@ -2,7 +2,11 @@ unless Enumerable.method_defined? :rest
2
2
  module Enumerable
3
3
  # Returns all elements after the first.
4
4
  def rest
5
- self[1..-1]
5
+ if self.respond_to? :[]
6
+ self[1..-1]
7
+ else
8
+ self.to_a[1..-1]
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -21,18 +25,30 @@ unless Enumerable.method_defined? :rrest
21
25
  # means, and that with a little context the reader could determine the
22
26
  # meaning correctly almost all every time.
23
27
  def rrest
24
- self[0..-2]
28
+ if self.respond_to? :[]
29
+ self[0..-2]
30
+ else
31
+ self.to_a[0..-2]
32
+ end
25
33
  end
26
34
  end
27
35
  end
28
36
 
29
- unless Enumerable.method_defined? :shuffle
37
+ unless Enumerable.method_defined?(:shuffle)
30
38
  module Enumerable
31
39
  # Returns an array with its elements shuffled. This is not a particularly
32
40
  # efficient method because Enumerable doesn't provide random access. This
33
41
  # is overridden with a more efficient method in Array.
42
+ #
43
+ # Note that there is no corresponding shuffle! method because shuffle
44
+ # returns an Array. If it ever makes sense to replace an IO or a Socket or
45
+ # a Struct with an Array, it probably also makes sense for you to have to
46
+ # write that method directly in the child class. The trivial
47
+ # implementation is straightforward: +self.replace(self.shuffle)+, but as
48
+ # was the case with Array, there is probably a more efficient
49
+ # implementation available.
34
50
  def shuffle
35
- self.sort_by { rand }
51
+ sort_by { rand }
36
52
  end
37
53
  end
38
54
  end
@@ -2,7 +2,7 @@ module Kitchensink #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
File without changes
File without changes
File without changes
@@ -0,0 +1,47 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe "Enumerable" do
4
+ describe "shuffle" do
5
+ it "should mix Hash key/values into an array of pairs" do
6
+ h = {:a=>9, :b=>"foo", :c=>42}
7
+ h.should respond_to(:shuffle)
8
+ s = h.shuffle
9
+ s.should be_kind_of(Array)
10
+ s.size.should == h.size
11
+ s.each do |k,v|
12
+ h.should be_key(k)
13
+ h[k].should == v
14
+ end
15
+ end
16
+
17
+ it "should work with unindexable Enumerables by converting them to arrays" do
18
+ s = (3..6).shuffle
19
+ s.size.should == 4
20
+ (3..6).each do |i|
21
+ s.should include(i)
22
+ end
23
+ end
24
+ end
25
+
26
+ describe "rest" do
27
+ it "should return all but the head" do
28
+ a = (1..10).to_a
29
+ a.rest.should == (2..10).to_a
30
+ end
31
+
32
+ it "should work with unindexable Enumerables by converting them to arrays" do
33
+ (1..10).rest.should == (2..10).to_a
34
+ end
35
+ end
36
+
37
+ describe "rrest" do
38
+ it "should return all but the tail" do
39
+ a = (1..10).to_a
40
+ a.rrest.should == (1..9).to_a
41
+ end
42
+
43
+ it "should work with unindexable Enumerables by converting them to arrays" do
44
+ (1..10).rrest.should == (1..9).to_a
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'kitchensink'
4
+
5
+ # class RespondTo
6
+ # def initialize(expected)
7
+ # @expected = expected
8
+ # end
9
+ #
10
+ # def matches?(actual)
11
+ # @actual = actual
12
+ # # Satisfy expectation here. Return false or raise an error if it's not met.
13
+ #
14
+ #
15
+ # true
16
+ # end
17
+ #
18
+ # def failure_message
19
+ # "expected #{@actual.inspect} to respond_to #{@expected.inspect}, but it didn't"
20
+ # end
21
+ #
22
+ # def negative_failure_message
23
+ # "expected #{@actual.inspect} not to respond_to #{@expected.inspect}, but it did"
24
+ # end
25
+ # end
26
+ #
27
+ # def respond_to(expected)
28
+ # RespondTo.new(expected)
29
+ # end
@@ -33,7 +33,7 @@
33
33
  <h1>kitchensink</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/kitchensink"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/kitchensink" class="numbers">0.2.1</a>
36
+ <a href="http://rubyforge.org/projects/kitchensink" class="numbers">0.2.2</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;kitchensink&#8217;</h1>
39
39
 
@@ -59,9 +59,6 @@
59
59
  <p><a href="http://groups.google.com/group/kitchensink">http://groups.google.com/group/kitchensink</a></p>
60
60
 
61
61
 
62
- <p><span class="caps">TODO</span> &#8211; create Google Group &#8211; kitchensink</p>
63
-
64
-
65
62
  <h2>How to submit patches</h2>
66
63
 
67
64
 
@@ -82,7 +79,7 @@
82
79
 
83
80
  <p>Comments are welcome. Send an email to <a href="mailto:FIXME"><span class="caps">FIXME</span> full name</a> email via the <a href="http://groups.google.com/group/kitchensink">forum</a></p>
84
81
  <p class="coda">
85
- <a href="FIXME email">FIXME full name</a>, 1st March 2008<br>
82
+ <a href="FIXME email">FIXME full name</a>, 25th March 2008<br>
86
83
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
87
84
  </p>
88
85
  </div>
@@ -21,8 +21,6 @@ h2. Forum
21
21
 
22
22
  "http://groups.google.com/group/kitchensink":http://groups.google.com/group/kitchensink
23
23
 
24
- TODO - create Google Group - kitchensink
25
-
26
24
  h2. How to submit patches
27
25
 
28
26
  Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchensink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - FIXME full name
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-25 00:00:00 -06:00
12
+ date: 2008-04-24 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -47,6 +47,8 @@ files:
47
47
  - script/generate
48
48
  - script/txt2html
49
49
  - setup.rb
50
+ - spec/spec_helper.rb
51
+ - spec/patches/enumerable_spec.rb
50
52
  - tasks/deployment.rake
51
53
  - tasks/environment.rake
52
54
  - tasks/website.rake
@@ -80,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
82
  requirements: []
81
83
 
82
84
  rubyforge_project: kitchensink
83
- rubygems_version: 1.0.1
85
+ rubygems_version: 1.1.0
84
86
  signing_key:
85
87
  specification_version: 2
86
88
  summary: description of gem