polygonize 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/lib/polygonize/version.rb +1 -1
- data/spec/polygonize_spec.rb +50 -28
- metadata +3 -2
data/.travis.yml
ADDED
data/lib/polygonize/version.rb
CHANGED
data/spec/polygonize_spec.rb
CHANGED
@@ -4,43 +4,65 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
include Polygonize
|
6
6
|
|
7
|
-
describe "Polygonize" do
|
8
|
-
|
9
|
-
|
10
|
-
""
|
7
|
+
describe "Polygonizeモジュールをインクルードする" do
|
8
|
+
describe ":coordinates メソッド" do
|
9
|
+
context "空テキスト" do
|
10
|
+
it "は何も返さない" do
|
11
|
+
"".coordinates.should eql ""
|
12
|
+
end
|
11
13
|
end
|
12
|
-
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
context "Stringのメソッドである" do
|
16
|
+
it "Fixnumはエラーになる" do
|
17
|
+
proc {
|
18
|
+
123.coordinates
|
19
|
+
}.should raise_error
|
20
|
+
end
|
21
|
+
|
22
|
+
it "Arrayはエラーになる" do
|
23
|
+
proc {
|
24
|
+
["foo","bar"].coordinates
|
25
|
+
}.should raise_error
|
26
|
+
end
|
18
27
|
end
|
19
28
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
29
|
+
context "テキスト" do
|
30
|
+
txt = "こんにちは"
|
31
|
+
it "はxy座標の文字列を返す" do
|
32
|
+
txt.coordinates.should eql "48,83 48,147 48,107 48,97 48,111"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "要素は偶数個である" do
|
36
|
+
ar = txt.coordinates.split(" ").inject([]) { |mem, x| mem << x.split(",") }
|
37
|
+
(ar.flatten.size%2).should eql 0
|
38
|
+
end
|
24
39
|
|
25
|
-
|
26
|
-
|
40
|
+
it "各要素は255(FF)以下である" do
|
41
|
+
ret = txt.coordinates.split(" ").flatten.reject! { |x| x.to_i < 255}
|
42
|
+
ret.should eql []
|
43
|
+
end
|
27
44
|
end
|
28
|
-
end
|
29
45
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
46
|
+
context "1バイトテキスト" do
|
47
|
+
txt_e = "x"
|
48
|
+
it "は奇数要素、ゼロで補完する" do
|
49
|
+
txt_e.coordinates.split(",")[1].should eql "0"
|
50
|
+
end
|
35
51
|
|
36
|
-
|
37
|
-
|
52
|
+
it "#{txt_e}の文字コードは0x78である" do
|
53
|
+
txt_e.coordinates.split(",")[0].should eql "78".hex.to_s
|
54
|
+
|
55
|
+
end
|
56
|
+
it "0x78 = 120である" do
|
57
|
+
txt_e.coordinates.split(",")[0].should eql "120"
|
58
|
+
end
|
38
59
|
end
|
39
|
-
end
|
40
60
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
61
|
+
context "メソッド" do
|
62
|
+
it ":coordinatesは Stringのインスタンスメソッドがある" do
|
63
|
+
String.instance_methods.grep(/^coordinates/).should eql [:coordinates]
|
64
|
+
end
|
65
|
+
end
|
45
66
|
end
|
67
|
+
|
46
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polygonize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -83,6 +83,7 @@ extensions: []
|
|
83
83
|
extra_rdoc_files: []
|
84
84
|
files:
|
85
85
|
- .gitignore
|
86
|
+
- .travis.yml
|
86
87
|
- Gemfile
|
87
88
|
- Guardfile
|
88
89
|
- LICENSE
|