bootstripe 0.2.8 → 0.2.9

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.
@@ -29,14 +29,8 @@ class Array
29
29
  offset = 0
30
30
  while offset < size
31
31
  next_size = (min_size..max_size).random.to_i
32
-
33
- # If following section will be too small, err on side of too big and lump it in with this one
34
- if offset + next_size >= size
35
- next_size = size - offset
36
- end
37
-
38
- sects << self[offset, offset + next_size]
39
- offset += next_size
32
+ sects << self[offset..offset+next_size]
33
+ offset += next_size + 1
40
34
  end
41
35
 
42
36
  sects
@@ -1,3 +1,3 @@
1
1
  module Bootstripe
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
@@ -10,4 +10,13 @@ describe Array do
10
10
  [' ', ' I need trimming! '].compakt.should == [' I need trimming! ']
11
11
  end
12
12
 
13
+ it 'should return random sections of an array' do
14
+ srand(123456)
15
+ arr = (1..20).to_a
16
+ sections = arr.sections(3, 5)
17
+ sections[0..-2].map{ |s| s.size }.each{ |l| (3..5).should include(l) }
18
+ p sections
19
+ sections.flatten.size.should == arr.size
20
+ end
21
+
13
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-17 00:00:00.000000000 Z
12
+ date: 2012-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70107993577100 !ruby/object:Gem::Requirement
16
+ requirement: &70213196783860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70107993577100
24
+ version_requirements: *70213196783860
25
25
  description: A handful of useful additions for Ruby
26
26
  email:
27
27
  - mike@bytebin.com