tanka_renderer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/NEWS.md +5 -0
- data/README.md +49 -0
- data/Rakefile +9 -0
- data/lib/tanka_renderer.rb +5 -0
- data/lib/tanka_renderer/renderer.rb +2 -0
- data/lib/tanka_renderer/renderer/base.rb +77 -0
- data/lib/tanka_renderer/renderer/image.rb +19 -0
- data/lib/tanka_renderer/renderer/pdf.rb +19 -0
- data/lib/tanka_renderer/version.rb +3 -0
- data/license/lgpl-3.0.txt +165 -0
- data/sample/image.rb +19 -0
- data/sample/pdf.rb +16 -0
- data/tanka_renderer.gemspec +30 -0
- data/test/run-test.rb +11 -0
- data/test/test-renderer.rb +78 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0fe566875fe6d53c443f3d09fd30e89919711769
|
4
|
+
data.tar.gz: 5ac8c73b0790a3e459e25ebf657734ead0729c4e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c54884714c5b605ea113737db2cbb22723624b9103a1bdb4d5901c13033f9bf361d400bf39c99a42aff99631b8cc6186206919e11d09eff2bda47901a7cd2893
|
7
|
+
data.tar.gz: c7f284ffddfd301a62bf726a9b5e1740c31b76f2675e7da8777937b3f2ae68e863240d0d4516bcb07b67cdcb4e0cd3621cb3ab23adfdd5ce22db497634864ceb
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# TankaRenderer [![Build Status](https://secure.travis-ci.org/myokoym/tanka_renderer.png?branch=master)](http://travis-ci.org/myokoym/tanka_renderer)
|
2
|
+
|
3
|
+
A rendering tool for short text such as tanka (31-mora Japanese poem).
|
4
|
+
|
5
|
+
![](http://myokoym.net/public/tanka_renderer-sample-tanka.png)
|
6
|
+
![](http://myokoym.net/public/tanka_renderer-sample-gyousyo.png)
|
7
|
+
|
8
|
+
## Sample's Fonts
|
9
|
+
|
10
|
+
[http://opentype.jp/freemouhitufont.htm](http://opentype.jp/freemouhitufont.htm)
|
11
|
+
|
12
|
+
## Using Libraries
|
13
|
+
|
14
|
+
* [rcairo](https://github.com/rcairo/rcairo)
|
15
|
+
* Ruby/Pango in [Ruby-GNOME2](http://ruby-gnome2.sourceforge.jp/)
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
gem 'tanka_renderer'
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install tanka_renderer
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
See sample/.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
Copyright (c) 2014 Masafumi Yokoyama
|
38
|
+
|
39
|
+
LGPLv3 or later.
|
40
|
+
|
41
|
+
See 'license/lgpl-3.0.txt' or 'http://www.gnu.org/licenses/lgpl-3.0' for details.
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( http://github.com/myokoym/tanka_renderer/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require "cairo"
|
2
|
+
require "pango"
|
3
|
+
require "fontdock"
|
4
|
+
|
5
|
+
module TankaRenderer
|
6
|
+
module Renderer
|
7
|
+
module Base
|
8
|
+
attr_accessor :width, :height, :font
|
9
|
+
attr_accessor :body_color, :text_color
|
10
|
+
attr_accessor :vertical
|
11
|
+
def initialize
|
12
|
+
@width = 300
|
13
|
+
@height = 500
|
14
|
+
@font = "IPAMincho"
|
15
|
+
@body_color = :white
|
16
|
+
@text_color = :black
|
17
|
+
@vertical = true
|
18
|
+
end
|
19
|
+
|
20
|
+
def guess_font(part_of_font_name)
|
21
|
+
@font = Fontdock::Local.find(part_of_font_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def render(text, output_path)
|
25
|
+
@width, @height = @height, @width unless @vertical
|
26
|
+
end
|
27
|
+
|
28
|
+
def draw(context, text)
|
29
|
+
draw_body(context)
|
30
|
+
draw_text(context, text)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def draw_body(context)
|
35
|
+
context.set_source_color(@body_color)
|
36
|
+
context.paint
|
37
|
+
end
|
38
|
+
|
39
|
+
def draw_text(context, text)
|
40
|
+
context.set_source_color(@text_color)
|
41
|
+
layout = context.create_pango_layout
|
42
|
+
if @vertical
|
43
|
+
layout.context.base_gravity = :east
|
44
|
+
else
|
45
|
+
layout.context.base_gravity = :south
|
46
|
+
end
|
47
|
+
layout.text = text
|
48
|
+
size = calc_font_size(text)
|
49
|
+
layout.font_description = Pango::FontDescription.new("#{@font} #{size}")
|
50
|
+
if @vertical
|
51
|
+
x = @width / 2 + text.each_line.to_a.length * size / 1.5
|
52
|
+
y = @height / 30
|
53
|
+
else
|
54
|
+
x = @width / 30
|
55
|
+
y = @height / 2 - text.each_line.to_a.length * size / 1.5
|
56
|
+
end
|
57
|
+
context.move_to(x, y)
|
58
|
+
context.rotate(Math::PI / 2) if @vertical
|
59
|
+
context.show_pango_layout(layout)
|
60
|
+
end
|
61
|
+
|
62
|
+
def calc_font_size(text)
|
63
|
+
max_length = 0
|
64
|
+
text.each_line do |line|
|
65
|
+
length = line.scan(/[ -~]/).length
|
66
|
+
length += line.scan(/[^ -~]/).length * 2
|
67
|
+
max_length = length if length > max_length
|
68
|
+
end
|
69
|
+
if @vertical
|
70
|
+
@height * 1.4 / max_length
|
71
|
+
else
|
72
|
+
@width * 1.4 / max_length
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "tanka_renderer/renderer/base"
|
2
|
+
|
3
|
+
module TankaRenderer
|
4
|
+
module Renderer
|
5
|
+
class Image
|
6
|
+
include Base
|
7
|
+
|
8
|
+
def render(text, output_path)
|
9
|
+
super
|
10
|
+
Cairo::ImageSurface.new(:argb32, @width, @height) do |surface|
|
11
|
+
Cairo::Context.new(surface) do |context|
|
12
|
+
draw(context, text)
|
13
|
+
end
|
14
|
+
surface.write_to_png(output_path)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "tanka_renderer/renderer/base"
|
2
|
+
|
3
|
+
module TankaRenderer
|
4
|
+
module Renderer
|
5
|
+
class PDF
|
6
|
+
include Base
|
7
|
+
|
8
|
+
def render(text, output_path)
|
9
|
+
super
|
10
|
+
Cairo::PDFSurface.new(output_path, @width, @height) do |surface|
|
11
|
+
Cairo::Context.new(surface) do |context|
|
12
|
+
draw(context, text)
|
13
|
+
context.show_page
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/sample/image.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require "tanka_renderer"
|
5
|
+
|
6
|
+
painter = TankaRenderer::Renderer::Image.new
|
7
|
+
painter.font = "KouzanBrushFontGyousyoOTF"
|
8
|
+
painter.render(<<-END_OF_TEXT, "sample.png")
|
9
|
+
春はあけぼの やう/\しろく成り行く
|
10
|
+
山ぎは すこしあかりて むらさきだちたる
|
11
|
+
雲のほそくたなびきたる
|
12
|
+
|
13
|
+
夏はよる 月の比はさら也 やみも猶
|
14
|
+
ほたるの多く飛びちがひたる
|
15
|
+
又 ただ一つ二つなどほのかに
|
16
|
+
うちひかりて行くもをかし
|
17
|
+
|
18
|
+
「枕草子」より
|
19
|
+
END_OF_TEXT
|
data/sample/pdf.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require "tanka_renderer"
|
5
|
+
|
6
|
+
painter = TankaRenderer::Renderer::PDF.new
|
7
|
+
painter.font = "KouzanBrushFontOTF"
|
8
|
+
painter.vertical = true
|
9
|
+
painter.render(<<-END_OF_TEXT, "sample.pdf")
|
10
|
+
秋来ぬと目にはさやかに見えねども
|
11
|
+
|
12
|
+
風の音にぞおどろかれぬる
|
13
|
+
|
14
|
+
|
15
|
+
藤原敏行
|
16
|
+
END_OF_TEXT
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tanka_renderer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tanka_renderer"
|
8
|
+
spec.version = TankaRenderer::VERSION
|
9
|
+
spec.authors = ["Masafumi Yokoyama"]
|
10
|
+
spec.email = ["myokoym@gmail.com"]
|
11
|
+
spec.summary = %q{A rendering tool for short text}
|
12
|
+
spec.description = %q{A rendering tool for short text such as tanka (31-mora Japanese poem).}
|
13
|
+
spec.homepage = "https://github.com/myokoym/tanka_renderer"
|
14
|
+
spec.license = "LGPLv3"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency("cairo")
|
22
|
+
spec.add_runtime_dependency("pango")
|
23
|
+
spec.add_runtime_dependency("fontdock", ">= 0.0.2")
|
24
|
+
|
25
|
+
spec.add_development_dependency("test-unit")
|
26
|
+
spec.add_development_dependency("test-unit-notify")
|
27
|
+
spec.add_development_dependency("test-unit-rr")
|
28
|
+
spec.add_development_dependency("bundler", "~> 1.5")
|
29
|
+
spec.add_development_dependency("rake")
|
30
|
+
end
|
data/test/run-test.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "test-unit"
|
4
|
+
require "test/unit/notify"
|
5
|
+
require "test/unit/rr"
|
6
|
+
|
7
|
+
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
8
|
+
$LOAD_PATH.unshift(File.join(base_dir, "lib"))
|
9
|
+
$LOAD_PATH.unshift(File.join(base_dir, "test"))
|
10
|
+
|
11
|
+
exit Test::Unit::AutoRunner.run(true)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "tanka_renderer/renderer"
|
3
|
+
require "cairo"
|
4
|
+
|
5
|
+
class RendererTest < Test::Unit::TestCase
|
6
|
+
class BaseTest < self
|
7
|
+
def setup
|
8
|
+
@renderer = TankaRenderer::Renderer::Image.new
|
9
|
+
end
|
10
|
+
|
11
|
+
class GuessFontTest < self
|
12
|
+
def test_found
|
13
|
+
part_of_name = "M"
|
14
|
+
assert_match(/#{part_of_name}/, @renderer.guess_font(part_of_name))
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_not_found
|
18
|
+
part_of_name = "ABCDE12345"
|
19
|
+
assert_nil(@renderer.guess_font(part_of_name))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class DrawTest < self
|
24
|
+
def test_ten_characters
|
25
|
+
assert_nothing_raised_in_draw("1234567890")
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def assert_nothing_raised_in_draw(text)
|
30
|
+
width = 200
|
31
|
+
height = 200
|
32
|
+
assert_nothing_raised do
|
33
|
+
Cairo::ImageSurface.new(:argb32, width, height) do |surface|
|
34
|
+
Cairo::Context.new(surface) do |context|
|
35
|
+
@renderer.draw(context, text)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class ImageTest < self
|
44
|
+
def setup
|
45
|
+
@renderer = TankaRenderer::Renderer::Image.new
|
46
|
+
@tmp_dir = File.join(File.dirname(__FILE__), "tmp")
|
47
|
+
FileUtils.mkdir_p(@tmp_dir)
|
48
|
+
end
|
49
|
+
|
50
|
+
def teardown
|
51
|
+
FileUtils.rm(Dir.glob(File.join(@tmp_dir, "*")))
|
52
|
+
FileUtils.rmdir(@tmp_dir)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_render
|
56
|
+
output_path = File.join(@tmp_dir, "test.png")
|
57
|
+
@renderer.render("南家", output_path)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class PDFTest < self
|
62
|
+
def setup
|
63
|
+
@renderer = TankaRenderer::Renderer::PDF.new
|
64
|
+
@tmp_dir = File.join(File.dirname(__FILE__), "tmp")
|
65
|
+
FileUtils.mkdir_p(@tmp_dir)
|
66
|
+
end
|
67
|
+
|
68
|
+
def teardown
|
69
|
+
FileUtils.rm(Dir.glob(File.join(@tmp_dir, "*")))
|
70
|
+
FileUtils.rmdir(@tmp_dir)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_render
|
74
|
+
output_path = File.join(@tmp_dir, "test.pdf")
|
75
|
+
@renderer.render("神薙", output_path)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tanka_renderer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masafumi Yokoyama
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cairo
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pango
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fontdock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit-notify
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: test-unit-rr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.5'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.5'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: A rendering tool for short text such as tanka (31-mora Japanese poem).
|
126
|
+
email:
|
127
|
+
- myokoym@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".travis.yml"
|
134
|
+
- Gemfile
|
135
|
+
- NEWS.md
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- lib/tanka_renderer.rb
|
139
|
+
- lib/tanka_renderer/renderer.rb
|
140
|
+
- lib/tanka_renderer/renderer/base.rb
|
141
|
+
- lib/tanka_renderer/renderer/image.rb
|
142
|
+
- lib/tanka_renderer/renderer/pdf.rb
|
143
|
+
- lib/tanka_renderer/version.rb
|
144
|
+
- license/lgpl-3.0.txt
|
145
|
+
- sample/image.rb
|
146
|
+
- sample/pdf.rb
|
147
|
+
- tanka_renderer.gemspec
|
148
|
+
- test/run-test.rb
|
149
|
+
- test/test-renderer.rb
|
150
|
+
homepage: https://github.com/myokoym/tanka_renderer
|
151
|
+
licenses:
|
152
|
+
- LGPLv3
|
153
|
+
metadata: {}
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
requirements: []
|
169
|
+
rubyforge_project:
|
170
|
+
rubygems_version: 2.2.0
|
171
|
+
signing_key:
|
172
|
+
specification_version: 4
|
173
|
+
summary: A rendering tool for short text
|
174
|
+
test_files:
|
175
|
+
- test/run-test.rb
|
176
|
+
- test/test-renderer.rb
|