Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
awebneck committed Dec 28, 2011
2 parents cb28e0d + 942520d commit 383d372
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.rdoc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ I have no doubt that will be some problems with this thing, as well as features


* Jeremy Holland (jeremy@jeremypholland.com, github:awebneck) -- author * Jeremy Holland (jeremy@jeremypholland.com, github:awebneck) -- author
* Christoffer Klang (toffeklang@yahoo.se, github:christoffer) -- regexp improvements * Christoffer Klang (toffeklang@yahoo.se, github:christoffer) -- regexp improvements
* MatmaRex (github:MatmaRex) -- parser improvements and scientific notation support


== Copyright == Copyright


Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
1.1.3 1.1.4
5 changes: 0 additions & 5 deletions lib/savage.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,3 @@
begin
require 'active_support/core_ext/string/inflections'
rescue LoadError, NameError
require 'activesupport'
end
SAVAGE_PATH = File.dirname(__FILE__) + "/savage/" SAVAGE_PATH = File.dirname(__FILE__) + "/savage/"
[ [
'utils', 'utils',
Expand Down
6 changes: 3 additions & 3 deletions lib/savage/parser.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def extract_subpaths(parsable)
subpaths = [] subpaths = []
if move_index = parsable.index(/[Mm]/) if move_index = parsable.index(/[Mm]/)
subpaths << parsable[0...move_index] if move_index > 0 subpaths << parsable[0...move_index] if move_index > 0
parsable.scan /[Mm](?:\d|[eE.,-]|[LlHhVvQqCcTtSsAaZz]|\W)+/m do |match_group| parsable.scan /[Mm](?:\d|[eE.,+-]|[LlHhVvQqCcTtSsAaZz]|\W)+/m do |match_group|
subpaths << $& subpaths << $&
end end
else else
Expand All @@ -35,7 +35,7 @@ def parse_subpath(parsable)


def extract_directions(parsable) def extract_directions(parsable)
directions = [] directions = []
parsable.scan /[MmLlHhVvQqCcTtSsAaZz](?:\d|[eE.,-]|\W)*/m do |match_group| parsable.scan /[MmLlHhVvQqCcTtSsAaZz](?:\d|[eE.,+-]|\W)*/m do |match_group|
direction = build_direction $& direction = build_direction $&
if direction.kind_of?(Array) if direction.kind_of?(Array)
directions.concat direction directions.concat direction
Expand Down Expand Up @@ -127,7 +127,7 @@ def build_direction(parsable)


def extract_coordinates(command_string) def extract_coordinates(command_string)
coordinates = [] coordinates = []
command_string.scan(/-?\d+(\.\d+)?([eE]-?\d+)?/) do |match_group| command_string.scan(/-?\d+(\.\d+)?([eE][+-]?\d+)?/) do |match_group|
coordinates << $&.to_f coordinates << $&.to_f
end end
coordinates coordinates
Expand Down
2 changes: 1 addition & 1 deletion lib/savage/sub_path.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SubPath
define_method(sym) do |*args| define_method(sym) do |*args|
raise TypeError if const == "QuadraticCurveTo" && @directions.last.class != Directions::QuadraticCurveTo && [2,3].include?(args.length) raise TypeError if const == "QuadraticCurveTo" && @directions.last.class != Directions::QuadraticCurveTo && [2,3].include?(args.length)
raise TypeError if const == "CubicCurveTo" && @directions.last.class != Directions::CubicCurveTo && [4,5].include?(args.length) raise TypeError if const == "CubicCurveTo" && @directions.last.class != Directions::CubicCurveTo && [4,5].include?(args.length)
(@directions << ("Savage::Directions::" << const).constantize.new(*args)).last (@directions << Savage::Directions.const_get(const).new(*args)).last
end end
end end


Expand Down
16 changes: 8 additions & 8 deletions savage.gemspec
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-


Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = %q{savage} s.name = "savage"
s.version = "1.1.2" s.version = "1.1.4"


s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jeremy Holland"] s.authors = ["Jeremy Holland"]
s.date = %q{2011-07-21} s.date = "2011-12-02"
s.description = %q{A little gem for extracting and manipulating SVG vector path data.} s.description = "A little gem for extracting and manipulating SVG vector path data."
s.email = %q{jeremy@jeremypholland.com} s.email = "jeremy@jeremypholland.com"
s.extra_rdoc_files = [ s.extra_rdoc_files = [
"LICENSE", "LICENSE",
"README.rdoc" "README.rdoc"
Expand Down Expand Up @@ -60,10 +60,10 @@ Gem::Specification.new do |s|
"spec/shared/point_target.rb", "spec/shared/point_target.rb",
"spec/spec_helper.rb" "spec/spec_helper.rb"
] ]
s.homepage = %q{http://github.com/awebneck/savage} s.homepage = "http://github.com/awebneck/savage"
s.require_paths = ["lib"] s.require_paths = ["lib"]
s.rubygems_version = %q{1.6.2} s.rubygems_version = "1.8.10"
s.summary = %q{A little library to manipulate SVG path data} s.summary = "A little library to manipulate SVG path data"


if s.respond_to? :specification_version then if s.respond_to? :specification_version then
s.specification_version = 3 s.specification_version = 3
Expand Down
2 changes: 1 addition & 1 deletion spec/savage/parser_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@


it "should support scienfitic notation in paths (eg. 2e-5)" do it "should support scienfitic notation in paths (eg. 2e-5)" do
# this is a 100x100 square # this is a 100x100 square
path = Parser.parse "M 0,0 L 1e2,0 100,1000e-1 L 0,100" path = Parser.parse "M 0,0 L 1e2,0 100,1000e-1 L 0,10e+1"
points = path.directions.map{|d| [d.target.x, d.target.y] } points = path.directions.map{|d| [d.target.x, d.target.y] }
points.should == [[0.0, 0.0], [100.0, 0.0], [100.0, 100.0], [0.0, 100.0]] points.should == [[0.0, 0.0], [100.0, 0.0], [100.0, 100.0], [0.0, 100.0]]
end end
Expand Down

0 comments on commit 383d372

Please sign in to comment.