shogi_koma 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +7 -0
- data/lib/shogi_koma/painter.rb +26 -20
- data/lib/shogi_koma/version.rb +1 -1
- data/lib/shogi_koma.rb +1 -0
- data/shogi_koma.gemspec +1 -0
- data/test/test-painter.rb +12 -0
- metadata +33 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec2d2b63f97bbdbf1c316d34254cf37d1f5262c8
|
4
|
+
data.tar.gz: dd9e8fbd289eaac2658dd8e20010a890749fc146
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd24230b3e36836d6901cc8f906cc0ffab61a35cf1df6fb579b26bf7655877101eb97e9ce2a24611f338c3111bbb52e0eea14b5fd96cc0a0963b247d36a25bf5
|
7
|
+
data.tar.gz: d9abe77247fef9c1372d5bfe5e279d0f755dc292fc64db886068e8be1f7b2739bd6b95636458feeba88ed9596e021ec19544fdd9dff68bc62b567df79cf120ab
|
data/NEWS.md
CHANGED
data/lib/shogi_koma/painter.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "cairo"
|
2
|
+
require "fontdock"
|
2
3
|
|
3
4
|
module ShogiKoma
|
4
5
|
class Painter
|
5
6
|
attr_accessor :width, :height, :font
|
6
|
-
attr_reader :body_color, :text_color
|
7
|
+
attr_reader :body_color, :frame_color, :text_color
|
7
8
|
def initialize
|
8
9
|
@width = 200
|
9
10
|
@height = 200
|
@@ -13,6 +14,10 @@ module ShogiKoma
|
|
13
14
|
set_text_color(:black)
|
14
15
|
end
|
15
16
|
|
17
|
+
def set_font(part_of_font_name)
|
18
|
+
@font = Fontdock::Local.find(part_of_font_name)
|
19
|
+
end
|
20
|
+
|
16
21
|
def set_body_color(color)
|
17
22
|
@body_color = Cairo::Color.parse(color)
|
18
23
|
end
|
@@ -70,25 +75,6 @@ module ShogiKoma
|
|
70
75
|
context.stroke
|
71
76
|
end
|
72
77
|
|
73
|
-
def divide(text)
|
74
|
-
case text.length
|
75
|
-
when 1
|
76
|
-
text
|
77
|
-
when 2
|
78
|
-
if text.bytes.to_a.length == 2
|
79
|
-
[text]
|
80
|
-
else
|
81
|
-
text
|
82
|
-
end
|
83
|
-
else
|
84
|
-
if text[0].bytes.to_a.length == 1 && text[1].bytes.to_a.length == 1
|
85
|
-
[text[0..1], text[2..-1]]
|
86
|
-
else
|
87
|
-
[text[0], text[1..-1]]
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
78
|
def draw_text1(context, text)
|
93
79
|
context.set_source_color(@text_color)
|
94
80
|
text = text[0] if text.is_a?(Array)
|
@@ -107,5 +93,25 @@ module ShogiKoma
|
|
107
93
|
context.move_to(0.3, 0.85)
|
108
94
|
context.show_text(text[1])
|
109
95
|
end
|
96
|
+
|
97
|
+
private
|
98
|
+
def divide(text)
|
99
|
+
case text.length
|
100
|
+
when 1
|
101
|
+
text
|
102
|
+
when 2
|
103
|
+
if text.bytes.to_a.length == 2
|
104
|
+
[text]
|
105
|
+
else
|
106
|
+
text
|
107
|
+
end
|
108
|
+
else
|
109
|
+
if text[0].bytes.to_a.length == 1 && text[1].bytes.to_a.length == 1
|
110
|
+
[text[0..1], text[2..-1]]
|
111
|
+
else
|
112
|
+
[text[0], text[1..-1]]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
110
116
|
end
|
111
117
|
end
|
data/lib/shogi_koma/version.rb
CHANGED
data/lib/shogi_koma.rb
CHANGED
data/shogi_koma.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_runtime_dependency("cairo")
|
22
|
+
spec.add_runtime_dependency("fontdock", ">= 0.0.2")
|
22
23
|
|
23
24
|
spec.add_development_dependency("test-unit")
|
24
25
|
spec.add_development_dependency("test-unit-notify")
|
data/test/test-painter.rb
CHANGED
@@ -6,6 +6,18 @@ class PainterTest < Test::Unit::TestCase
|
|
6
6
|
@painter = ShogiKoma::Painter.new
|
7
7
|
end
|
8
8
|
|
9
|
+
class SetFontTest < self
|
10
|
+
def test_found
|
11
|
+
part_of_name = "M"
|
12
|
+
assert_match(/#{part_of_name}/, @painter.set_font(part_of_name))
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_not_found
|
16
|
+
part_of_name = "ABCDE12345"
|
17
|
+
assert_nil(@painter.set_font(part_of_name))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
9
21
|
class DrawTest < self
|
10
22
|
def test_one_character
|
11
23
|
assert_nothing_raised_in_draw("A")
|
metadata
CHANGED
@@ -1,97 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shogi_koma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Yokoyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cairo
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fontdock
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.2
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: test-unit
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: test-unit-notify
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: test-unit-rr
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - ~>
|
87
|
+
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '1.3'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - ~>
|
94
|
+
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '1.3'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
description: An image generator for Shogi's pieces (it's "ko-ma" in Japanese) for
|
@@ -102,8 +116,8 @@ executables: []
|
|
102
116
|
extensions: []
|
103
117
|
extra_rdoc_files: []
|
104
118
|
files:
|
105
|
-
- .gitignore
|
106
|
-
- .travis.yml
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
107
121
|
- Gemfile
|
108
122
|
- LICENSE.txt
|
109
123
|
- NEWS.md
|
@@ -126,17 +140,17 @@ require_paths:
|
|
126
140
|
- lib
|
127
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- -
|
143
|
+
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '0'
|
132
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
147
|
requirements:
|
134
|
-
- -
|
148
|
+
- - ">="
|
135
149
|
- !ruby/object:Gem::Version
|
136
150
|
version: '0'
|
137
151
|
requirements: []
|
138
152
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.0
|
153
|
+
rubygems_version: 2.2.0
|
140
154
|
signing_key:
|
141
155
|
specification_version: 4
|
142
156
|
summary: An image generater for Shogi's pieces
|