savage 1.0.2 → 1.0.3
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/parser.rb +4 -4
- data/savage.gemspec +2 -2
- data/spec/savage/parser_spec.rb +17 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/lib/savage/parser.rb
CHANGED
@@ -18,7 +18,7 @@ module Savage
|
|
18
18
|
subpaths = []
|
19
19
|
if move_index = parsable.index(/[Mm]/)
|
20
20
|
subpaths << parsable[0...move_index] if move_index > 0
|
21
|
-
parsable.scan /[Mm][
|
21
|
+
parsable.scan /[Mm](?:\d|[.,-]|[LlHhVvQqCcTtSsAaZz]|\W)+/m do |match_group|
|
22
22
|
subpaths << $&
|
23
23
|
end
|
24
24
|
else
|
@@ -35,7 +35,7 @@ module Savage
|
|
35
35
|
|
36
36
|
def extract_directions(parsable)
|
37
37
|
directions = []
|
38
|
-
parsable.scan /[
|
38
|
+
parsable.scan /[MmLlHhVvQqCcTtSsAaZz](?:\d|[.,-]|\W)*/m do |match_group|
|
39
39
|
direction = build_direction $&
|
40
40
|
if direction.kind_of?(Array)
|
41
41
|
directions.concat direction
|
@@ -129,11 +129,11 @@ module Savage
|
|
129
129
|
|
130
130
|
def extract_coordinates(command_string)
|
131
131
|
coordinates = []
|
132
|
-
command_string.scan
|
132
|
+
command_string.scan(/-?\d+(\.\d+)?/) do |match_group|
|
133
133
|
coordinates << $&.to_f
|
134
134
|
end
|
135
135
|
coordinates
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
139
|
-
end
|
139
|
+
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.3"
|
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-
|
12
|
+
s.date = %q{2010-09-04}
|
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 = [
|
data/spec/savage/parser_spec.rb
CHANGED
@@ -20,6 +20,14 @@ describe Parser do
|
|
20
20
|
path.subpaths.last.directions.last.class.should == Directions::MoveTo
|
21
21
|
end
|
22
22
|
|
23
|
+
it 'should handle comma separated coordinates' do
|
24
|
+
path = Parser.parse("M100,200")
|
25
|
+
path.class.should == Path
|
26
|
+
path.subpaths.length.should == 1
|
27
|
+
path.subpaths.last.directions.length.should == 1
|
28
|
+
path.subpaths.last.directions.last.class.should == Directions::MoveTo
|
29
|
+
end
|
30
|
+
|
23
31
|
it 'should return a path object with one subpath containing a move_to and a line_to when the string is a move_to command followed by a line_to command' do
|
24
32
|
path = Parser.parse("M100 200l-342.65 21")
|
25
33
|
path.class.should == Path
|
@@ -175,5 +183,13 @@ describe Parser do
|
|
175
183
|
path = Parser.parse(path_string)
|
176
184
|
path.to_command.should == path_string
|
177
185
|
end
|
186
|
+
|
187
|
+
it "should be able to parse complex paths" do
|
188
|
+
path = Parser.parse("M74.89,146.249c0.042,0.552,0.376,0.685,0.744,0.293m50.543-9.1323c15.445-16.43,32.782-32.859,49.793-49.289 c-6.298,0.001-12.595,0.001-18.893,0c-10.813,10.37-21.759,20.737-32.275,31.107C74.249,134.323,74.424,140.285,74.89,146.249z")
|
189
|
+
path.class.should == Path
|
190
|
+
path.subpaths.length.should == 2
|
191
|
+
path.subpaths[0].directions.length.should == 2
|
192
|
+
path.subpaths[1].directions.length.should == 6
|
193
|
+
end
|
178
194
|
end
|
179
|
-
end
|
195
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: savage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Holland
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-04 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|