enumerator-comparable 0.0.2 → 0.0.3
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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5dc50b2fefe0e4667b7c4d012ad895cdd2c638ab
|
|
4
|
+
data.tar.gz: 74fd876fb41049d891518ea889f58fd258fe6473
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1f73ae6d3ebcb29060197e425d8f80dd7311c02dd5385cc21852660a4c0d525cefa28ceac564f917cecf8244fda10d89f1b0ab05ce0b9ac5f5374edbf25d9cc
|
|
7
|
+
data.tar.gz: ca7622fa074f1934ab097ffd58843730928f0af892853db498982a63e6e2289f3f265a346e6648c31a72cbd63b77a07ae34037d821bb5cae51b36aa8bc6e5156
|
data/Gemfile
CHANGED
|
@@ -8,6 +8,7 @@ class Enumerator
|
|
|
8
8
|
# sequences are infinite, then this method never returns.
|
|
9
9
|
# If you understand dictionary order for words then you understand
|
|
10
10
|
# how this works. Shorter sequences come before longer sequences.
|
|
11
|
+
# The elements of the sequence(s) must define spaceship (<=>) too.
|
|
11
12
|
# Here's a method that ought to be defined in Enumerator::Lazy
|
|
12
13
|
# but isn't.
|
|
13
14
|
def <=>(other)
|
|
@@ -23,10 +24,9 @@ class Enumerator
|
|
|
23
24
|
end
|
|
24
25
|
elsif b_end
|
|
25
26
|
1 # other is shorter
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
1
|
|
27
|
+
else
|
|
28
|
+
x = a <=> b
|
|
29
|
+
x unless x == 0
|
|
30
30
|
end
|
|
31
31
|
next if result.nil?
|
|
32
32
|
return result
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'enumerator_comparable' do
|
|
4
|
+
|
|
5
|
+
def seq(s)
|
|
6
|
+
s.each_char
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe 'spaceship' do
|
|
10
|
+
describe 'both empty' do
|
|
11
|
+
let(:a){seq('')}
|
|
12
|
+
let(:b){seq('')}
|
|
13
|
+
it 'should be 0' do
|
|
14
|
+
(a <=> b).should == 0
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
describe 'single and equal' do
|
|
18
|
+
let(:a){seq('c')}
|
|
19
|
+
let(:b){seq('c')}
|
|
20
|
+
it 'should be 0' do
|
|
21
|
+
(a <=> b).should == 0
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
describe 'double and equal' do
|
|
25
|
+
let(:a){seq('xy')}
|
|
26
|
+
let(:b){seq('xy')}
|
|
27
|
+
it 'should be 0' do
|
|
28
|
+
(a <=> b).should == 0
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
describe 'left shorter' do
|
|
32
|
+
let(:a){seq('')}
|
|
33
|
+
let(:b){seq('a')}
|
|
34
|
+
it 'should be -1' do
|
|
35
|
+
(a <=> b).should == -1
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
describe 'right shorter' do
|
|
39
|
+
let(:a){seq('a')}
|
|
40
|
+
let(:b){seq('')}
|
|
41
|
+
it 'should be 1' do
|
|
42
|
+
(a <=> b).should == 1
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
describe 'left less' do
|
|
46
|
+
let(:a){seq('a')}
|
|
47
|
+
let(:b){seq('b')}
|
|
48
|
+
it 'should be -1' do
|
|
49
|
+
(a <=> b).should == -1
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
describe 'right less' do
|
|
53
|
+
let(:a){seq('b')}
|
|
54
|
+
let(:b){seq('a')}
|
|
55
|
+
it 'should be 1' do
|
|
56
|
+
(a <=> b).should == 1
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
describe 'left less in second position' do
|
|
60
|
+
let(:a){seq('ba')}
|
|
61
|
+
let(:b){seq('bb')}
|
|
62
|
+
it 'should be -1' do
|
|
63
|
+
(a <=> b).should == -1
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
describe 'right less in second position' do
|
|
67
|
+
let(:a){seq('bb')}
|
|
68
|
+
let(:b){seq('ba')}
|
|
69
|
+
it 'should be 1' do
|
|
70
|
+
(a <=> b).should == 1
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe 'equality' do
|
|
75
|
+
describe 'both empty' do
|
|
76
|
+
let(:a){seq('')}
|
|
77
|
+
let(:b){seq('')}
|
|
78
|
+
it 'should be equal' do
|
|
79
|
+
a.should == b
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
describe 'same length 1' do
|
|
83
|
+
let(:a){seq('c')}
|
|
84
|
+
let(:b){seq('c')}
|
|
85
|
+
it 'should be equal' do
|
|
86
|
+
a.should == b
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
describe 'unequal, length 1' do
|
|
90
|
+
let(:a){seq('c')}
|
|
91
|
+
let(:b){seq('d')}
|
|
92
|
+
it 'should not be equal' do
|
|
93
|
+
a.should_not == b
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe 'sequences of Arrays' do
|
|
99
|
+
describe 'equal' do
|
|
100
|
+
let(:a){[[1]].each}
|
|
101
|
+
let(:b){[[1]].each}
|
|
102
|
+
it 'should be 0' do
|
|
103
|
+
(a <=> b).should == 0
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
describe 'left less' do
|
|
107
|
+
let(:a){[[1]].each}
|
|
108
|
+
let(:b){[[2]].each}
|
|
109
|
+
it 'should be -1' do
|
|
110
|
+
(a <=> b).should == -1
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
describe 'right less' do
|
|
114
|
+
let(:a){[[2]].each}
|
|
115
|
+
let(:b){[[1]].each}
|
|
116
|
+
it 'should be 1' do
|
|
117
|
+
(a <=> b).should == 1
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'byebug'
|
|
2
|
+
|
|
3
|
+
# require 'simplecov'
|
|
4
|
+
# SimpleCov.start do
|
|
5
|
+
# add_group "Calendrical", "lib/calendrical"
|
|
6
|
+
# end
|
|
7
|
+
|
|
8
|
+
$:.unshift(File.join( File.dirname(__FILE__), '../lib'))
|
|
9
|
+
|
|
10
|
+
# http://anti-pattern.com/bundler-setup-vs-bundler-require
|
|
11
|
+
require 'rubygems'
|
|
12
|
+
require 'bundler/setup'
|
|
13
|
+
|
|
14
|
+
# when we run via plain old "ruby" command instead of "rspec", this
|
|
15
|
+
# line tells ruby to run the examples
|
|
16
|
+
require 'rspec/autorun'
|
|
17
|
+
|
|
18
|
+
# This is the present Ruby Gem: the one we are spec-ing/testing
|
|
19
|
+
require 'enumerator_comparable'
|
|
20
|
+
|
|
21
|
+
# Grab all the rspec support files: utility classes, custom matchers etc.
|
|
22
|
+
$LOAD_PATH.unshift(*Dir[File.join( File.dirname(__FILE__), 'support/**')])
|
|
23
|
+
|
|
24
|
+
require 'spec_helper_methods'
|
|
25
|
+
|
|
26
|
+
RSpec.configure do |config|
|
|
27
|
+
|
|
28
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
29
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
30
|
+
# the seed, which is printed after each run.
|
|
31
|
+
# --seed 1234
|
|
32
|
+
config.order = "random"
|
|
33
|
+
|
|
34
|
+
# Use color in STDOUT
|
|
35
|
+
config.color_enabled = true
|
|
36
|
+
|
|
37
|
+
# Use color not only in STDOUT but also in pagers and files
|
|
38
|
+
config.tty = true
|
|
39
|
+
|
|
40
|
+
# Use the specified formatter
|
|
41
|
+
config.formatter = :progress # :documentation :progress, :html, :textmate
|
|
42
|
+
|
|
43
|
+
config.include SpecHelperMethods
|
|
44
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: enumerator-comparable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bill
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Makes Enumerators Comparables
|
|
14
14
|
email:
|
|
@@ -17,7 +17,7 @@ executables: []
|
|
|
17
17
|
extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
|
19
19
|
files:
|
|
20
|
-
- .gitignore
|
|
20
|
+
- ".gitignore"
|
|
21
21
|
- Gemfile
|
|
22
22
|
- LICENSE.txt
|
|
23
23
|
- README.md
|
|
@@ -27,6 +27,9 @@ files:
|
|
|
27
27
|
- lib/enumerator_comparable/initializers.rb
|
|
28
28
|
- lib/enumerator_comparable/initializers/enumerator_comparable.rb
|
|
29
29
|
- lib/enumerator_comparable/version.rb
|
|
30
|
+
- spec/enumerator_comparable_spec.rb
|
|
31
|
+
- spec/spec_helper.rb
|
|
32
|
+
- spec/spec_helper_methods.rb
|
|
30
33
|
homepage: ''
|
|
31
34
|
licenses: []
|
|
32
35
|
metadata: {}
|
|
@@ -36,18 +39,21 @@ require_paths:
|
|
|
36
39
|
- lib
|
|
37
40
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
41
|
requirements:
|
|
39
|
-
- -
|
|
42
|
+
- - ">="
|
|
40
43
|
- !ruby/object:Gem::Version
|
|
41
44
|
version: '0'
|
|
42
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
46
|
requirements:
|
|
44
|
-
- -
|
|
47
|
+
- - ">="
|
|
45
48
|
- !ruby/object:Gem::Version
|
|
46
49
|
version: '0'
|
|
47
50
|
requirements: []
|
|
48
51
|
rubyforge_project:
|
|
49
|
-
rubygems_version: 2.
|
|
52
|
+
rubygems_version: 2.2.2
|
|
50
53
|
signing_key:
|
|
51
54
|
specification_version: 4
|
|
52
55
|
summary: Defines spaceship (<=>) operator for Enumerator and mixes in Comparable
|
|
53
|
-
test_files:
|
|
56
|
+
test_files:
|
|
57
|
+
- spec/enumerator_comparable_spec.rb
|
|
58
|
+
- spec/spec_helper.rb
|
|
59
|
+
- spec/spec_helper_methods.rb
|