savage 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  A little gem for extracting and manipulating SVG vector path data, Savage will make your life easier when it comes time to dynamically draw new and manipulate existing SVG paths. No more wacky regex to capture those cryptic path data strings; just pass the whole "d" attribute into Savage's parser, et voilá: You'll be given an instance of Savage::Path, replete with an array of subpaths split on the "move to" commands (to better help with those pesky winding issues). In turn, each subpath contains its own array of directions that can be swapped around, reconfigured, and otherwise manipulated to your heart's content in a truly human-readable way.
4
4
 
5
+ == Latest Update
6
+
7
+ Version 1.1.0 adds support for Rails 3 and Ruby 1.9.2. Enjoy!
8
+
5
9
  == Usage
6
10
 
7
11
  <b>Parsing existing data</b>
@@ -11,7 +15,7 @@ Easy-peasy Japanesey. Just take a look at the below:
11
15
  path = Savage::Parser.parse my_path_data_string
12
16
  path.subpaths # [subpath_1, subpath_2, ... subpath_n]
13
17
  path.subpaths.last.directions # [direction_1, direction_2, ... direction_n]
14
-
18
+
15
19
  Once extracted, you can manipulate, add, and remove the subpaths and directions as you see fit. See below for instructions on using the various direction types
16
20
 
17
21
  <b>Creating from scratch</b>
@@ -24,7 +28,7 @@ What if you want to roll your own from the get-go? No problem:
24
28
  p.horizontal_to 500
25
29
  p.close_path
26
30
  end
27
-
31
+
28
32
  We'll learn more about the actual drawing methods here shortly, but suffice it to say they are provided both as methods on the constructor block parameter for the sake of your visual organization, and the path itself after instantiation, as below:
29
33
 
30
34
  path = Savage::Path.new
@@ -32,7 +36,7 @@ We'll learn more about the actual drawing methods here shortly, but suffice it t
32
36
  path.line_to 300, 400
33
37
  path.horizontal_to 500
34
38
  path.close_path
35
-
39
+
36
40
  <b>Drawing with Savage</b>
37
41
 
38
42
  So what are the different directions we can give our virtual pen? Here I'll refer you first to the SVG 1.1 specification by our friends down at the W3C, as they can describe all the specifics much better than I: http://www.w3.org/TR/SVG/paths.html#PathData. Each "command" listed in that section has an analog method on the Savage::SubPath class as well as the Savage::Path class (calling one of the methods on an instance of the Savage::Path class actually just delegates the call to the last SubPath in that path's selection of subpaths). Every parameter of these methods is expected to be a Numeric except where noted otherwise. The methods are as follows:
@@ -51,14 +55,14 @@ So what are the different directions we can give our virtual pen? Here I'll refe
51
55
  There you have it, pretty much right out of the book. One thing to keep in mind is that all of these methods use ABSOLUTE coordinates by default; if you want to use relative coordinates (based on the current position of the 'pen'), just pass false as the final argument to any of them:
52
56
 
53
57
  path.line_to 100, 200, false
54
-
58
+
55
59
  Each of these commands just creates a new instance of the appropriate subclass of the Savage::Direction class and pushes it onto the end of the directions list in question. Don't necessarily want to draw onto the end? Just create your own instance using the standard constructor and insert it wherever it butters your biscuit so to do:
56
60
 
57
61
  direction = Savage::Directions::LineTo.new(100,200)
58
62
  subpath.directions.insert(3,direction)
59
63
 
60
64
  Did you mess up before and need to change a directions coordinates after you drew it (or, more likely, after you parsed it out of some pre-existing data)? No problem:
61
-
65
+
62
66
  direction = Savage::Directions::LineTo.new(100,200)
63
67
  direction.target.x = 234
64
68
 
@@ -77,13 +81,18 @@ Note that the #to_command method exists on Savage::Path, Savage::SubPath, and ea
77
81
  I have no doubt that will be some problems with this thing, as well as features missing that some of you fine folks might want. Please, please, please check Github's issue-tracking system to see if a ticket for the problem has already been submitted, or create a new one if not. I'll check the issues listed therein regularly, but you email me directly at your own risk (and by risk, I mean risk of not receiving a reply). :)
78
82
 
79
83
  == Note on Patches/Pull Requests
80
-
84
+
81
85
  * Fork the project.
82
86
  * Make your feature addition or bug fix. I very much prefer feature-specific branches.
83
87
  * Add specs for it. This is important so I don't break it in a future version unintentionally, which I can guarantee I will do.
84
88
  * Commit. Do not mess with rakefile, version, or history, please.
85
89
  * Send me a pull request - again, bonus points for topic branches.
86
90
 
91
+ == Contributors
92
+
93
+ * Jeremy Holland (jeremy@jeremypholland.com, github:awebneck) -- author
94
+ * Christoffer Klang (toffeklang@yahoo.se, github:christoffer) -- regexp improvements
95
+
87
96
  == Copyright
88
97
 
89
98
  Copyright (c) 2010 Jeremy Holland. See LICENSE for details.
data/Rakefile CHANGED
@@ -8,9 +8,9 @@ begin
8
8
  gem.summary = %Q{A little library to manipulate SVG path data}
9
9
  gem.description = %Q{A little gem for extracting and manipulating SVG vector path data.}
10
10
  gem.email = "jeremy@jeremypholland.com"
11
- gem.homepage = "http://github.com/therubyneck/savage"
11
+ gem.homepage = "http://github.com/awebneck/savage"
12
12
  gem.authors = ["Jeremy Holland"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
13
+ gem.add_development_dependency "rspec", ">= 2.3.0"
14
14
  gem.add_dependency "activesupport", ">= 2.3.5"
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
16
  end
@@ -19,15 +19,9 @@ rescue LoadError
19
19
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
20
  end
21
21
 
22
- require 'spec/rake/spectask'
23
- Spec::Rake::SpecTask.new(:spec) do |spec|
24
- spec.libs << 'lib' << 'spec'
25
- spec.spec_files = FileList['spec/**/*_spec.rb']
26
- end
27
-
28
- Spec::Rake::SpecTask.new(:rcov) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.pattern = 'spec/**/*_spec.rb'
22
+ require 'rspec/core/rake_task'
23
+ RSpec::Core::RakeTask.new(:spec)
24
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
31
25
  spec.rcov = true
32
26
  end
33
27
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
data/savage.gemspec CHANGED
@@ -1,90 +1,88 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{savage}
8
- s.version = "1.1.0"
8
+ s.version = "1.1.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-10-07}
12
+ s.date = %q{2010-12-30}
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 = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/savage.rb",
27
- "lib/savage/direction.rb",
28
- "lib/savage/direction_proxy.rb",
29
- "lib/savage/directions/arc_to.rb",
30
- "lib/savage/directions/close_path.rb",
31
- "lib/savage/directions/coordinate_target.rb",
32
- "lib/savage/directions/cubic_curve_to.rb",
33
- "lib/savage/directions/horizontal_to.rb",
34
- "lib/savage/directions/line_to.rb",
35
- "lib/savage/directions/move_to.rb",
36
- "lib/savage/directions/point_target.rb",
37
- "lib/savage/directions/quadratic_curve_to.rb",
38
- "lib/savage/directions/vertical_to.rb",
39
- "lib/savage/parser.rb",
40
- "lib/savage/path.rb",
41
- "lib/savage/sub_path.rb",
42
- "lib/savage/utils.rb",
43
- "savage.gemspec",
44
- "spec/savage/directions/arc_to_spec.rb",
45
- "spec/savage/directions/close_path_spec.rb",
46
- "spec/savage/directions/cubic_curve_to_spec.rb",
47
- "spec/savage/directions/horizontal_to_spec.rb",
48
- "spec/savage/directions/line_to_spec.rb",
49
- "spec/savage/directions/move_to_spec.rb",
50
- "spec/savage/directions/point_spec.rb",
51
- "spec/savage/directions/quadratic_curve_spec.rb",
52
- "spec/savage/directions/vertical_to_spec.rb",
53
- "spec/savage/parser_spec.rb",
54
- "spec/savage/path_spec.rb",
55
- "spec/savage/sub_path_spec.rb",
56
- "spec/savage_spec.rb",
57
- "spec/shared/command.rb",
58
- "spec/shared/coordinate_target.rb",
59
- "spec/shared/direction.rb",
60
- "spec/shared/point_target.rb",
61
- "spec/spec.opts",
62
- "spec/spec_helper.rb"
21
+ ".rspec",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/savage.rb",
27
+ "lib/savage/direction.rb",
28
+ "lib/savage/direction_proxy.rb",
29
+ "lib/savage/directions/arc_to.rb",
30
+ "lib/savage/directions/close_path.rb",
31
+ "lib/savage/directions/coordinate_target.rb",
32
+ "lib/savage/directions/cubic_curve_to.rb",
33
+ "lib/savage/directions/horizontal_to.rb",
34
+ "lib/savage/directions/line_to.rb",
35
+ "lib/savage/directions/move_to.rb",
36
+ "lib/savage/directions/point_target.rb",
37
+ "lib/savage/directions/quadratic_curve_to.rb",
38
+ "lib/savage/directions/vertical_to.rb",
39
+ "lib/savage/parser.rb",
40
+ "lib/savage/path.rb",
41
+ "lib/savage/sub_path.rb",
42
+ "lib/savage/utils.rb",
43
+ "savage.gemspec",
44
+ "spec/savage/directions/arc_to_spec.rb",
45
+ "spec/savage/directions/close_path_spec.rb",
46
+ "spec/savage/directions/cubic_curve_to_spec.rb",
47
+ "spec/savage/directions/horizontal_to_spec.rb",
48
+ "spec/savage/directions/line_to_spec.rb",
49
+ "spec/savage/directions/move_to_spec.rb",
50
+ "spec/savage/directions/point_spec.rb",
51
+ "spec/savage/directions/quadratic_curve_spec.rb",
52
+ "spec/savage/directions/vertical_to_spec.rb",
53
+ "spec/savage/parser_spec.rb",
54
+ "spec/savage/path_spec.rb",
55
+ "spec/savage/sub_path_spec.rb",
56
+ "spec/savage_spec.rb",
57
+ "spec/shared/command.rb",
58
+ "spec/shared/coordinate_target.rb",
59
+ "spec/shared/direction.rb",
60
+ "spec/shared/point_target.rb",
61
+ "spec/spec_helper.rb"
63
62
  ]
64
- s.homepage = %q{http://github.com/therubyneck/savage}
65
- s.rdoc_options = ["--charset=UTF-8"]
63
+ s.homepage = %q{http://github.com/awebneck/savage}
66
64
  s.require_paths = ["lib"]
67
65
  s.rubygems_version = %q{1.3.7}
68
66
  s.summary = %q{A little library to manipulate SVG path data}
69
67
  s.test_files = [
70
68
  "spec/savage/directions/arc_to_spec.rb",
71
- "spec/savage/directions/close_path_spec.rb",
72
- "spec/savage/directions/cubic_curve_to_spec.rb",
73
- "spec/savage/directions/horizontal_to_spec.rb",
74
- "spec/savage/directions/line_to_spec.rb",
75
- "spec/savage/directions/move_to_spec.rb",
76
- "spec/savage/directions/point_spec.rb",
77
- "spec/savage/directions/quadratic_curve_spec.rb",
78
- "spec/savage/directions/vertical_to_spec.rb",
79
- "spec/savage/parser_spec.rb",
80
- "spec/savage/path_spec.rb",
81
- "spec/savage/sub_path_spec.rb",
82
- "spec/savage_spec.rb",
83
- "spec/shared/command.rb",
84
- "spec/shared/coordinate_target.rb",
85
- "spec/shared/direction.rb",
86
- "spec/shared/point_target.rb",
87
- "spec/spec_helper.rb"
69
+ "spec/savage/directions/close_path_spec.rb",
70
+ "spec/savage/directions/cubic_curve_to_spec.rb",
71
+ "spec/savage/directions/horizontal_to_spec.rb",
72
+ "spec/savage/directions/line_to_spec.rb",
73
+ "spec/savage/directions/move_to_spec.rb",
74
+ "spec/savage/directions/point_spec.rb",
75
+ "spec/savage/directions/quadratic_curve_spec.rb",
76
+ "spec/savage/directions/vertical_to_spec.rb",
77
+ "spec/savage/parser_spec.rb",
78
+ "spec/savage/path_spec.rb",
79
+ "spec/savage/sub_path_spec.rb",
80
+ "spec/savage_spec.rb",
81
+ "spec/shared/command.rb",
82
+ "spec/shared/coordinate_target.rb",
83
+ "spec/shared/direction.rb",
84
+ "spec/shared/point_target.rb",
85
+ "spec/spec_helper.rb"
88
86
  ]
89
87
 
90
88
  if s.respond_to? :specification_version then
@@ -92,14 +90,14 @@ Gem::Specification.new do |s|
92
90
  s.specification_version = 3
93
91
 
94
92
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
95
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
93
+ s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
96
94
  s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
97
95
  else
98
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
96
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
99
97
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
100
98
  end
101
99
  else
102
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
100
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
103
101
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
104
102
  end
105
103
  end
@@ -6,13 +6,14 @@ describe ArcTo do
6
6
  def dir_class; ArcTo; end
7
7
  def create_relative; ArcTo.new(100,200,300,true,false,400,500,false); end
8
8
  def command_code; 'a'; end
9
-
9
+
10
10
  before :each do
11
11
  @dir = dir_class.new(100,200,300,true,false,400,500)
12
12
  end
13
-
13
+
14
+ include Command
14
15
  include DirectionShared
15
-
16
+
16
17
  it 'should have a target' do
17
18
  @dir.respond_to?(:target).should == true
18
19
  @dir.target.class.should == Point
@@ -93,4 +94,4 @@ describe ArcTo do
93
94
  extract_coordinates(@dir.to_command)[6].should == 500
94
95
  end
95
96
  end
96
- end
97
+ end
@@ -8,6 +8,7 @@ describe ClosePath do
8
8
  end
9
9
  def create_relative; ClosePath.new(false); end
10
10
  def command_code; 'z'; end
11
+ include Command
11
12
  include DirectionShared
12
13
  it 'should be constructed with with either no parameters or a single boolean parameter' do
13
14
  lambda { ClosePath.new }.should_not raise_error
@@ -6,13 +6,14 @@ describe CubicCurveTo do
6
6
  def dir_class; CubicCurveTo; end
7
7
  def create_relative; CubicCurveTo.new(100,200,300,400,500,600,false); end
8
8
  def command_code; 'c'; end
9
-
9
+
10
10
  before :each do
11
11
  @dir = dir_class.new(100,200,300,400,500,600)
12
12
  end
13
-
13
+
14
+ include Command
14
15
  include DirectionShared
15
-
16
+
16
17
  it 'should have a target' do
17
18
  @dir.respond_to?(:target).should == true
18
19
  @dir.target.class.should == Point
@@ -142,4 +143,4 @@ describe CubicCurveTo do
142
143
  end
143
144
  end
144
145
  end
145
- end
146
+ end
@@ -6,13 +6,14 @@ describe QuadraticCurveTo do
6
6
  def dir_class; QuadraticCurveTo; end
7
7
  def create_relative; QuadraticCurveTo.new(100,200,300,400,false); end
8
8
  def command_code; 'q'; end
9
-
9
+
10
10
  before :each do
11
11
  @dir = dir_class.new(100,200,300,400)
12
12
  end
13
-
13
+
14
+ include Command
14
15
  include DirectionShared
15
-
16
+
16
17
  it 'should have a target' do
17
18
  @dir.respond_to?(:target).should == true
18
19
  @dir.target.class.should == Point
@@ -119,4 +120,4 @@ describe QuadraticCurveTo do
119
120
  end
120
121
  end
121
122
  end
122
- end
123
+ end
@@ -2,6 +2,7 @@ share_as :CoordinateTargetShared do
2
2
  before :each do
3
3
  @dir = dir_class.new(100)
4
4
  end
5
+ include Command
5
6
  include DirectionShared
6
7
  it 'should have an accessible target, based on the constructor argument' do
7
8
  @dir.respond_to?(:target).should == true
@@ -32,4 +33,4 @@ share_as :CoordinateTargetShared do
32
33
  extract_coordinates(@dir.to_command)[0].should == 100
33
34
  end
34
35
  end
35
- end
36
+ end
@@ -2,6 +2,7 @@ share_as :PointTargetShared do
2
2
  before :each do
3
3
  @dir = dir_class.new(100,200)
4
4
  end
5
+ include Command
5
6
  include DirectionShared
6
7
  it 'should have a target' do
7
8
  @dir.respond_to?(:target).should == true
@@ -41,4 +42,4 @@ share_as :PointTargetShared do
41
42
  extract_coordinates(@dir.to_command)[1].should == 200
42
43
  end
43
44
  end
44
- end
45
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,31 +2,31 @@ require 'rubygems'
2
2
  require 'spork'
3
3
 
4
4
  Spork.prefork do
5
- # Loading more in this block will cause your tests to run faster. However,
5
+ # Loading more in this block will cause your tests to run faster. However,
6
6
  # if you change any configuration or code from libraries loaded here, you'll
7
7
  # need to restart spork for it take effect.
8
8
  $LOAD_PATH.unshift(File.dirname(__FILE__))
9
9
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
10
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'shared'))
11
-
11
+
12
12
  require 'savage'
13
- require 'spec'
14
- require 'spec/autorun'
15
- Spec::Runner.configure do |config|
13
+ require 'rspec'
14
+ require 'rspec/autorun'
15
+ RSpec.configure do |config|
16
16
 
17
17
  end
18
-
18
+
19
19
  Dir[File.join(File.dirname(__FILE__) << '/shared', "*.rb")].each {|file| require File.basename(file) }
20
20
  end
21
21
 
22
22
  Spork.each_run do
23
23
  # This code will be run each time you run your specs.
24
-
24
+
25
25
  end
26
26
 
27
27
  # --- Instructions ---
28
- # - Sort through your spec_helper file. Place as much environment loading
29
- # code that you don't normally modify during development in the
28
+ # - Sort through your spec_helper file. Place as much environment loading
29
+ # code that you don't normally modify during development in the
30
30
  # Spork.prefork block.
31
31
  # - Place the rest under Spork.each_run block
32
32
  # - Any code that is left outside of the blocks will be ran during preforking
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 0
9
- version: 1.1.0
8
+ - 1
9
+ version: 1.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeremy Holland
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-07 00:00:00 -05:00
17
+ date: 2010-12-30 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -26,10 +26,10 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
- - 1
30
29
  - 2
31
- - 9
32
- version: 1.2.9
30
+ - 3
31
+ - 0
32
+ version: 2.3.0
33
33
  type: :development
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
@@ -58,7 +58,7 @@ extra_rdoc_files:
58
58
  - README.rdoc
59
59
  files:
60
60
  - .document
61
- - .gitignore
61
+ - .rspec
62
62
  - LICENSE
63
63
  - README.rdoc
64
64
  - Rakefile
@@ -98,15 +98,14 @@ files:
98
98
  - spec/shared/coordinate_target.rb
99
99
  - spec/shared/direction.rb
100
100
  - spec/shared/point_target.rb
101
- - spec/spec.opts
102
101
  - spec/spec_helper.rb
103
102
  has_rdoc: true
104
- homepage: http://github.com/therubyneck/savage
103
+ homepage: http://github.com/awebneck/savage
105
104
  licenses: []
106
105
 
107
106
  post_install_message:
108
- rdoc_options:
109
- - --charset=UTF-8
107
+ rdoc_options: []
108
+
110
109
  require_paths:
111
110
  - lib
112
111
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
File without changes