noft 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ require File.expand_path('../../../../helper', __FILE__)
2
+
3
+ class TestAssetsTemplate < Noft::TestCase
4
+ def test_generate_assets
5
+ icon_set = load_sample1_icon_set
6
+ output_directory = run_generators([:svg_assets], icon_set)
7
+
8
+ assert_sample1_dist_output("#{output_directory}/assets/sample1")
9
+ end
10
+ end
@@ -0,0 +1,47 @@
1
+ require File.expand_path('../../helper', __FILE__)
2
+
3
+ class TestGenerator < Noft::TestCase
4
+ def test_generate_assets
5
+ icon_set = load_sample1_icon_set
6
+
7
+ output_directory = local_dir('assets')
8
+ Noft::Generator.generate_assets(icon_set.name, output_directory)
9
+
10
+ assert_sample1_dist_output(output_directory)
11
+ end
12
+
13
+ def test_generate_assets_with_existing_assets_in_place
14
+ icon_set = load_sample1_icon_set
15
+
16
+ git_dir = local_dir('myrepo')
17
+ output_directory = "#{git_dir}/assets/fa"
18
+
19
+ create_git_repo(git_dir) do |dir|
20
+ update_dir_from_fixture(output_directory, 'sample1/dist')
21
+ File.write("#{output_directory}/font.ttf", 'random_content')
22
+ end
23
+
24
+ Noft::Generator.generate_assets(icon_set.name, output_directory)
25
+
26
+ assert_sample1_dist_output(output_directory)
27
+
28
+ in_dir(git_dir) do
29
+ assert_equal '', run_command('git status -s')
30
+ end
31
+ end
32
+
33
+ def test_reset_state_if_unchanged
34
+ git_dir = local_dir('myrepo')
35
+ create_git_repo(git_dir) do |dir|
36
+ update_dir_from_fixture(dir, 'sample1')
37
+ File.write('font.ttf', 'random_content')
38
+ end
39
+
40
+ in_dir(git_dir) do
41
+ File.write('font.ttf', 'other content')
42
+ assert_equal " M font.ttf\n", run_command('git status -s')
43
+ Noft::Generator.send(:reset_state_if_unchanged, git_dir)
44
+ assert_equal '', run_command('git status -s')
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,135 @@
1
+ require File.expand_path('../../helper', __FILE__)
2
+
3
+ class TestModel < Noft::TestCase
4
+ def test_to_h
5
+
6
+ Noft.icon_set(:fa) do |s|
7
+ s.display_string = 'Font Awesome'
8
+ s.description = 'The iconic font and CSS toolkit'
9
+ s.version = '4.3.2'
10
+ s.url = 'http://fontawesome.io'
11
+ s.license = 'SIL Open Font License (OFL)'
12
+ s.license_url = 'http://scripts.sil.org/OFL'
13
+
14
+ # Font file ignored
15
+ s.font_file = 'webfont.svg'
16
+
17
+ s.icon(:'map-marker') do |i|
18
+ i.display_string = 'The nice map marker'
19
+
20
+ # unicode ignored
21
+ i.unicode = 'f041'
22
+ i.categories << 'Map Icons'
23
+ i.categories << 'Web App Icons'
24
+ i.aliases << 'map-point'
25
+ i.aliases << 'poi'
26
+ end
27
+
28
+ s.icon(:cross) do |i|
29
+ i.unicode = 'f022'
30
+ i.categories << 'Web App Icons'
31
+ end
32
+ end
33
+
34
+ icon_set = Noft.icon_set_by_name(:fa)
35
+
36
+ expected =
37
+ {
38
+ :name => :fa,
39
+ :displayString => 'Font Awesome',
40
+ :description => 'The iconic font and CSS toolkit',
41
+ :version => '4.3.2',
42
+ :url => 'http://fontawesome.io',
43
+ :license => 'SIL Open Font License (OFL)',
44
+ :licenseUrl => 'http://scripts.sil.org/OFL',
45
+ :icons =>
46
+ {
47
+ :'map-marker' =>
48
+ {
49
+ :displayString => 'The nice map marker',
50
+ :aliases => %w(map-point poi),
51
+ :categories => ['Map Icons', 'Web App Icons'],
52
+ :unicode => 'f041'
53
+ },
54
+ :cross => { :categories => ['Web App Icons'], :unicode => 'f022' } } }
55
+
56
+ assert_equal expected, icon_set.to_h
57
+ end
58
+
59
+ def test_write_then_read
60
+ Noft.icon_set(:fa) do |s|
61
+ s.display_string = 'Font Awesome'
62
+ s.description = 'The iconic font and CSS toolkit'
63
+ s.version = '4.3.2'
64
+ s.url = 'http://fontawesome.io'
65
+ s.license = 'SIL Open Font License (OFL)'
66
+ s.license_url = 'http://scripts.sil.org/OFL'
67
+
68
+ # Font file ignored
69
+ s.font_file = 'webfont.svg'
70
+
71
+ s.icon(:'map-marker') do |i|
72
+ i.display_string = 'The nice map marker'
73
+
74
+ # unicode ignored
75
+ i.unicode = 'f041'
76
+ i.categories << 'Map Icons'
77
+ i.categories << 'Web App Icons'
78
+ i.aliases << 'map-point'
79
+ i.aliases << 'poi'
80
+ end
81
+
82
+ s.icon(:cross) do |i|
83
+ i.unicode = 'f022'
84
+ i.categories << 'Web App Icons'
85
+ end
86
+ end
87
+
88
+ icon_set = Noft.icon_set_by_name(:fa)
89
+
90
+ filename = create_filename('.json')
91
+ icon_set.write_to(filename)
92
+
93
+ Noft.reset
94
+
95
+ icon_set_2 = Noft.read_model(filename)
96
+
97
+ assert_equal icon_set.name, icon_set_2.name
98
+ assert_equal icon_set.to_h, icon_set_2.to_h
99
+ assert_equal nil, icon_set_2.font_file
100
+ assert_equal 'f041', icon_set_2.icon_by_name('map-marker').unicode
101
+ assert_equal 'f022', icon_set_2.icon_by_name('cross').unicode
102
+ end
103
+
104
+ def test_filtering_read
105
+ filename = create_filename('.json')
106
+ Noft.icon_set(:fa) do |s|
107
+ s.icon(:a)
108
+ s.icon(:b)
109
+ s.icon(:c)
110
+ end.write_to(filename)
111
+
112
+ Noft.reset
113
+ icon_set = Noft.read_model(filename)
114
+ assert_equal icon_set.icon_names.sort, %w(a b c)
115
+
116
+ Noft.reset
117
+ icon_set = Noft.read_model(filename, %w(b c d e))
118
+ assert_equal icon_set.icon_names.sort, %w(b c)
119
+
120
+ Noft.reset
121
+ filter = Proc.new { |icon_name| %w(a c x).include?(icon_name) }
122
+ icon_set = Noft.read_model(filename, filter)
123
+ assert_equal icon_set.icon_names.sort, %w(a c)
124
+ end
125
+
126
+ def test_font_file?
127
+ Noft.icon_set(:fa) do |s|
128
+ assert_false s.font_file?
129
+
130
+ s.font_file = 'webfont.svg'
131
+
132
+ assert_true s.font_file?
133
+ end
134
+ end
135
+ end
metadata ADDED
@@ -0,0 +1,217 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: noft
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Peter Donald
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: reality-mda
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: reality-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: reality-facets
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.9.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: reality-generators
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.13.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.13.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: reality-naming
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.9.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.9.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: reality-model
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: reality-orderedhash
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: schmooze
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.6
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.6
125
+ - !ruby/object:Gem::Dependency
126
+ name: minitest
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 5.9.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 5.9.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: test-unit
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 3.1.5
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 3.1.5
153
+ description: A tool to extract svg icons from icon fonts and generate helpers to render
154
+ the icons.
155
+ email: peter@realityforge.org
156
+ executables:
157
+ - noft
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - ".gitattributes"
162
+ - ".gitignore"
163
+ - ".node-version"
164
+ - ".ruby-version"
165
+ - ".travis.yml"
166
+ - CONTRIBUTING.md
167
+ - Gemfile
168
+ - LICENSE
169
+ - README.md
170
+ - Rakefile
171
+ - bin/noft
172
+ - lib/noft.rb
173
+ - lib/noft/base/model.rb
174
+ - lib/noft/base/templates/assets.rb
175
+ - lib/noft/generator.rb
176
+ - lib/noft/model.rb
177
+ - lib/noft_plus.rb
178
+ - lib/noft_plus/util.rb
179
+ - noft.gemspec
180
+ - test/fixtures/sample1/dist/fire-extinguisher.svg
181
+ - test/fixtures/sample1/dist/fire-symbol.svg
182
+ - test/fixtures/sample1/dist/fire.svg
183
+ - test/fixtures/sample1/dist/sample1.noft.json
184
+ - test/fixtures/sample1/webfont.svg
185
+ - test/helper.rb
186
+ - test/noft/base/templates/test_assets_template.rb
187
+ - test/noft/test_generator.rb
188
+ - test/noft/test_model.rb
189
+ homepage: https://github.com/realityforge/noft
190
+ licenses: []
191
+ metadata: {}
192
+ post_install_message:
193
+ rdoc_options:
194
+ - "--line-numbers"
195
+ - "--inline-source"
196
+ - "--title"
197
+ - noft
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements: []
211
+ rubyforge_project:
212
+ rubygems_version: 2.5.1
213
+ signing_key:
214
+ specification_version: 4
215
+ summary: A tool to extract svg icons from icon fonts and generate helpers to render
216
+ the icons.
217
+ test_files: []