rsvg2 2.2.3 → 2.2.4
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 +4 -4
- data/Rakefile +1 -1
- data/ext/rsvg2/extconf.rb +2 -15
- data/ext/rsvg2/rbrsvghandle.c +46 -25
- data/ext/rsvg2/rsvg2.h +4 -2
- data/test/rsvg2-test-utils.rb +23 -0
- data/test/run-test.rb +49 -0
- data/test/test-handle.rb +91 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18a414e9b9ef9208f8a98463d437b79e25eb0c9e
|
4
|
+
data.tar.gz: aa6884c40c7198d758c9a4b0388652b8fa62ea39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27afbac556c96722250c8e07dacf5d26d4174cc0a71c3ea12c777979dce7f17b81ec0d2d4d5819eb5dc62bc66c07c7de80cd00abd6c8da483bc832ae72196f59
|
7
|
+
data.tar.gz: 1c9cd3551351a3197f771978adbe5e4d0dba26082fba3389bbd872fd37b91158c0a7cecb03689856135c9a7a7e884f304d6ad40fe6d2058626a276f5f0e15322
|
data/Rakefile
CHANGED
data/ext/rsvg2/extconf.rb
CHANGED
@@ -39,24 +39,11 @@ end
|
|
39
39
|
:target_build_dir => build_dir)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
rcairo_source_dir_names = ["rcairo"]
|
44
|
-
if /mingw|cygwin|mswin/ =~ RUBY_PLATFORM
|
45
|
-
rcairo_source_dir_names.unshift("rcairo.win32")
|
46
|
-
end
|
47
|
-
rcairo_source_dir_names.each do |rcairo_source_dir_name|
|
48
|
-
rcairo_source_dir = top_dir.parent.expand_path + rcairo_source_dir_name
|
49
|
-
if rcairo_source_dir.exist?
|
50
|
-
rcairo_options[:rcairo_source_dir] = rcairo_source_dir.to_s
|
51
|
-
break
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
unless check_cairo(rcairo_options)
|
42
|
+
unless check_cairo(:top_dir => top_dir)
|
56
43
|
exit(false)
|
57
44
|
end
|
58
45
|
|
59
|
-
|
46
|
+
setup_windows(module_name, base_dir)
|
60
47
|
|
61
48
|
unless required_pkg_config_package(package_id,
|
62
49
|
:debian => "librsvg2-dev",
|
data/ext/rsvg2/rbrsvghandle.c
CHANGED
@@ -109,13 +109,44 @@ rg_s_new_from_data(G_GNUC_UNUSED VALUE self, VALUE data)
|
|
109
109
|
}
|
110
110
|
|
111
111
|
static VALUE
|
112
|
-
rg_s_new_from_file(
|
112
|
+
rg_s_new_from_file(int argc, VALUE *argv, VALUE self)
|
113
113
|
{
|
114
|
+
VALUE rb_file_path, rb_options, rb_flags;
|
114
115
|
GError *error = NULL;
|
115
116
|
RsvgHandle *handle;
|
116
117
|
|
117
|
-
|
118
|
+
rb_scan_args(argc, argv, "11", &rb_file_path, &rb_options);
|
119
|
+
rbg_scan_options(rb_options,
|
120
|
+
"flags", &rb_flags,
|
121
|
+
NULL);
|
122
|
+
|
123
|
+
#if LIBRSVG_CHECK_VERSION(2, 40, 3)
|
124
|
+
{
|
125
|
+
GFile *file;
|
126
|
+
GCancellable *cancellable = NULL;
|
127
|
+
RsvgHandleFlags flags = RSVG_HANDLE_FLAGS_NONE;
|
128
|
+
|
129
|
+
if (!NIL_P(rb_flags)) {
|
130
|
+
flags = RVAL2GFLAGS(rb_flags, RSVG_TYPE_HANDLE_FLAGS);
|
131
|
+
}
|
132
|
+
|
133
|
+
file = g_file_new_for_path((const char *)RVAL2CSTR(rb_file_path));
|
134
|
+
handle = rsvg_handle_new_from_gfile_sync(file, flags,
|
135
|
+
cancellable,
|
136
|
+
&error);
|
137
|
+
g_object_unref(file);
|
138
|
+
}
|
139
|
+
#else
|
140
|
+
if (!NIL_P(rb_flags)) {
|
141
|
+
rb_raise(rb_eArgError,
|
142
|
+
"librsvg 2.40.3 or later is required for :flags: <%d.%d.%d>",
|
143
|
+
LIBRSVG_MAJOR_VERSION,
|
144
|
+
LIBRSVG_MINOR_VERSION,
|
145
|
+
LIBRSVG_MICRO_VERSION);
|
146
|
+
}
|
147
|
+
handle = rsvg_handle_new_from_file((const gchar *)RVAL2CSTR(rb_file_path),
|
118
148
|
&error);
|
149
|
+
#endif
|
119
150
|
|
120
151
|
if (error)
|
121
152
|
RAISE_GERROR(error);
|
@@ -232,21 +263,6 @@ rg_pixbuf(int argc, VALUE *argv, VALUE self)
|
|
232
263
|
return rb_pixbuf;
|
233
264
|
}
|
234
265
|
|
235
|
-
#if LIBRSVG_CHECK_VERSION(2, 9, 0)
|
236
|
-
static VALUE
|
237
|
-
rg_base_uri(VALUE self)
|
238
|
-
{
|
239
|
-
return CSTR2RVAL(rsvg_handle_get_base_uri(_SELF(self)));
|
240
|
-
}
|
241
|
-
|
242
|
-
static VALUE
|
243
|
-
rg_set_base_uri(VALUE self, VALUE base_uri)
|
244
|
-
{
|
245
|
-
rsvg_handle_set_base_uri(_SELF(self), RVAL2CSTR(base_uri));
|
246
|
-
return self;
|
247
|
-
}
|
248
|
-
#endif
|
249
|
-
|
250
266
|
#ifdef HAVE_TYPE_RSVGDIMENSIONDATA
|
251
267
|
static VALUE
|
252
268
|
rg_dimensions(VALUE self)
|
@@ -266,6 +282,7 @@ rg_dimensions(VALUE self)
|
|
266
282
|
}
|
267
283
|
#endif
|
268
284
|
|
285
|
+
#if !LIBRSVG_CHECK_VERSION(2, 36, 0)
|
269
286
|
/* Accessibility API */
|
270
287
|
static VALUE
|
271
288
|
rg_title(VALUE self)
|
@@ -279,12 +296,13 @@ rg_desc(VALUE self)
|
|
279
296
|
return CSTR2RVAL(rsvg_handle_get_desc(_SELF(self)));
|
280
297
|
}
|
281
298
|
|
282
|
-
#ifdef HAVE_RSVG_HANDLE_GET_METADATA
|
299
|
+
# ifdef HAVE_RSVG_HANDLE_GET_METADATA
|
283
300
|
static VALUE
|
284
301
|
rg_metadata(VALUE self)
|
285
302
|
{
|
286
303
|
return CSTR2RVAL(rsvg_handle_get_metadata(_SELF(self)));
|
287
304
|
}
|
305
|
+
# endif
|
288
306
|
#endif
|
289
307
|
|
290
308
|
#if !LIBRSVG_CHECK_VERSION(2, 11, 0)
|
@@ -432,7 +450,7 @@ Init_rsvg_handle(VALUE mRSVG)
|
|
432
450
|
|
433
451
|
#if LIBRSVG_CHECK_VERSION(2, 14, 0)
|
434
452
|
RG_DEF_SMETHOD(new_from_data, 1);
|
435
|
-
RG_DEF_SMETHOD(new_from_file, 1);
|
453
|
+
RG_DEF_SMETHOD(new_from_file, -1);
|
436
454
|
#endif
|
437
455
|
|
438
456
|
RG_DEF_METHOD(initialize, -1);
|
@@ -444,20 +462,17 @@ Init_rsvg_handle(VALUE mRSVG)
|
|
444
462
|
RG_DEF_METHOD_P(closed, 0);
|
445
463
|
RG_DEF_METHOD(pixbuf, -1);
|
446
464
|
|
447
|
-
#if LIBRSVG_CHECK_VERSION(2, 9, 0)
|
448
|
-
RG_DEF_METHOD(base_uri, 0);
|
449
|
-
RG_DEF_METHOD(set_base_uri, 1);
|
450
|
-
#endif
|
451
|
-
|
452
465
|
#ifdef HAVE_TYPE_RSVGDIMENSIONDATA
|
453
466
|
RG_DEF_METHOD(dimensions, 0);
|
454
467
|
#endif
|
455
468
|
|
469
|
+
#if !LIBRSVG_CHECK_VERSION(2, 36, 0)
|
456
470
|
/* Accessibility API */
|
457
471
|
RG_DEF_METHOD(title, 0);
|
458
472
|
RG_DEF_METHOD(desc, 0);
|
459
|
-
#ifdef HAVE_RSVG_HANDLE_GET_METADATA
|
473
|
+
# ifdef HAVE_RSVG_HANDLE_GET_METADATA
|
460
474
|
RG_DEF_METHOD(metadata, 0);
|
475
|
+
# endif
|
461
476
|
#endif
|
462
477
|
|
463
478
|
#if !LIBRSVG_CHECK_VERSION(2, 11, 0)
|
@@ -472,4 +487,10 @@ Init_rsvg_handle(VALUE mRSVG)
|
|
472
487
|
#ifdef HAVE_LIBRSVG_RSVG_CAIRO_H
|
473
488
|
RG_DEF_METHOD(render_cairo, -1);
|
474
489
|
#endif
|
490
|
+
|
491
|
+
#if LIBRSVG_CHECK_VERSION(2, 40, 3)
|
492
|
+
/* RsvgHandleFlags */
|
493
|
+
G_DEF_CLASS(RSVG_TYPE_HANDLE_FLAGS, "Flags", RG_TARGET_NAMESPACE);
|
494
|
+
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, RSVG_TYPE_HANDLE_FLAGS, "RSVG_HANDLE_");
|
495
|
+
#endif
|
475
496
|
}
|
data/ext/rsvg2/rsvg2.h
CHANGED
@@ -49,14 +49,16 @@ extern "C" {
|
|
49
49
|
# include "librsvg-enum-types.h"
|
50
50
|
#endif
|
51
51
|
|
52
|
-
#include <librsvg/librsvg-features.h>
|
53
|
-
|
54
52
|
#define LIBRSVG_CHECK_VERSION(major, minor, micro) \
|
55
53
|
(LIBRSVG_MAJOR_VERSION > (major) || \
|
56
54
|
(LIBRSVG_MAJOR_VERSION == (major) && LIBRSVG_MINOR_VERSION > (minor)) || \
|
57
55
|
(LIBRSVG_MAJOR_VERSION == (major) && LIBRSVG_MINOR_VERSION == (minor) && \
|
58
56
|
LIBRSVG_MICRO_VERSION >= (micro)))
|
59
57
|
|
58
|
+
#if !LIBRSVG_CHECK_VERSION(2, 36, 2)
|
59
|
+
# include <librsvg/librsvg-features.h>
|
60
|
+
#endif
|
61
|
+
|
60
62
|
|
61
63
|
G_GNUC_INTERNAL void Init_rsvg_handle(VALUE mRSVG);
|
62
64
|
G_GNUC_INTERNAL void Init_rsvg_dimensiondata(VALUE mRSVG);
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "test-unit"
|
18
|
+
require "test/unit/notify"
|
19
|
+
|
20
|
+
require "fileutils"
|
21
|
+
|
22
|
+
module RSVG2TestUtils
|
23
|
+
end
|
data/test/run-test.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
|
19
|
+
ruby_gnome2_base = File.join(File.dirname(__FILE__), "..", "..")
|
20
|
+
ruby_gnome2_base = File.expand_path(ruby_gnome2_base)
|
21
|
+
|
22
|
+
glib_base = File.join(ruby_gnome2_base, "glib2")
|
23
|
+
gdk_pixbuf2_base = File.join(ruby_gnome2_base, "gdk_pixbuf2")
|
24
|
+
rsvg2_base = File.join(ruby_gnome2_base, "rsvg2")
|
25
|
+
|
26
|
+
have_make = system("which make > /dev/null")
|
27
|
+
|
28
|
+
modules = [
|
29
|
+
[glib_base, "glib2"],
|
30
|
+
[gdk_pixbuf2_base, "gdk_pixbuf2"],
|
31
|
+
[rsvg2_base, "rsvg2"],
|
32
|
+
]
|
33
|
+
modules.each do |target, module_name|
|
34
|
+
if File.exist?(File.join(target, "Makefile")) and have_make
|
35
|
+
`make -C #{target.dump} > /dev/null` or exit(false)
|
36
|
+
end
|
37
|
+
$LOAD_PATH.unshift(File.join(target, "ext", module_name))
|
38
|
+
$LOAD_PATH.unshift(File.join(target, "lib"))
|
39
|
+
end
|
40
|
+
|
41
|
+
$LOAD_PATH.unshift(File.join(glib_base, "test"))
|
42
|
+
require "glib-test-init"
|
43
|
+
|
44
|
+
$LOAD_PATH.unshift(File.join(rsvg2_base, "test"))
|
45
|
+
require "rsvg2-test-utils"
|
46
|
+
|
47
|
+
require "rsvg2"
|
48
|
+
|
49
|
+
exit Test::Unit::AutoRunner.run(true)
|
data/test/test-handle.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
class TestHandle < Test::Unit::TestCase
|
18
|
+
sub_test_case ".new_from_file" do
|
19
|
+
sub_test_case "options" do
|
20
|
+
def setup
|
21
|
+
setup_svg
|
22
|
+
end
|
23
|
+
|
24
|
+
def setup_svg
|
25
|
+
@svg_path = "tmp/empty.svg"
|
26
|
+
return if File.exist?(@svg_path)
|
27
|
+
|
28
|
+
FileUtils.mkdir_p(File.dirname(@svg_path))
|
29
|
+
File.open(@svg_path, "w") do |svg|
|
30
|
+
svg.puts(<<-SVG)
|
31
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
32
|
+
<svg>
|
33
|
+
</svg>
|
34
|
+
SVG
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_empty_options
|
39
|
+
handle = RSVG::Handle.new_from_file(@svg_path, {})
|
40
|
+
assert_equal([0, 0, 0.0, 0.0],
|
41
|
+
handle.dimensions.to_a)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
sub_test_case ":flags => :unlimited" do
|
46
|
+
def setup
|
47
|
+
setup_large_svg
|
48
|
+
end
|
49
|
+
|
50
|
+
def setup_large_svg
|
51
|
+
@large_svg_path = "tmp/large-file.svg"
|
52
|
+
return if File.exist?(@large_svg_path)
|
53
|
+
|
54
|
+
FileUtils.mkdir_p(File.dirname(@large_svg_path))
|
55
|
+
large_byte = (10 * 1024 * 1024).to_i
|
56
|
+
File.open(@large_svg_path, "w") do |svg|
|
57
|
+
svg.puts(<<-SVG_HEADER)
|
58
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
59
|
+
<svg>
|
60
|
+
SVG_HEADER
|
61
|
+
large_byte.times do
|
62
|
+
svg.puts("\n")
|
63
|
+
end
|
64
|
+
svg.puts(<<-SVG_FOOTER)
|
65
|
+
</svg>
|
66
|
+
SVG_FOOTER
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_no_option
|
71
|
+
assert_raise(RSVG::Error::Failed) do
|
72
|
+
RSVG::Handle.new_from_file(@large_svg_path)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_unlimited
|
77
|
+
handle = RSVG::Handle.new_from_file(@large_svg_path,
|
78
|
+
:flags => :flag_unlimited)
|
79
|
+
assert_equal([0, 0, 0.0, 0.0],
|
80
|
+
handle.dimensions.to_a)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_base_uri
|
84
|
+
handle = RSVG::Handle.new
|
85
|
+
uri_string = "test_base_uri"
|
86
|
+
handle.base_uri = uri_string
|
87
|
+
assert_match(uri_string, handle.base_uri)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsvg2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Ruby-GNOME2 Project Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cairo
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.2.
|
33
|
+
version: 2.2.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.2.
|
40
|
+
version: 2.2.4
|
41
41
|
description: Ruby/RSVG is a Ruby binding of librsvg-2.x.
|
42
42
|
email: ruby-gnome2-devel-en@lists.sourceforge.net
|
43
43
|
executables: []
|
@@ -58,6 +58,9 @@ files:
|
|
58
58
|
- lib/rsvg2.rb
|
59
59
|
- sample/svg-viewer.rb
|
60
60
|
- sample/svg2.rb
|
61
|
+
- test/rsvg2-test-utils.rb
|
62
|
+
- test/run-test.rb
|
63
|
+
- test/test-handle.rb
|
61
64
|
homepage: http://ruby-gnome2.sourceforge.jp/
|
62
65
|
licenses:
|
63
66
|
- LGPLv2.1 or later
|