savage 1.0.0 → 1.0.1
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.
- data/VERSION +1 -1
- data/lib/savage/sub_path.rb +2 -0
- data/savage.gemspec +3 -3
- data/spec/savage/parser_spec.rb +5 -0
- data/spec/savage/sub_path_spec.rb +40 -0
- metadata +9 -20
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/lib/savage/sub_path.rb
CHANGED
@@ -5,6 +5,8 @@ module Savage
|
|
5
5
|
|
6
6
|
define_proxies do |sym,const|
|
7
7
|
define_method(sym) do |*args|
|
8
|
+
raise TypeError if const == "QuadraticCurveTo" && @directions.last.class != Directions::QuadraticCurveTo && [2,3].include?(args.length)
|
9
|
+
raise TypeError if const == "CubicCurveTo" && @directions.last.class != Directions::CubicCurveTo && [4,5].include?(args.length)
|
8
10
|
(@directions << constantize("Savage::Directions::" << const).new(*args)).last
|
9
11
|
end
|
10
12
|
end
|
data/savage.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{savage}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeremy Holland"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-20}
|
13
13
|
s.description = %q{A little gem for extracting and manipulating SVG vector path data.}
|
14
14
|
s.email = %q{jeremy@jeremypholland.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -64,7 +64,7 @@ Gem::Specification.new do |s|
|
|
64
64
|
s.homepage = %q{http://github.com/therubyneck/savage}
|
65
65
|
s.rdoc_options = ["--charset=UTF-8"]
|
66
66
|
s.require_paths = ["lib"]
|
67
|
-
s.rubygems_version = %q{1.3.
|
67
|
+
s.rubygems_version = %q{1.3.5}
|
68
68
|
s.summary = %q{A little library to manipulate SVG path data}
|
69
69
|
s.test_files = [
|
70
70
|
"spec/savage/directions/arc_to_spec.rb",
|
data/spec/savage/parser_spec.rb
CHANGED
@@ -170,5 +170,10 @@ describe Parser do
|
|
170
170
|
path.subpaths[1].directions[1].target.x.should == -423
|
171
171
|
path.subpaths[1].directions[1].target.y.should == 11.1
|
172
172
|
end
|
173
|
+
it 'should generate the same string given to it (assuming float values are used), if not changed in the interim' do
|
174
|
+
path_string = "M100.0 200.0A255.0 12.0-123.0 1 0 23.0-93.4L100.0 200.0 300.0 400.0Q1.233-34.0 255.0 12.0T255.0 12.0H-342.65Z"
|
175
|
+
path = Parser.parse(path_string)
|
176
|
+
path.to_command.should == path_string
|
177
|
+
end
|
173
178
|
end
|
174
179
|
end
|
@@ -64,6 +64,46 @@ describe SubPath do
|
|
64
64
|
path2.directions[1].class.should == Directions::CubicCurveTo
|
65
65
|
path2.directions[2].class.should == Directions::ArcTo
|
66
66
|
end
|
67
|
+
describe '#quadratic_curve_to' do
|
68
|
+
it 'should raise an error if in short format and the previous command is of any type by QuadraticCurveTo' do
|
69
|
+
path = SubPath.new
|
70
|
+
lambda { path.quadratic_curve_to 500, 600 }.should raise_error
|
71
|
+
path = SubPath.new
|
72
|
+
path.move_to 233, 123
|
73
|
+
lambda { path.quadratic_curve_to 500, 600 }.should raise_error
|
74
|
+
path = SubPath.new
|
75
|
+
path.line_to 443, 265
|
76
|
+
lambda { path.quadratic_curve_to 500, 600 }.should raise_error
|
77
|
+
path = SubPath.new
|
78
|
+
path.cubic_curve_to 100,200,300,400,500,600
|
79
|
+
lambda { path.quadratic_curve_to 500, 600 }.should raise_error
|
80
|
+
end
|
81
|
+
it 'should not raise an error if in short format and the previous command is of type QuadraticCurveTo' do
|
82
|
+
path = SubPath.new
|
83
|
+
path.quadratic_curve_to 100,200,300,400
|
84
|
+
lambda { path.quadratic_curve_to 500, 600 }.should_not raise_error
|
85
|
+
end
|
86
|
+
end
|
87
|
+
describe '#cubic_curve_to' do
|
88
|
+
it 'should raise an error if in short format and the previous command is of any type by CubicCurveTo' do
|
89
|
+
path = SubPath.new
|
90
|
+
lambda { path.cubic_curve_to 500, 600, 700, 800 }.should raise_error
|
91
|
+
path = SubPath.new
|
92
|
+
path.move_to 233, 123
|
93
|
+
lambda { path.cubic_curve_to 500, 600, 700, 800 }.should raise_error
|
94
|
+
path = SubPath.new
|
95
|
+
path.line_to 443, 265
|
96
|
+
lambda { path.cubic_curve_to 500, 600, 700, 800 }.should raise_error
|
97
|
+
path = SubPath.new
|
98
|
+
path.quadratic_curve_to 100,200,300,400
|
99
|
+
lambda { path.cubic_curve_to 500, 600, 700, 800 }.should raise_error
|
100
|
+
end
|
101
|
+
it 'should not raise an error if in short format and the previous command is of type CubicCurveTo' do
|
102
|
+
path = SubPath.new
|
103
|
+
path.cubic_curve_to 100,200,300,400,500,600
|
104
|
+
lambda { path.cubic_curve_to 500, 600, 700, 800 }.should_not raise_error
|
105
|
+
end
|
106
|
+
end
|
67
107
|
describe '#closed?' do
|
68
108
|
it 'should be true if the last direction in the directions list is of type ClosePath' do
|
69
109
|
path = SubPath.new
|
metadata
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: savage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
version: 1.0.0
|
4
|
+
version: 1.0.1
|
10
5
|
platform: ruby
|
11
6
|
authors:
|
12
7
|
- Jeremy Holland
|
@@ -14,23 +9,19 @@ autorequire:
|
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
11
|
|
17
|
-
date: 2010-05-
|
12
|
+
date: 2010-05-20 00:00:00 -05:00
|
18
13
|
default_executable:
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: rspec
|
22
|
-
|
23
|
-
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
20
|
requirements:
|
25
21
|
- - ">="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 2
|
30
|
-
- 9
|
31
23
|
version: 1.2.9
|
32
|
-
|
33
|
-
version_requirements: *id001
|
24
|
+
version:
|
34
25
|
description: A little gem for extracting and manipulating SVG vector path data.
|
35
26
|
email: jeremy@jeremypholland.com
|
36
27
|
executables: []
|
@@ -97,20 +88,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
88
|
requirements:
|
98
89
|
- - ">="
|
99
90
|
- !ruby/object:Gem::Version
|
100
|
-
segments:
|
101
|
-
- 0
|
102
91
|
version: "0"
|
92
|
+
version:
|
103
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
94
|
requirements:
|
105
95
|
- - ">="
|
106
96
|
- !ruby/object:Gem::Version
|
107
|
-
segments:
|
108
|
-
- 0
|
109
97
|
version: "0"
|
98
|
+
version:
|
110
99
|
requirements: []
|
111
100
|
|
112
101
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.3.
|
102
|
+
rubygems_version: 1.3.5
|
114
103
|
signing_key:
|
115
104
|
specification_version: 3
|
116
105
|
summary: A little library to manipulate SVG path data
|