sane 0.25.2 → 0.25.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ 0.25.3: Add String#last
2
2
  0.25.1 : Add absent present? method [oops]
3
3
  0.25.0 : add Array#sample, try to add sanity to release numberings, since the ones previous seemed bworked ?
4
4
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.25.2
1
+ 0.25.3
@@ -4,6 +4,16 @@ class String
4
4
  def replace_all! this_string
5
5
  gsub!(/^.*$/, this_string)
6
6
  end
7
+
8
+ def last n
9
+ if n > 0
10
+ out = self[-n..-1]
11
+ else
12
+ out = '' # case 0 or less
13
+ end
14
+ out ||= self.dup # I guess .dup is good...
15
+
16
+ end
7
17
 
8
18
  end
9
19
 
@@ -202,4 +202,11 @@ describe Sane do
202
202
  [2].sample.should == 2
203
203
  end
204
204
 
205
+ it 'should have String#last' do
206
+ 'abc'.last(2).should == 'bc'
207
+ 'abc'.last(3).should == 'abc'
208
+ 'abc'.last(1).should == 'c'
209
+ 'abc'.last(0).should == '' # this is feeling weird now...
210
+ 'abc'.last(44).should == 'abc'
211
+ end
205
212
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sane
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.25.2
5
+ version: 0.25.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Roger Pack
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-21 00:00:00 Z
13
+ date: 2012-03-13 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: os
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  requirements: []
102
102
 
103
103
  rubyforge_project:
104
- rubygems_version: 1.8.9
104
+ rubygems_version: 1.8.15
105
105
  signing_key:
106
106
  specification_version: 3
107
107
  summary: Helpers for ruby core to make it easier to work with--things that are missing from core but should arguably be there