usps_flags-grades 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ require 'usps_flags'
7
+ require 'usps_flags/grades'
8
+
9
+ # The spec for USPSFlags::Grades contains an example that checks for
10
+ # USPSFlags::Errors::InvalidGrade
11
+ RSpec::Expectations.configuration.on_potential_false_positives = :nothing
12
+
13
+ RSpec.configure do |config|
14
+ config.before(:suite) do
15
+ $tmp_flags_dir = "tmp/flags"
16
+
17
+ USPSFlags.configure do |c|
18
+ c.flags_dir = $tmp_flags_dir
19
+ end
20
+ end
21
+
22
+ config.after(:suite) do
23
+ ::FileUtils.rm_rf("tmp") if ::Dir.exist?("tmp")
24
+ end
25
+ end
@@ -0,0 +1,284 @@
1
+ require 'spec_helper'
2
+
3
+ describe USPSFlags::Grades do
4
+ context "invalid grade" do
5
+ it "should raise USPSFlags::Errors::InvalidInsignia if an invalid insignia is specified" do
6
+ @insignia = USPSFlags::Grades.new do |b|
7
+ b.grade = :not_a_grade
8
+ b.outfile = ""
9
+ end
10
+
11
+ expect { @insignia.svg }.to raise_error(USPSFlags::Errors::InvalidInsignia)
12
+ end
13
+ end
14
+
15
+ context "S" do
16
+ before(:each) do
17
+ @insignia = USPSFlags::Grades.new do |g|
18
+ g.grade = :s
19
+ g.outfile = ""
20
+ end
21
+ end
22
+
23
+ it "should have the S insignia" do
24
+ expect(@insignia.svg).to include(
25
+ <<~SVG
26
+ <g transform="translate(0, 50)">
27
+ <rect x="0" y="0" width="100" height="35" fill="#FFD700" />
28
+ SVG
29
+ )
30
+ end
31
+ end
32
+
33
+ context "P" do
34
+ before(:each) do
35
+ @insignia = USPSFlags::Grades.new do |g|
36
+ g.grade = :p
37
+ g.outfile = ""
38
+ end
39
+ end
40
+
41
+ it "should have the P insignia" do
42
+ expect(@insignia.svg).to include(
43
+ <<~SVG
44
+ <g transform="translate(0, 50)">
45
+ <rect x="0" y="0" width="100" height="35" fill="#FFD700" />
46
+
47
+ <g transform="translate(125)"><rect x="0" y="0" width="100" height="35" fill="#FFD700" />
48
+ </g>
49
+ SVG
50
+ )
51
+ end
52
+ end
53
+
54
+ context "AP - EdPro" do
55
+ before(:each) do
56
+ @insignia = USPSFlags::Grades.new do |g|
57
+ g.grade = :ap
58
+ g.edpro = true
59
+ g.outfile = ""
60
+ end
61
+ end
62
+
63
+ it "should have the AP insignia" do
64
+ expect(@insignia.svg).to include(
65
+ <<~SVG
66
+ <g transform="translate(0, 50)">
67
+ <rect x="0" y="0" width="100" height="35" fill="#FFD700" />
68
+
69
+ <g transform="translate(192.5)"><g transform="scale(0.25) translate(0, 150)">
70
+ <path d="M 0 0
71
+ l 117.555 81.805
72
+ l -41.47 -137.085
73
+ l 114.125 -86.525
74
+ l -143.185 -2.915
75
+ l -47.025 -135.28
76
+ l -47.025 135.28
77
+ l -143.185 2.915
78
+ l 114.125 86.525
79
+ l -41.47 137.085
80
+ l 117.555 -81.805
81
+ " fill="#FFD700" />
82
+
83
+ </g>
84
+ </g>
85
+ <g transform="translate(281.25)"><rect x="0" y="0" width="100" height="35" fill="#FFD700" />
86
+ </g>
87
+ SVG
88
+ )
89
+ end
90
+
91
+ it "should have the AP EdPro bar" do
92
+ expect(@insignia.svg).to include(
93
+ <<~SVG
94
+ <rect x="0" y="100" width="381.25" height="15" fill="#FFD700" />
95
+ SVG
96
+ )
97
+ end
98
+ end
99
+
100
+ context "JN - 5MM" do
101
+ before(:each) do
102
+ @insignia = USPSFlags::Grades.new do |g|
103
+ g.grade = :jn
104
+ g.merit_marks = 5
105
+ g.edpro = true
106
+ g.outfile = ""
107
+ end
108
+ end
109
+
110
+ it "should have the JN insignia" do
111
+ expect(@insignia.svg).to include(
112
+ <<~SVG
113
+ <g transform="translate(0, 50)">
114
+ <g transform="translate(50)">
115
+ <g transform="scale(0.25) translate(0, 150)">
116
+ <path d="M 0 0
117
+ l 117.555 81.805
118
+ l -41.47 -137.085
119
+ l 114.125 -86.525
120
+ l -143.185 -2.915
121
+ l -47.025 -135.28
122
+ l -47.025 135.28
123
+ l -143.185 2.915
124
+ l 114.125 86.525
125
+ l -41.47 137.085
126
+ l 117.555 -81.805
127
+ " fill="#FFD700" />
128
+
129
+ </g>
130
+
131
+ <g transform="translate(87)"><rect x="0" y="0" width="100" height="35" fill="#FFD700" />
132
+ </g>
133
+ <g transform="translate(270)"><g transform="scale(0.25) translate(0, 150)">
134
+ <path d="M 0 0
135
+ l 117.555 81.805
136
+ l -41.47 -137.085
137
+ l 114.125 -86.525
138
+ l -143.185 -2.915
139
+ l -47.025 -135.28
140
+ l -47.025 135.28
141
+ l -143.185 2.915
142
+ l 114.125 86.525
143
+ l -41.47 137.085
144
+ l 117.555 -81.805
145
+ " fill="#FFD700" />
146
+
147
+ </g>
148
+ </g>
149
+ </g>
150
+ SVG
151
+ )
152
+ end
153
+
154
+ it "should have a 5th position merit mark" do
155
+ expect(@insignia.svg).to include("<rect x=\"180\" y=\"0\" width=\"35\" height=\"80\" fill=\"#FFD700\" />")
156
+ end
157
+
158
+ it "should not have a 6th position merit mark" do
159
+ expect(@insignia.svg).to_not include("<rect x=\"225\" y=\"0\" width=\"35\" height=\"80\" fill=\"#FFD700\" />")
160
+ end
161
+
162
+ it "should have the JN EdPro bar" do
163
+ expect(@insignia.svg).to include(
164
+ <<~SVG
165
+ <rect x="0" y="100" width="365" height="15" fill="#FFD700" />
166
+ SVG
167
+ )
168
+ end
169
+ end
170
+
171
+ context "N - Life Member" do
172
+ before(:each) do
173
+ @insignia = USPSFlags::Grades.new do |g|
174
+ g.grade = :n
175
+ g.membership = :life
176
+ g.outfile = ""
177
+ end
178
+ end
179
+
180
+ it "should have the N insignia" do
181
+ expect(@insignia.svg).to include(
182
+ <<~SVG
183
+ <g transform="translate(0, 50)">
184
+ <g transform="translate(50)">
185
+ <g transform="scale(0.25) translate(0, 150)">
186
+ <path d="M 0 0
187
+ l 117.555 81.805
188
+ l -41.47 -137.085
189
+ l 114.125 -86.525
190
+ l -143.185 -2.915
191
+ l -47.025 -135.28
192
+ l -47.025 135.28
193
+ l -143.185 2.915
194
+ l 114.125 86.525
195
+ l -41.47 137.085
196
+ l 117.555 -81.805
197
+ " fill="#FFD700" />
198
+
199
+ </g>
200
+
201
+ <g transform="translate(87)"><rect x="0" y="0" width="100" height="35" fill="#FFD700" />
202
+ </g>
203
+ <g transform="translate(270)"><g transform="scale(0.25) translate(0, 150)">
204
+ <path d="M 0 0
205
+ l 117.555 81.805
206
+ l -41.47 -137.085
207
+ l 114.125 -86.525
208
+ l -143.185 -2.915
209
+ l -47.025 -135.28
210
+ l -47.025 135.28
211
+ l -143.185 2.915
212
+ l 114.125 86.525
213
+ l -41.47 137.085
214
+ l 117.555 -81.805
215
+ " fill="#FFD700" />
216
+
217
+ </g>
218
+ </g>
219
+ <g transform="translate(365)"><rect x="0" y="0" width="100" height="35" fill="#FFD700" />
220
+ </g>
221
+ <g transform="translate(550)"><g transform="scale(0.25) translate(0, 150)">
222
+ <path d="M 0 0
223
+ l 117.555 81.805
224
+ l -41.47 -137.085
225
+ l 114.125 -86.525
226
+ l -143.185 -2.915
227
+ l -47.025 -135.28
228
+ l -47.025 135.28
229
+ l -143.185 2.915
230
+ l 114.125 86.525
231
+ l -41.47 137.085
232
+ l 117.555 -81.805
233
+ " fill="#FFD700" />
234
+
235
+ </g>
236
+ </g>
237
+ </g>
238
+ SVG
239
+ )
240
+ end
241
+
242
+ it "should have a life member arrow" do
243
+ expect(@insignia.svg).to include(
244
+ "m 107.6,178.2 c -0.2,0.7 -1.2,4.7 -2.1,8.8 -0.9,4.1 -2.2,9.7 -3,12.5 -7.9,29.7 -8.9,51.9 -2.9,67.7 4.5,12.2 7,16.7 8.9,16.7 2.4,0.1 12.2,-15.8 16.2,-26.4 6.4,-16.5 6.7,-18 6.7,-33.6 0.1,-15.7 -0.1,-16.4 -6.7,-29.7 -2,-3.9 -5.4,-8.5 -8.9,-11.8 -5.7,-5.5 -7.6,-6.4 -8.2,-4.2 z"
245
+ )
246
+ end
247
+ end
248
+
249
+ context "SN - Senior Member - 20 MM" do
250
+ before(:each) do
251
+ @insignia = USPSFlags::Grades.new do |g|
252
+ g.grade = :sn
253
+ g.membership = :senior
254
+ g.merit_marks = 20
255
+ g.outfile = ""
256
+ end
257
+ end
258
+
259
+ it "should have the SN insignia box" do
260
+ expect(@insignia.svg).to include(
261
+ <<~SVG
262
+ <polyline points="20,-10 735,-10 735,150 20,150 20,-10" fill="none" stroke-width="15" stroke="#FFD700" />
263
+ SVG
264
+ )
265
+ end
266
+
267
+ it "should have a senior member arrow" do
268
+ expect(@insignia.svg).to include(
269
+ <<~SVG
270
+ <polyline points="0,250 75,220 75,240 150,240 150,260 75,260 75,280 0,250" fill="#FFD700" />
271
+ <polyline points="145,240 350,240 350,260 145,260 145,240" fill="#FFD700" />
272
+ <polyline points="400,240 610,240 610,260 400,260 400,240" fill="#FFD700" />
273
+ <polyline points="600,240 675,240 675,220 750,250 675,280 675,260 600,260 600,240" fill="#FFD700" />
274
+
275
+ <polyline points="325,200 350,200 375,275 400,200 425,200 390,300 360,300 325,200" fill="#FFD700" />
276
+ SVG
277
+ )
278
+ end
279
+
280
+ it "should have a 20th position merit mark" do
281
+ expect(@insignia.svg).to include("<rect x=\"855\" y=\"0\" width=\"35\" height=\"80\" fill=\"#FFD700\" />")
282
+ end
283
+ end
284
+ end
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'usps_flags-grades'
3
+ s.version = '0.0.1'
4
+ s.date = '2017-11-16'
5
+ s.summary = 'Insignia generator for United States Power Squadrons'
6
+ s.description = 'An extension to the flag image (PNG, SVG) generator for United States Power Squadrons to generate grade insignia.'
7
+ s.homepage = 'http://rubygems.org/gems/usps_flags-grades'
8
+ s.license = 'GPL-3.0'
9
+ s.authors = ['Julian Fiander']
10
+ s.email = 'julian@fiander.one'
11
+ s.require_paths = ['lib', 'spec']
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- spec/*`.split("\n")
14
+
15
+ s.cert_chain = ['certs/jfiander.pem']
16
+ s.signing_key = File.expand_path("~/.ssh/usps_flags-private_key.pem") if $0 =~ /gem\z/
17
+
18
+ s.required_ruby_version = '~> 2.4'
19
+
20
+ s.add_runtime_dependency 'usps_flags', '~> 0.3', '>= 0.3.15'
21
+
22
+ s.add_development_dependency 'rake', '~> 12.2', '>= 12.2.1'
23
+ s.add_development_dependency 'rspec', '~> 3.7', '>= 3.7.0'
24
+ s.add_development_dependency 'simplecov', '~> 0.15', '>= 0.15.1'
25
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: usps_flags-grades
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Julian Fiander
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQ8wDQYDVQQDDAZqdWxp
14
+ YW4xFzAVBgoJkiaJk/IsZAEZFgdmaWFuZGVyMRMwEQYKCZImiZPyLGQBGRYDb25l
15
+ MB4XDTE3MTAxNzIwMzYwNVoXDTE4MTAxNzIwMzYwNVowPzEPMA0GA1UEAwwGanVs
16
+ aWFuMRcwFQYKCZImiZPyLGQBGRYHZmlhbmRlcjETMBEGCgmSJomT8ixkARkWA29u
17
+ ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKgyweLKJcXOZUJ/Y/fb
18
+ IjGIQzFgi0UUbIxc6BRP3BYCAr7MpflEq3sYaVsECs0ZyM27zLpyDN0oW73Wby6k
19
+ jaik/yBcsDMvrl58+6mjHnB3yIuk0BbEfQaijgMBzW2p0hToocMToMXigwZOGe4e
20
+ kPTAO6yTIIYLhhjWALA+nURCBcCNI8d1YAIjiEuF1lCr4pnV4aAq8tPBVrz7a8Fg
21
+ WpeLe0V1Blhkg9BDzNUmSrDxDxitO8oA5+A0z9Wm1xn8cJfn50103813SEK8gaXV
22
+ eb/zLRa/CNnTzQ8xUrySd10b1auLnKduXgewBhINcWYjDOT/C1FCjxpK5F6buJ6S
23
+ 1ukCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFI/F
24
+ wfSc4YJ3gO9EnkvjGcT6fE3WMB0GA1UdEQQWMBSBEmp1bGlhbkBmaWFuZGVyLm9u
25
+ ZTAdBgNVHRIEFjAUgRJqdWxpYW5AZmlhbmRlci5vbmUwDQYJKoZIhvcNAQEFBQAD
26
+ ggEBAHddpCbrFKtf02u/4MPzRQQO+uTP9vlbNDxseQsMvpjIIzMjJzANGBqPeI+V
27
+ HCjLEnKtnUi9br+RqjtQWWc2jGBdZwrlhOFglKUcTVn60ZvBNrByUj8PeBHQR3U2
28
+ vEKSi1v2i/jlVVvrk+9z4DZ4QdrfARBcPCZhUSZcZBsDbnzjMeX6lhoknnqKn/oi
29
+ op1Z8vhtFmvxNk4UfHMG1bdUoxl6DDXKfodqWM//9mARZwSyVX9oV7snFP0nKUaD
30
+ 3YzYAc+kXfD7kkzA2NMvLT6Q1v03qQyIZ8BS8SNk5wLGAdLM+IravFDLEs448fjz
31
+ lEAU0RHLFVbE+CXW6makIlWGHR0=
32
+ -----END CERTIFICATE-----
33
+ date: 2017-11-16 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: usps_flags
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.3'
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 0.3.15
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '0.3'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.15
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '12.2'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 12.2.1
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '12.2'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 12.2.1
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.7'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 3.7.0
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '3.7'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 3.7.0
95
+ - !ruby/object:Gem::Dependency
96
+ name: simplecov
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.15'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 0.15.1
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0.15'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 0.15.1
115
+ description: An extension to the flag image (PNG, SVG) generator for United States
116
+ Power Squadrons to generate grade insignia.
117
+ email: julian@fiander.one
118
+ executables: []
119
+ extensions: []
120
+ extra_rdoc_files: []
121
+ files:
122
+ - ".gitignore"
123
+ - ".rspec"
124
+ - ".travis.yml"
125
+ - ".yardopts"
126
+ - CONTRIBUTING.md
127
+ - Gemfile
128
+ - Gemfile.lock
129
+ - LICENSE
130
+ - README.md
131
+ - Rakefile
132
+ - certs/jfiander.pem
133
+ - lib/usps_flags/grades.rb
134
+ - lib/usps_flags/grades/config.rb
135
+ - lib/usps_flags/grades/edpro.rb
136
+ - lib/usps_flags/grades/errors.rb
137
+ - lib/usps_flags/grades/grade.rb
138
+ - lib/usps_flags/grades/membership.rb
139
+ - lib/usps_flags/grades/merit_marks.rb
140
+ - spec/spec_helper.rb
141
+ - spec/usps_flags/grades_spec.rb
142
+ - usps_flags-grades.gemspec
143
+ homepage: http://rubygems.org/gems/usps_flags-grades
144
+ licenses:
145
+ - GPL-3.0
146
+ metadata: {}
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ - spec
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "~>"
155
+ - !ruby/object:Gem::Version
156
+ version: '2.4'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.6.11
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: Insignia generator for United States Power Squadrons
168
+ test_files:
169
+ - spec/spec_helper.rb
170
+ - spec/usps_flags/grades_spec.rb