savage 1.1.4 → 1.1.5

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.
@@ -92,6 +92,7 @@ I have no doubt that will be some problems with this thing, as well as features
92
92
 
93
93
  * Jeremy Holland (jeremy@jeremypholland.com, github:awebneck) -- author
94
94
  * Christoffer Klang (toffeklang@yahoo.se, github:christoffer) -- regexp improvements
95
+ * MatmaRex (github:MatmaRex) -- parser improvements, scientific notation support, bug fixes
95
96
 
96
97
  == Copyright
97
98
 
data/Rakefile CHANGED
@@ -11,7 +11,6 @@ begin
11
11
  gem.homepage = "http://github.com/awebneck/savage"
12
12
  gem.authors = ["Jeremy Holland"]
13
13
  gem.add_development_dependency "rspec", ">= 2.3.0"
14
- gem.add_dependency "activesupport", ">= 2.3.5"
15
14
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
15
  end
17
16
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.4
1
+ 1.1.5
@@ -1,8 +1,3 @@
1
- begin
2
- require 'active_support/core_ext/string/inflections'
3
- rescue LoadError, NameError
4
- require 'activesupport'
5
- end
6
1
  SAVAGE_PATH = File.dirname(__FILE__) + "/savage/"
7
2
  [
8
3
  'utils',
@@ -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](?:\d|[eE.,-]|[LlHhVvQqCcTtSsAaZz]|\W)+/m do |match_group|
21
+ parsable.scan /[Mm](?:\d|[eE.,+-]|[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 /[MmLlHhVvQqCcTtSsAaZz](?:\d|[eE.,-]|\W)*/m do |match_group|
38
+ parsable.scan /[MmLlHhVvQqCcTtSsAaZz](?:\d|[eE.,+-]|\W)*/m do |match_group|
39
39
  direction = build_direction $&
40
40
  if direction.kind_of?(Array)
41
41
  directions.concat direction
@@ -127,7 +127,7 @@ module Savage
127
127
 
128
128
  def extract_coordinates(command_string)
129
129
  coordinates = []
130
- command_string.scan(/-?\d+(\.\d+)?([eE]-?\d+)?/) do |match_group|
130
+ command_string.scan(/-?\d+(\.\d+)?([eE][+-]?\d+)?/) do |match_group|
131
131
  coordinates << $&.to_f
132
132
  end
133
133
  coordinates
@@ -7,7 +7,7 @@ module Savage
7
7
  define_method(sym) do |*args|
8
8
  raise TypeError if const == "QuadraticCurveTo" && @directions.last.class != Directions::QuadraticCurveTo && [2,3].include?(args.length)
9
9
  raise TypeError if const == "CubicCurveTo" && @directions.last.class != Directions::CubicCurveTo && [4,5].include?(args.length)
10
- (@directions << ("Savage::Directions::" << const).constantize.new(*args)).last
10
+ (@directions << Savage::Directions.const_get(const).new(*args)).last
11
11
  end
12
12
  end
13
13
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "savage"
8
- s.version = "1.1.4"
8
+ s.version = "1.1.5"
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 = "2011-12-02"
12
+ s.date = "2011-12-28"
13
13
  s.description = "A little gem for extracting and manipulating SVG vector path data."
14
14
  s.email = "jeremy@jeremypholland.com"
15
15
  s.extra_rdoc_files = [
@@ -70,14 +70,11 @@ Gem::Specification.new do |s|
70
70
 
71
71
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
72
72
  s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
73
- s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
74
73
  else
75
74
  s.add_dependency(%q<rspec>, [">= 2.3.0"])
76
- s.add_dependency(%q<activesupport>, [">= 2.3.5"])
77
75
  end
78
76
  else
79
77
  s.add_dependency(%q<rspec>, [">= 2.3.0"])
80
- s.add_dependency(%q<activesupport>, [">= 2.3.5"])
81
78
  end
82
79
  end
83
80
 
@@ -19,7 +19,7 @@ describe Parser do
19
19
  path.subpaths.last.directions.length.should == 1
20
20
  path.subpaths.last.directions.last.class.should == Directions::MoveTo
21
21
  end
22
-
22
+
23
23
  it 'should handle comma separated coordinates' do
24
24
  path = Parser.parse("M100,200")
25
25
  path.class.should == Path
@@ -27,7 +27,7 @@ describe Parser do
27
27
  path.subpaths.last.directions.length.should == 1
28
28
  path.subpaths.last.directions.last.class.should == Directions::MoveTo
29
29
  end
30
-
30
+
31
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
32
32
  path = Parser.parse("M100 200l-342.65 21")
33
33
  path.class.should == Path
@@ -108,7 +108,7 @@ describe Parser do
108
108
  path.subpaths.last.directions[2].class.should == Directions::ClosePath
109
109
  path.subpaths.last.closed?.should == true
110
110
  end
111
-
111
+
112
112
  it 'should return a path object with one subpath containing two line_to directions when the string is a line_to command followed by implicit coordinates' do
113
113
  path = Parser.parse("L100 200 300 400")
114
114
  path.class.should == Path
@@ -183,20 +183,20 @@ describe Parser do
183
183
  path = Parser.parse(path_string)
184
184
  path.to_command.should == path_string
185
185
  end
186
-
186
+
187
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")
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
189
  path.class.should == Path
190
190
  path.subpaths.length.should == 2
191
191
  path.subpaths[0].directions.length.should == 2
192
192
  path.subpaths[1].directions.length.should == 6
193
193
  end
194
-
195
- it "should support scienfitic notation in paths (eg. 2e-5)" do
196
- # this is a 100x100 square
197
- path = Parser.parse "M 0,0 L 1e2,0 100,1000e-1 L 0,100"
198
- points = path.directions.map{|d| [d.target.x, d.target.y] }
199
- points.should == [[0.0, 0.0], [100.0, 0.0], [100.0, 100.0], [0.0, 100.0]]
200
- end
194
+
195
+ it "should support scientific notation in paths (eg. 2e-5)" do
196
+ # this is a 100x100 square
197
+ path = Parser.parse "M 0,0 L 1e2,0 100,1000e-1 L 0,10e+1"
198
+ points = path.directions.map{|d| [d.target.x, d.target.y] }
199
+ points.should == [[0.0, 0.0], [100.0, 0.0], [100.0, 100.0], [0.0, 100.0]]
200
+ end
201
201
  end
202
202
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-02 00:00:00.000000000 Z
12
+ date: 2011-12-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70224833773340 !ruby/object:Gem::Requirement
16
+ requirement: &70355808993480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,18 +21,7 @@ dependencies:
21
21
  version: 2.3.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70224833773340
25
- - !ruby/object:Gem::Dependency
26
- name: activesupport
27
- requirement: &70224833766920 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: 2.3.5
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70224833766920
24
+ version_requirements: *70355808993480
36
25
  description: A little gem for extracting and manipulating SVG vector path data.
37
26
  email: jeremy@jeremypholland.com
38
27
  executables: []