hyper_iterator 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45fbaa9da4504f18c89bd500f25f98f20b2c1cc9
4
- data.tar.gz: 05b840c3f67530f9e917d9f01a2693516806644a
3
+ metadata.gz: 55ad0f990d6b8995564bb008dfab3d7b31466571
4
+ data.tar.gz: a1d40fae14f08758adc32ed5feb422d3e057ce61
5
5
  SHA512:
6
- metadata.gz: 0155e42f2792e794a67dbd65452da2f032a5f59a7cc401a5ff16d083bb3e19e126aea80d0b1dc9e4e569bb5133462331208685ec9c0104bf65094f3f71c2771b
7
- data.tar.gz: 18b2607caab7f03b83388d50cdad5019283605d5d9af0ac5d46550272ba0ead573f486a24cc91affe7e5a33fba86442c9b80f6f7fdc229473a034299a4e53e2f
6
+ metadata.gz: 21983520dc57eff8a897387e2ec5d10f4d3c717c3ecf32b747050f5bf28a56eda9c5479c7bbd6723a6205b961f4f93d0e018f4edeed31337f08a70827072300e
7
+ data.tar.gz: c8a76fb37c41b0ba6738f6c94d9bfc4df68ee48379f28cca2caddbe3a67e742711e34a5060ed47acc989b87e4123e5d793d98c319dd801ad606863103431bdad
data/README.md CHANGED
@@ -35,6 +35,9 @@ Or install it yourself as:
35
35
 
36
36
  - `each_slice!`
37
37
  - `each!`
38
+ - `HyperIterator.each!`: This is the same as `each!`. But it takes an array as argument.
39
+ This is added because there are gems that implement their own `each` method (e.g. the pg
40
+ gem). Instead of monkey patching all the gems out there, this is a compromise for flexibility.
38
41
 
39
42
  ## Gotcha
40
43
 
@@ -2,12 +2,12 @@ require 'benchmark'
2
2
  require_relative '../../lib/hyper_iterator'
3
3
  $stdout.sync = true
4
4
 
5
- puts 'Array#each_slice'
6
- puts 'creating array'
5
+ puts
6
+ puts '--------------- Array#each_slice --------------'
7
+ puts '#i user system total real'
8
+
7
9
  base_arr = Array.new(10000) { '-' * 10 }
8
10
  arrs = [base_arr]
9
- puts 'finished creating base array'
10
- puts 'each iteration begins'
11
11
 
12
12
  i = 0
13
13
  while true
@@ -2,12 +2,12 @@ require 'benchmark'
2
2
  require_relative '../../lib/hyper_iterator'
3
3
  $stdout.sync = true
4
4
 
5
- puts 'Array#each_slice'
6
- puts 'creating array'
5
+ puts
6
+ puts '-------------- Array#each_slice! --------------'
7
+ puts '#i user system total real'
8
+
7
9
  base_arr = Array.new(10000) { '-' * 10 }
8
10
  arrs = [base_arr]
9
- puts 'finished creating base array'
10
- puts 'each iteration begins'
11
11
 
12
12
  i = 0
13
13
  while true
data/bin/bm CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  docker_command="docker run -m=4m -v `pwd`:`pwd` -w `pwd` hyper_iterator ruby ./benchmark/memory_bm"
4
- if [ "$1" = "each" ] || [ "$1" = 1 ]; then
4
+ if [ "$1" = "each!" ] || [ "$1" = 1 ]; then
5
5
  eval "$docker_command/each.rb"
6
6
  eval "$docker_command/each_bang.rb"
7
- elif [ "$1" = "each" ] || [ "$1" = 2 ]; then
7
+ elif [ "$1" = "each_slice!" ] || [ "$1" = 2 ]; then
8
8
  eval "$docker_command/each_slice.rb"
9
9
  eval "$docker_command/each_slice_bang.rb"
10
10
  else
@@ -1,3 +1,3 @@
1
1
  module HyperIterator
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -7,6 +7,10 @@ module HyperIterator
7
7
  :each_slice!,
8
8
  :each!
9
9
  ].freeze
10
+
11
+ def self.each!(arr)
12
+ arr.each! { |el| yield el }
13
+ end
10
14
  end
11
15
 
12
16
  Array.include HyperIterator
@@ -1,7 +1,7 @@
1
1
  module HyperIterator
2
- def each!(&blk)
2
+ def each!
3
3
  while count > 0
4
- blk.call(shift)
4
+ yield shift
5
5
  end
6
6
  nil
7
7
  end
@@ -1,5 +1,5 @@
1
1
  module HyperIterator
2
- def each_slice!(slice_size, &blk)
2
+ def each_slice!(slice_size)
3
3
  i = 0
4
4
 
5
5
  while count > 0
@@ -8,7 +8,7 @@ module HyperIterator
8
8
  current_slice << shift
9
9
  i += 1
10
10
  end
11
- blk.call(current_slice)
11
+ yield current_slice
12
12
  i = 0
13
13
  end
14
14
  nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyper_iterator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edmund Li
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-17 00:00:00.000000000 Z
11
+ date: 2017-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler