list 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +32 -7
- data/ext/list/list.c +209 -334
- data/list.gemspec +5 -5
- data/spec/list_spec.rb +17 -6
- metadata +16 -16
data/list.gemspec
CHANGED
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "list"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.2.0"
|
8
8
|
spec.author = "ksss"
|
9
9
|
spec.email = "co000ri@gmail.com"
|
10
10
|
spec.summary = %q{List in Ruby}
|
11
|
-
spec.description = %q{List
|
11
|
+
spec.description = %q{List is a class of wrapped singly-linked list}
|
12
12
|
spec.homepage = ""
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
spec.extensions = ["ext/list/extconf.rb"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec"
|
24
|
-
spec.add_development_dependency "rake-compiler"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rake-compiler"
|
25
25
|
end
|
data/spec/list_spec.rb
CHANGED
@@ -257,7 +257,7 @@ describe List do
|
|
257
257
|
list.push 1,2,3
|
258
258
|
expect(list.pop(2)).to eq(@cls[2,3])
|
259
259
|
expect(list.pop).to eq(1)
|
260
|
-
expect{list.pop("1")}.to raise_error(TypeError)
|
260
|
+
expect{list.pop("1")}.to raise_error(TypeError)
|
261
261
|
end
|
262
262
|
|
263
263
|
it "shift" do
|
@@ -266,7 +266,7 @@ describe List do
|
|
266
266
|
list.push 1,2,3
|
267
267
|
expect(list.shift(2)).to eq(@cls[1,2])
|
268
268
|
expect(list.shift).to eq(3)
|
269
|
-
expect{list.shift("1")}.to raise_error(TypeError)
|
269
|
+
expect{list.shift("1")}.to raise_error(TypeError)
|
270
270
|
end
|
271
271
|
|
272
272
|
it "unshift" do
|
@@ -611,7 +611,7 @@ describe List do
|
|
611
611
|
expect(a.zip([1,2],[8]){|i| ary << i}).to eq(nil)
|
612
612
|
expect(ary).to eq([[4,1,8],[5,2,nil],[6,nil,nil]])
|
613
613
|
expect{a.zip("a")}.to raise_error # <= 1.9.3 NoMethodError, >= 2.0.0 TypeError
|
614
|
-
|
614
|
+
|
615
615
|
obj = Object.new
|
616
616
|
def obj.to_a; [1,2]; end
|
617
617
|
expect{@cls[*%w{a b}].zip(obj)}.to raise_error # <= 1.9.3 NoNameError, >= 2.0.0 TypeError
|
@@ -802,7 +802,7 @@ describe List do
|
|
802
802
|
a = @cls[*%w{a a}]
|
803
803
|
b = a.uniq
|
804
804
|
expect(a).to eq(@cls[*%w{a a}])
|
805
|
-
expect(a.none?(&:frozen?)).to eq true
|
805
|
+
expect(a.none?(&:frozen?)).to eq true
|
806
806
|
expect(b).to eq(@cls[*%w{a}])
|
807
807
|
expect(b.none?(&:frozen?)).to eq true
|
808
808
|
|
@@ -832,7 +832,7 @@ describe List do
|
|
832
832
|
a = @cls[*%w{a a}]
|
833
833
|
b = a.uniq {|v| v }
|
834
834
|
expect(a).to eq(@cls[*%w{a a}])
|
835
|
-
expect(a.none?(&:frozen?)).to eq true
|
835
|
+
expect(a.none?(&:frozen?)).to eq true
|
836
836
|
expect(b).to eq(@cls[*%w{a}])
|
837
837
|
expect(b.none?(&:frozen?)).to eq true
|
838
838
|
end
|
@@ -991,7 +991,14 @@ describe List do
|
|
991
991
|
expect(a.count).to eq(5)
|
992
992
|
expect(a.count(1)).to eq(2)
|
993
993
|
expect(a.count {|x| x % 2 == 1}).to eq(3)
|
994
|
+
|
995
|
+
orig = $stderr
|
996
|
+
$stderr = StringIO.new
|
994
997
|
expect(a.count(1) {|x| x % 2 == 1}).to eq(2)
|
998
|
+
$stderr.rewind
|
999
|
+
expect($stderr.read.chomp).to match("warning: given block not used")
|
1000
|
+
$stderr = orig
|
1001
|
+
|
995
1002
|
expect{a.count(0,1)}.to raise_error(ArgumentError)
|
996
1003
|
end
|
997
1004
|
|
@@ -1075,7 +1082,7 @@ describe List do
|
|
1075
1082
|
end
|
1076
1083
|
|
1077
1084
|
expect{[1,2].sample(-1)}.to raise_error(ArgumentError)
|
1078
|
-
|
1085
|
+
|
1079
1086
|
gen = Random.new(0)
|
1080
1087
|
srand(0)
|
1081
1088
|
a = @cls[*(1..18)]
|
@@ -1214,4 +1221,8 @@ describe List do
|
|
1214
1221
|
expect(list.ring.ring?).to eq(true)
|
1215
1222
|
expect(list.ring!.ring?).to eq(true)
|
1216
1223
|
end
|
1224
|
+
|
1225
|
+
it "pack" do
|
1226
|
+
expect(@cls[76,105,115,116].pack("C*")).to eq("List")
|
1227
|
+
end
|
1217
1228
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,31 +42,31 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake-compiler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0
|
69
|
-
description: List
|
68
|
+
version: '0'
|
69
|
+
description: List is a class of wrapped singly-linked list
|
70
70
|
email: co000ri@gmail.com
|
71
71
|
executables: []
|
72
72
|
extensions:
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.4.5
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: List in Ruby
|