multiples 0.1.0 → 0.1.1

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: e7edc53b90318e0babfb1c73ecad1b2d09966129
4
- data.tar.gz: a3d791a1a8351b9d817e374cb6d8692a6caa7fd2
3
+ metadata.gz: 7c148b2dbc34e3fe1fd0b1ab3f77580923d8db47
4
+ data.tar.gz: 1cc36f198a041ef08285c0f31279f317e0d917bb
5
5
  SHA512:
6
- metadata.gz: 1a447a6aa6fa6d97445eba165033eb4fe7695b6099ef0d35470a9872a8cd38ff18ac668fbe0e8dca01ad584e816b5be8f67b2b4599ff79657ef69c6b1ad50688
7
- data.tar.gz: fb11443773d0f4823353d45c8c4528480cf3769fd73ec09225cfee1fb9869ab4bd6d8af152b2284f758ec89f3887fa360fa2df4ef849ee49c41ed8d097df03f0
6
+ metadata.gz: a67ca997e635bd02a675b6ccaadc0aadf18cea97f5cad749f16e97e5ab1547b04a5450d46573cf9d552e78cf01d2e23fccfd9e18edd527081f10851b262c484e
7
+ data.tar.gz: 3fb75d42c0cafe86d2ce87d9cd8a1cf0013509925e30df4f9f3f515496a3106096a3ef74543fe1e106ee46e150f1177d603eb16ecbeb88719520bde72d56035a
data/README.md CHANGED
@@ -76,8 +76,28 @@ x.prev
76
76
  # => 30
77
77
  x.phase
78
78
  # => 0
79
+
80
+ y = Multiples.new(3,5)
81
+
82
+ y.lazy.take(4).to_a
83
+ # => [3, 5, 6, 9]
84
+ y.next
85
+ # => 10
86
+ y.prev
87
+ # => 9
88
+
89
+ y.lazy.select {|v| v % 7 == 0 }.take(14).to_a
90
+ # => [21, 35, 42, 63, 70, 84, 105, 126, 140, 147, 168, 175, 189, 210]
79
91
  ```
80
92
 
93
+ ## Benchmark
94
+
95
+ If you reuse the Enumerator (rather than re-initialzing it) you will gain a
96
+ performance advantage of at least 100% (2x original). If you create a new Enumerator each time
97
+ you use it your performance will be 30% worse than if you had not used this gem.
98
+ See the benchmark file in test/benches for an example and run `rake bench` to see
99
+ the results for yourself.
100
+
81
101
  ## Development
82
102
 
83
103
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/Rakefile CHANGED
@@ -1,6 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
+ Rake::TestTask.new(:bench) do |t|
5
+ t.libs = %w(lib test)
6
+ t.pattern = 'test/**/*_benchmark.rb'
7
+ end
8
+
4
9
  Rake::TestTask.new(:test) do |t|
5
10
  t.libs << "test"
6
11
  t.libs << "lib"
@@ -40,6 +40,11 @@ module Multiples
40
40
  @base
41
41
  end
42
42
 
43
+ def reset!
44
+ @base = 0
45
+ @phase = 0
46
+ end
47
+
43
48
  def each
44
49
  loop do
45
50
  send :next
@@ -1,3 +1,3 @@
1
1
  module Multiples
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/multiples.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Multiples::VERSION
9
9
  spec.authors = ["Daniel P. Clark"]
10
10
  spec.email = ["6ftdan@gmail.com"]
11
- spec.summary = %q{Creates enumerators that step through integers from a union of two multiples"}
12
- spec.description = %q{Creates enumerators that step through integers from a union of two multiples. A pattern from the two numbers is determined (much like two frequencies create a pattern) and the resulting palindrome is given to a custom Enumerator for you to use."}
11
+ spec.summary = %q{Creates enumerators that step through integers from a union of two multiples}
12
+ spec.description = %q{Creates enumerators that step through integers from a union of two multiples. A pattern from the two numbers is determined (much like two frequencies create a pattern) and the resulting palindrome is given to a custom Enumerator for you to use.}
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.13"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "minitest", "~> 5.0"
25
+ spec.add_development_dependency "benchmark-ips", "~> 2.7"
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiples
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark
@@ -52,10 +52,24 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: benchmark-ips
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.7'
55
69
  description: Creates enumerators that step through integers from a union of two multiples.
56
70
  A pattern from the two numbers is determined (much like two frequencies create a
57
71
  pattern) and the resulting palindrome is given to a custom Enumerator for you to
58
- use."
72
+ use.
59
73
  email:
60
74
  - 6ftdan@gmail.com
61
75
  executables: []
@@ -97,5 +111,5 @@ rubyforge_project:
97
111
  rubygems_version: 2.6.4
98
112
  signing_key:
99
113
  specification_version: 4
100
- summary: Creates enumerators that step through integers from a union of two multiples"
114
+ summary: Creates enumerators that step through integers from a union of two multiples
101
115
  test_files: []