hieroglyph 0.1.1 → 0.1.2

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.
@@ -1,5 +1,119 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Hieroglyph::Glyph do
4
-
5
- end
4
+ context 'A Glyph' do
5
+
6
+ before :each do
7
+ module Hieroglyph
8
+ def self.log(*)
9
+ end
10
+ def self.header(*)
11
+ end
12
+ end
13
+ system('rm -rf /tmp/glyphs/')
14
+ system('mkdir /tmp/glyphs/')
15
+ path_to_test = File.expand_path('../../../support/test.svg', __FILE__)
16
+ system("cp #{path_to_test} /tmp/glyphs/a-test.svg")
17
+ path_to_test = File.expand_path('../../../support/test-polygon.svg', __FILE__)
18
+ system("cp #{path_to_test} /tmp/glyphs/b-polygon.svg")
19
+
20
+ @font = Hieroglyph::Font.new({:output_folder => '/tmp', :name => 'font', :glyph_folder => '/tmp/glyphs'})
21
+ @glyph = Hieroglyph::Glyph.new('/tmp/glyphs/a-test.svg', '/tmp/glyphs', @font)
22
+
23
+ end
24
+
25
+ after :each do
26
+ system('rm /tmp/glyphs/a-test.svg')
27
+ end
28
+ it 'sets a name when given simple letters' do
29
+ @glyph.set_name('/tmp/glyphs/a-file.svg', '/tmp/glyphs/')
30
+ @glyph.name.should eql 'a'
31
+ end
32
+
33
+ it 'sets a name when given a special characters' do
34
+ @glyph.set_name('/tmp/glyphs/{-file.svg', '/tmp/glyphs/')
35
+ @glyph.name.should eql '{'
36
+ end
37
+
38
+ it 'sets a name when given a question mark' do
39
+ @glyph.set_name('/tmp/glyphs/?-file.svg', '/tmp/glyphs/')
40
+ @glyph.name.should eql '?'
41
+ end
42
+
43
+ it 'sets a name when given a dash' do
44
+ @glyph.set_name('/tmp/glyphs/--file.svg', '/tmp/glyphs/')
45
+ @glyph.name.should eql '-'
46
+ end
47
+
48
+ it 'sets a name when given unicode' do
49
+ @glyph.set_name('/tmp/glyphs/-file.svg', '/tmp/glyphs/')
50
+ @glyph.name.should eql ''
51
+ end
52
+
53
+ it 'adds single characters to the character array' do
54
+ @font.characters = []
55
+ @glyph.set_name('/tmp/glyphs/a-file.svg', '/tmp/glyphs/')
56
+ @font.characters.should eql ['a']
57
+ end
58
+
59
+ it 'adds unicode names to the unicode array' do
60
+ @font.unicode_values = []
61
+ @glyph.set_name('/tmp/glyphs/-file.svg', '/tmp/glyphs/')
62
+ @font.unicode_values.should eql ['F8FF']
63
+ end
64
+
65
+ it 'calls appropriate method when given a shape' do
66
+ @glyph.should_receive(:convert_polygon)
67
+ @glyph.contents = Nokogiri::XML('<?xml version="1.0" encoding="utf-8"?><svg><polygon /></svg>')
68
+ @glyph.parse_shapes
69
+ end
70
+
71
+ it 'reports too many if given multiple shapes' do
72
+ @glyph.should_receive(:report_too_many)
73
+ @glyph.contents = Nokogiri::XML('<?xml version="1.0" encoding="utf-8"?><svg><polygon points="2,2" /><path /></svg>')
74
+ @glyph.parse_shapes
75
+ end
76
+
77
+ it 'converts polygons to paths' do
78
+ path_to_test = File.expand_path('../../../support/test-polygon.svg', __FILE__)
79
+ content = Nokogiri::XML(File.new(path_to_test)).at_css('polygon')
80
+ path = 'M745.365 600.357 499.029 354.03499999999997 252.729 600.357 131.5 479.03 377.77 232.78200000000004 377.759 232.77099999999996 500.882 109.64300000000003 868.5 477.229Z'
81
+ @glyph.convert_polygon('', content).to_command.should eql path
82
+ end
83
+
84
+ it 'gets paths from path strings' do
85
+ Savage::Parser.should_receive(:parse)
86
+ path_to_test = File.expand_path('../../../support/test.svg', __FILE__)
87
+ content = Nokogiri::XML(File.new(path_to_test)).at_css('path')
88
+ @glyph.stub!(:flip)
89
+ @glyph.convert_path('', content)
90
+ end
91
+
92
+ it 'flips paths' do
93
+ normal_path = File.open(File.expand_path('../../../support/normal_path', __FILE__)).read
94
+ flipped_path = File.open(File.expand_path('../../../support/flipped_path', __FILE__)).read
95
+ path = Savage::Parser.parse normal_path
96
+ new_path = @glyph.flip(path).to_command + "\n"
97
+ new_path.should eql flipped_path
98
+ end
99
+
100
+ it 'flips y values around the 500 axis, subtracts 25' do
101
+ @glyph.flip_y(750).should eql 225.0
102
+ end
103
+
104
+ it 'flips y values around the 500 axis, subtracts 25' do
105
+ @glyph.flip_y(999).should eql -24.0
106
+ end
107
+
108
+ it 'flips y values around the 500 axis, subtracts 25' do
109
+ @glyph.flip_y(500).should eql 475.0
110
+ end
111
+
112
+ it 'converts paths to XML nodes' do
113
+ @glyph.path = Savage::Path.new
114
+ @glyph.path.stub!(:to_command).and_return('foo')
115
+ @glyph.to_node.should eql "<glyph unicode=\"a\" d=\"foo\" />\n"
116
+ end
117
+
118
+ end
119
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hieroglyph::NoopSheet do
4
+ context 'A NoopSheet' do
5
+
6
+ before :each do
7
+ module Hieroglyph
8
+ def log(*)
9
+ end
10
+ def self.header(*)
11
+ end
12
+ end
13
+ @character_sheet = Hieroglyph::NoopSheet.new({:output_folder => '/tmp', :name => 'sheet'})
14
+ end
15
+
16
+ it 'should execute add' do
17
+ @character_sheet.add('whatever')
18
+ end
19
+
20
+ it 'should not save files' do
21
+ @character_sheet.save
22
+ File.exists?('/tmp/sheet_characters.png').should be_false
23
+ end
24
+
25
+ end
26
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,23 +1,11 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
1
  require 'bundler'
8
2
  Bundler.setup(:test)
9
3
 
10
4
  require 'rspec'
11
- require 'mocha'
12
- require 'bourne'
5
+ # require 'mocha'
6
+ # require 'bourne'
13
7
 
8
+ require File.expand_path('../../lib/hieroglyph.rb', __FILE__)
14
9
  require File.expand_path('../../lib/hieroglyph', __FILE__)
15
10
 
16
11
  Dir["./spec/support/**/*.rb"].each {|f| require f}
17
-
18
- RSpec.configure do |config|
19
- # config.treat_symbols_as_metadata_keys_with_true_values = true
20
- # config.run_all_when_everything_filtered = true
21
- # config.filter_run :focus
22
- config.mock_with :mocha
23
- end
@@ -0,0 +1 @@
1
+ M866.341 533.889c-7.23-8.624-14.862-11.476-21.095-13.302-6.368-1.69-12.206-2.153-18.276-2.153l-210.252-0.133c-1.957 0.133-6.468-1.195-10.215-4.112-3.849-2.855-6.27-6.801-6.7-8.691l-60.897-218.911c-2.023-6.899-4.248-13.134-8.825-19.902-4.177-6.102-13.366-16.285-30.083-16.684-16.617 0.332-25.904 10.514-30.084 16.684-4.578 6.833-6.833 13.069-8.755 19.967L400.261 505.43000000000006c-0.4 1.925-2.92 5.903-6.734 8.69-3.715 2.92-8.226 4.245-10.183 4.178l-210.288 0.066c-8.093 0.131-15.658 0.662-24.812 4.544-4.511 2.023-9.816 5.141-14.493 10.914-4.744 5.571-7.994 14.264-7.862 22.057 0.266 12.472 5.505 20.066 9.817 25.341 4.578 5.339 9.352 9.122 14.728 12.669l169.456 111.676c3.021 1.293 8.328 10.682 7.863 16.983 0.0 1.558-0.199 2.819-0.464 3.783l-65.872 215.858c-1.823 6.235-3.216 12.272-3.284 19.636 0.099 6.168 0.828 14.192 7.063 23.217 6.038 9.285 19.438 15.089 28.593 14.526 17.313-0.928 24.544-7.761 33.1-14.264l165.678-141.063c1.359-1.26 4.809-2.722 8.688-2.722 3.75 0.0 7.031 1.328 8.392 2.522l174.631 142.226c8.657 6.269 15.755 12.771 32.671 13.698 0.399 0.0 0.829 0.034 1.227 0.034 8.724 0.0 20.93-5.276 26.902-14.099 6.368-8.956 7.164-17.112 7.229-23.151-0.064-7.927-1.626-14.263-3.847-20.995L674.43 724.534c-0.331-0.929-0.566-2.254-0.566-3.914-0.431-5.837 4.38-14.195 7.133-15.39l168.595-111.277c5.373-3.55 10.184-7.364 14.761-12.703 4.245-5.309 9.519-12.868 9.752-25.338C874.302 548.149 871.051 539.46 866.341 533.889z
@@ -0,0 +1 @@
1
+ M866.341 441.111c-7.23 8.624-14.862 11.476-21.095 13.302-6.368 1.69-12.206 2.153-18.276 2.153l-210.252 0.133c-1.957-0.133-6.468 1.195-10.215 4.112-3.849 2.855-6.27 6.801-6.7 8.691l-60.897 218.911c-2.023 6.899-4.248 13.134-8.825 19.902-4.177 6.102-13.366 16.285-30.083 16.684-16.617-0.332-25.904-10.514-30.084-16.684-4.578-6.833-6.833-13.069-8.755-19.967L400.261 469.57c-0.4-1.925-2.92-5.903-6.734-8.69-3.715-2.92-8.226-4.245-10.183-4.178l-210.288-0.066c-8.093-0.131-15.658-0.662-24.812-4.544-4.511-2.023-9.816-5.141-14.493-10.914-4.744-5.571-7.994-14.264-7.862-22.057 0.266-12.472 5.505-20.066 9.817-25.341 4.578-5.339 9.352-9.122 14.728-12.669l169.456-111.676c3.021-1.293 8.328-10.682 7.863-16.983 0.0-1.558-0.199-2.819-0.464-3.783l-65.872-215.858c-1.823-6.235-3.216-12.272-3.284-19.636 0.099-6.168 0.828-14.192 7.063-23.217 6.038-9.285 19.438-15.089 28.593-14.526 17.313 0.928 24.544 7.761 33.1 14.264l165.678 141.063c1.359 1.26 4.809 2.722 8.688 2.722 3.75-0.0 7.031-1.328 8.392-2.522l174.631-142.226c8.657-6.269 15.755-12.771 32.671-13.698 0.399-0.0 0.829-0.034 1.227-0.034 8.724-0.0 20.93 5.276 26.902 14.099 6.368 8.956 7.164 17.112 7.229 23.151-0.064 7.927-1.626 14.263-3.847 20.995L674.43 250.466c-0.331 0.929-0.566 2.254-0.566 3.914-0.431 5.837 4.38 14.195 7.133 15.39l168.595 111.277c5.373 3.55 10.184 7.364 14.761 12.703 4.245 5.309 9.519 12.868 9.752 25.338C874.302 426.851 871.051 435.53999999999996 866.341 441.111z
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="1000px" height="1000px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
6
+ <polygon fill="#151514" points="745.365,374.643 499.029,620.965 252.729,374.643 131.5,495.97 377.77,742.218 377.759,742.229
7
+ 500.882,865.357 868.5,497.771 "/>
8
+ </svg>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="1000px" height="1000px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
6
+ <path fill="#050606" d="M866.341,533.889c-7.23-8.624-14.862-11.476-21.095-13.302c-6.368-1.69-12.206-2.153-18.276-2.153
7
+ l-210.252-0.133c-1.957,0.133-6.468-1.195-10.215-4.112c-3.849-2.855-6.27-6.801-6.7-8.691l-60.897-218.911
8
+ c-2.023-6.899-4.248-13.134-8.825-19.902c-4.177-6.102-13.366-16.285-30.083-16.684c-16.617,0.332-25.904,10.514-30.084,16.684
9
+ c-4.578,6.833-6.833,13.069-8.755,19.967L400.261,505.43c-0.4,1.925-2.92,5.903-6.734,8.69c-3.715,2.92-8.226,4.245-10.183,4.178
10
+ l-210.288,0.066c-8.093,0.131-15.658,0.662-24.812,4.544c-4.511,2.023-9.816,5.141-14.493,10.914
11
+ c-4.744,5.571-7.994,14.264-7.862,22.057c0.266,12.472,5.505,20.066,9.817,25.341c4.578,5.339,9.352,9.122,14.728,12.669
12
+ l169.456,111.676c3.021,1.293,8.328,10.682,7.863,16.983c0,1.558-0.199,2.819-0.464,3.783l-65.872,215.858
13
+ c-1.823,6.235-3.216,12.272-3.284,19.636c0.099,6.168,0.828,14.192,7.063,23.217c6.038,9.285,19.438,15.089,28.593,14.526
14
+ c17.313-0.928,24.544-7.761,33.1-14.264l165.678-141.063c1.359-1.26,4.809-2.722,8.688-2.722c3.75,0,7.031,1.328,8.392,2.522
15
+ l174.631,142.226c8.657,6.269,15.755,12.771,32.671,13.698c0.399,0,0.829,0.034,1.227,0.034c8.724,0,20.93-5.276,26.902-14.099
16
+ c6.368-8.956,7.164-17.112,7.229-23.151c-0.064-7.927-1.626-14.263-3.847-20.995L674.43,724.534
17
+ c-0.331-0.929-0.566-2.254-0.566-3.914c-0.431-5.837,4.38-14.195,7.133-15.39l168.595-111.277
18
+ c5.373-3.55,10.184-7.364,14.761-12.703c4.245-5.309,9.519-12.868,9.752-25.338C874.302,548.149,871.051,539.46,866.341,533.889z"/>
19
+ </svg>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hieroglyph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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: 2012-03-24 00:00:00.000000000Z
12
+ date: 2012-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70178521601540 !ruby/object:Gem::Requirement
16
+ requirement: &70243481833860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70178521601540
24
+ version_requirements: *70243481833860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: savage
27
- requirement: &70178521601040 !ruby/object:Gem::Requirement
27
+ requirement: &70243481833320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,51 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70178521601040
36
- - !ruby/object:Gem::Dependency
37
- name: rspec
38
- requirement: &70178521600660 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70178521600660
47
- - !ruby/object:Gem::Dependency
48
- name: mocha
49
- requirement: &70178521600200 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *70178521600200
58
- - !ruby/object:Gem::Dependency
59
- name: bourne
60
- requirement: &70178521599780 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: '0'
66
- type: :development
67
- prerelease: false
68
- version_requirements: *70178521599780
69
- - !ruby/object:Gem::Dependency
70
- name: rmagick
71
- requirement: &70178521599360 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *70178521599360
35
+ version_requirements: *70243481833320
80
36
  description: Generate a web-ready SVG font from a directory of SVG icons
81
37
  email:
82
38
  - dougunderscorenelson@gmail.com
@@ -85,6 +41,7 @@ executables:
85
41
  extensions: []
86
42
  extra_rdoc_files: []
87
43
  files:
44
+ - -rf
88
45
  - .gitignore
89
46
  - .rspec
90
47
  - Gemfile
@@ -94,21 +51,32 @@ files:
94
51
  - bin/hieroglyph
95
52
  - hieroglyph.gemspec
96
53
  - lib/hieroglyph.rb
54
+ - lib/hieroglyph/assets/fontsquirrel-subsetting.jpg
97
55
  - lib/hieroglyph/assets/footer
56
+ - lib/hieroglyph/assets/glyphs/&#xf8ff;-private_unicode.svg
98
57
  - lib/hieroglyph/assets/glyphs/C-checkcircle.svg
99
58
  - lib/hieroglyph/assets/glyphs/a-star.svg
100
59
  - lib/hieroglyph/assets/glyphs/c-check.svg
101
60
  - lib/hieroglyph/assets/glyphs/d-downcaret.svg
61
+ - lib/hieroglyph/assets/glyphs/e-invalid_shapes-BAD.svg
62
+ - lib/hieroglyph/assets/glyphs/f-too_many_shapes-BAD.svg
102
63
  - lib/hieroglyph/assets/header
103
64
  - lib/hieroglyph/character_sheet.rb
104
65
  - lib/hieroglyph/command_line.rb
105
66
  - lib/hieroglyph/font.rb
106
67
  - lib/hieroglyph/glyph.rb
68
+ - lib/hieroglyph/noop_sheet.rb
107
69
  - lib/hieroglyph/version.rb
70
+ - rm
108
71
  - spec/lib/hieroglyph/character_sheet_spec.rb
109
72
  - spec/lib/hieroglyph/font_spec.rb
110
73
  - spec/lib/hieroglyph/glyph_spec.rb
74
+ - spec/lib/hieroglyph/noop_sheet_spec.rb
111
75
  - spec/spec_helper.rb
76
+ - spec/support/flipped_path
77
+ - spec/support/normal_path
78
+ - spec/support/test-polygon.svg
79
+ - spec/support/test.svg
112
80
  homepage: http://github.com/averyvery/hieroglyph
113
81
  licenses: []
114
82
  post_install_message:
@@ -137,4 +105,9 @@ test_files:
137
105
  - spec/lib/hieroglyph/character_sheet_spec.rb
138
106
  - spec/lib/hieroglyph/font_spec.rb
139
107
  - spec/lib/hieroglyph/glyph_spec.rb
108
+ - spec/lib/hieroglyph/noop_sheet_spec.rb
140
109
  - spec/spec_helper.rb
110
+ - spec/support/flipped_path
111
+ - spec/support/normal_path
112
+ - spec/support/test-polygon.svg
113
+ - spec/support/test.svg