usps_flags 0.1.26 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,6 +62,14 @@ class USPSFlags::Helpers
62
62
  end
63
63
  end
64
64
 
65
+ # Gets the maximum length among valid flags.
66
+ #
67
+ # This is used USPSFlags::Generate, and should never need to be called directly.
68
+ # @private
69
+ def max_flag_name_length
70
+ valid_flags(:all).map(&:length).max
71
+ end
72
+
65
73
  # Gets the generation details for the given rank.
66
74
  #
67
75
  # This is used USPSFlags::Generate, and should never need to be called directly.
@@ -76,144 +84,6 @@ class USPSFlags::Helpers
76
84
  }
77
85
  end
78
86
 
79
- # Displays an overlay grid with regularly spaced locator markers.
80
- #
81
- # This is useful for adjusting or creating new SVG data generators, but should not otherwise need to be called.
82
- # @private
83
- def grid(width: USPSFlags::Config::BASE_FLY, height: USPSFlags::Config::BASE_HOIST)
84
- <<~SVG
85
- <circle cx="0" cy="0" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
86
- <circle cx="#{width}" cy="0" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
87
- <circle cx="#{width}" cy="#{height}" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
88
- <circle cx="0" cy="#{height}" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
89
-
90
- <circle cx="#{width*1/4}" cy="#{height/2}" r="#{width/60}" fill="#999999" fill-opacity="0.4" />
91
- <circle cx="#{width*3/4}" cy="#{height/2}" r="#{width/60}" fill="#999999" fill-opacity="0.4" />
92
-
93
- <circle cx="#{width/2}" cy="#{height*1/4}" r="#{width/60}" fill="#999999" fill-opacity="0.4" />
94
- <circle cx="#{width/2}" cy="#{height/2}" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
95
- <circle cx="#{width/2}" cy="#{height/2}" r="#{width/75}" fill="#CCCCCC" fill-opacity="0.4" />
96
- <circle cx="#{width/2}" cy="#{height/2}" r="#{width/100}" fill="#000000" fill-opacity="0.4" />
97
- <circle cx="#{width/2}" cy="#{height*3/4}" r="#{width/60}" fill="#999999" fill-opacity="0.4" />
98
-
99
- <line x1="0" y1="0" x2="#{width}" y2="0" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
100
- <line x1="0" y1="#{height*1/4}" x2="#{width}" y2="#{height*1/4}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
101
- <line x1="0" y1="#{height/2}" x2="#{width}" y2="#{height/2}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
102
- <line x1="0" y1="#{height*3/4}" x2="#{width}" y2="#{height*3/4}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
103
- <line x1="0" y1="#{height}" x2="#{width}" y2="#{height}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
104
-
105
- <line y1="0" x1="0" y2="#{height}" x2="0" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
106
- <line y1="0" x1="#{width*1/6}" y2="#{height}" x2="#{width*1/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
107
- <line y1="0" x1="#{width*2/6}" y2="#{height}" x2="#{width*2/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
108
- <line y1="0" x1="#{width*3/6}" y2="#{height}" x2="#{width*3/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
109
- <line y1="0" x1="#{width*4/6}" y2="#{height}" x2="#{width*4/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
110
- <line y1="0" x1="#{width*5/6}" y2="#{height}" x2="#{width*5/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
111
- <line y1="0" x1="#{width}" y2="#{height}" x2="#{width}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
112
-
113
- <line x1="#{width/2}" y1="#{height*1/4}" x2="#{width*3/4}" y2="#{height/2}" stroke="#999999" stroke-width="#{width/600}" stroke-opacity="0.5" />
114
- <line x1="#{width*3/4}" y1="#{height/2}" x2="#{width/2}" y2="#{height*3/4}" stroke="#999999" stroke-width="#{width/600}" stroke-opacity="0.5" />
115
- <line x1="#{width/2}" y1="#{height*3/4}" x2="#{width*1/4}" y2="#{height/2}" stroke="#999999" stroke-width="#{width/600}" stroke-opacity="0.5" />
116
- <line x1="#{width*1/4}" y1="#{height/2}" x2="#{width/2}" y2="#{height*1/4}" stroke="#999999" stroke-width="#{width/600}" stroke-opacity="0.5" />
117
-
118
- SVG
119
- end
120
-
121
- # Displays an overlay indicator of concentric circles and radiating lines.
122
- #
123
- # This is useful for adjusting or creating new SVG data generators, but should not otherwise need to be called.
124
- # @private
125
- def locator
126
- <<~SVG
127
- <circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY*2}" fill="#000000" fill-opacity="0.4" />
128
- <circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY}" fill="#333333" fill-opacity="0.4" />
129
- <circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY/2}" fill="#666666" fill-opacity="0.4" />
130
- <circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY/4}" fill="#999999" fill-opacity="0.4" />
131
- <circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY/8}" fill="#CCCCCC" fill-opacity="0.4" />
132
- <circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY/16}" fill="#FFFFFF" fill-opacity="0.4" />
133
-
134
- <line x1="-#{USPSFlags::Config::BASE_FLY}" y1="-#{USPSFlags::Config::BASE_HOIST}" x2="#{USPSFlags::Config::BASE_FLY}" y2="#{USPSFlags::Config::BASE_HOIST}" stroke="#FFFFFF" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" />
135
- <line x1="-#{USPSFlags::Config::BASE_FLY}" y1="#{USPSFlags::Config::BASE_HOIST}" x2="#{USPSFlags::Config::BASE_FLY}" y2="-#{USPSFlags::Config::BASE_HOIST}" stroke="#FFFFFF" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" />
136
- <line x1="0" y1="#{USPSFlags::Config::BASE_HOIST}" x2="0" y2="-#{USPSFlags::Config::BASE_HOIST}" stroke="#FFFFFF" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" />
137
- <line x1="-#{USPSFlags::Config::BASE_FLY}" y1="0" x2="#{USPSFlags::Config::BASE_FLY}" y2="0" stroke="#FFFFFF" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" />
138
-
139
- <rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY/30}" height="#{USPSFlags::Config::BASE_FLY/30}" fill="#333333" fill-opacity="0.6" />
140
- SVG
141
- end
142
-
143
- # Creates a vertical arrow for the trident spec sheet.
144
- #
145
- # This is used USPSFlags::Core.trident_spec, and should never need to be called directly.
146
- # @private
147
- def v_arrow(x, top, bottom, pointer_top = nil, pointer_bottom = nil, label: nil, label_offset: (USPSFlags::Config::BASE_FLY/120), label_offset_y: 0, label_align: "left", color: "#CCCCCC", stroke_width: (USPSFlags::Config::BASE_FLY/600), stroke_dash: "10, 10", font_size: (USPSFlags::Config::BASE_FLY/60), arrow_size: (USPSFlags::Config::BASE_FLY/120), fly: USPSFlags::Config::BASE_FLY, unit: nil)
148
- label = bottom - top if label.nil?
149
- label = label.to_i if label - label.to_i == 0
150
- label = Rational(label) * fly / USPSFlags::Config::BASE_FLY
151
- if label == label.to_i
152
- label = label.to_i
153
- label_fraction = ""
154
- else
155
- label, label_fraction = label.to_simplified_a
156
- end
157
- svg = ""
158
- unless pointer_top.nil?
159
- svg << <<~SVG
160
- <line x1="#{x}" y1="#{top}" x2="#{pointer_top}" y2="#{top}" stroke="#{color}" stroke-width="#{stroke_width}" stroke-dasharray="#{stroke_dash}" />
161
- SVG
162
- end
163
- unless pointer_bottom.nil?
164
- svg << <<~SVG
165
- <line x1="#{x}" y1="#{bottom}" x2="#{pointer_bottom}" y2="#{bottom}" stroke="#{color}" stroke-width="#{stroke_width}" stroke-dasharray="#{stroke_dash}" />
166
- SVG
167
- end
168
-
169
- svg << <<~SVG
170
- <path d="M#{x} #{top} l #{arrow_size} #{arrow_size} M#{x} #{top} l -#{arrow_size} #{arrow_size} M#{x} #{top} l 0 #{bottom - top} l #{arrow_size} -#{arrow_size} M#{x} #{bottom} l -#{arrow_size} -#{arrow_size}" stroke="#{color}" stroke-width="#{stroke_width}" fill="none" />
171
- <g>
172
- <style><![CDATA[tspan{font-size: #{USPSFlags::Config::FRACTION_SCALE}%;}]]></style>
173
- <text x="#{x + label_offset}" y="#{(top+bottom)/2+(USPSFlags::Config::BASE_HOIST/150)+label_offset_y}" font-family="sans-serif" font-size="#{font_size}px" fill="#041E42" text-anchor="#{label_align}">#{label} <tspan>#{label_fraction}</tspan> #{unit}</text>
174
- </g>
175
- SVG
176
-
177
- svg
178
- end
179
-
180
- # Creates a horizontal arrow for the trident spec sheet.
181
- #
182
- # This is used USPSFlags::Core.trident_spec, and should never need to be called directly.
183
- # @private
184
- def h_arrow(y, left, right, pointer_left = nil, pointer_right = nil, label: nil, label_offset: (USPSFlags::Config::BASE_FLY/45), label_offset_x: 0, label_align: "middle", color: "#CCCCCC", stroke_width: (USPSFlags::Config::BASE_FLY/600), stroke_dash: "10, 10", font_size: (USPSFlags::Config::BASE_FLY/60), arrow_size: (USPSFlags::Config::BASE_FLY/120), fly: USPSFlags::Config::BASE_FLY, unit: nil)
185
- label = right - left if label.nil?
186
- label = label.to_i if label - label.to_i == 0
187
- label = Rational(label) * fly / USPSFlags::Config::BASE_FLY
188
- if label == label.to_i
189
- label = label.to_i
190
- label_fraction = ""
191
- else
192
- label, label_fraction = label.to_simplified_a
193
- end
194
- svg = ""
195
- unless pointer_left.nil?
196
- svg << <<~SVG
197
- <line x1="#{left}" y1="#{y}" x2="#{left}" y2="#{pointer_left}" stroke="#{color}" stroke-width="#{stroke_width}" stroke-dasharray="#{stroke_dash}" />
198
- SVG
199
- end
200
- unless pointer_right.nil?
201
- svg << <<~SVG
202
- <line x1="#{right}" y1="#{y}" x2="#{right}" y2="#{pointer_right}" stroke="#{color}" stroke-width="#{stroke_width}" stroke-dasharray="#{stroke_dash}" />
203
- SVG
204
- end
205
-
206
- svg << <<~SVG
207
- <path d="M#{left} #{y} l #{arrow_size} #{arrow_size} M#{left} #{y} l #{arrow_size} -#{arrow_size} M#{left} #{y} l #{right - left} 0 l -#{arrow_size} -#{arrow_size} M#{right} #{y} l -#{arrow_size} #{arrow_size}" stroke="#{color}" stroke-width="#{stroke_width}" fill="none" />
208
- <g>
209
- <style><![CDATA[tspan{font-size: #{USPSFlags::Config::FRACTION_SCALE}%;}]]></style>
210
- <text x="#{(left+right)/2+label_offset_x}" y="#{y + label_offset}" font-family="sans-serif" font-size="#{font_size}px" fill="#041E42" text-anchor="#{label_align}">#{label} <tspan>#{label_fraction}</tspan> #{unit}</text>
211
- </g>
212
- SVG
213
-
214
- svg
215
- end
216
-
217
87
  # Resizes and saves a PNG image.
218
88
  #
219
89
  # This is used USPSFlags::Generate, and should never need to be called directly.
@@ -279,6 +149,21 @@ class USPSFlags::Helpers
279
149
  log_file.close if log_file.is_a?(File)
280
150
  end
281
151
 
152
+ # Prints output to the console or saves to a file, then returns the generated data.
153
+ #
154
+ # This should never need to be called directly.
155
+ # @private
156
+ def output(svg, outfile: nil)
157
+ if outfile.nil?
158
+ puts svg, "\n"
159
+ elsif outfile != ""
160
+ f = ::File.new(outfile, "w+")
161
+ f.write(svg)
162
+ f.close
163
+ end
164
+ svg
165
+ end
166
+
282
167
  private
283
168
  def flag_style(rank)
284
169
  if valid_flags(:past).include?(rank)
@@ -329,15 +214,7 @@ class USPSFlags::Helpers
329
214
  end
330
215
 
331
216
  def flag_type(rank)
332
- if valid_flags(:squadron).include?(rank)
333
- :s
334
- elsif valid_flags(:district).include?(rank)
335
- :d
336
- elsif rank == "STFC"
337
- :stf
338
- elsif valid_flags(:national).include?(rank)
339
- :n
340
- elsif rank == "PORTCAP"
217
+ if rank == "PORTCAP"
341
218
  :pc
342
219
  elsif rank == "FLEETCAP"
343
220
  :fc
@@ -351,6 +228,14 @@ class USPSFlags::Helpers
351
228
  :f
352
229
  elsif rank == "NFLT"
353
230
  :f
231
+ elsif rank == "STFC"
232
+ :stf
233
+ elsif valid_flags(:squadron).include?(rank)
234
+ :s
235
+ elsif valid_flags(:district).include?(rank)
236
+ :d
237
+ elsif valid_flags(:national).include?(rank)
238
+ :n
354
239
  end
355
240
  end
356
241
  end
data/lib/usps_flags.rb CHANGED
@@ -14,10 +14,20 @@ class USPSFlags
14
14
  require 'usps_flags/generate'
15
15
 
16
16
  # Dir['./lib/usps_flags/core/**'].map { |d| d.split("/").last.split(".rb").first }
17
- %w[anchor binoculars ensign field footer headers lighthouse pennant star trident trident_spec trumpet us wheel].each do |d|
17
+ %w[anchor binoculars ensign field footer headers lighthouse pennant star trident tridents trident_spec trumpet us wheel].each do |d|
18
18
  require "usps_flags/core/#{d}"
19
19
  end
20
20
 
21
+ # Dir['./lib/usps_flags/generate/**'].map { |d| d.split("/").last.split(".rb").first }
22
+ %w[flag].each do |d|
23
+ require "usps_flags/generate/#{d}"
24
+ end
25
+
26
+ # Dir['./lib/usps_flags/helpers/**'].map { |d| d.split("/").last.split(".rb").first }
27
+ %w[builders spec_arrows].each do |d|
28
+ require "usps_flags/helpers/#{d}"
29
+ end
30
+
21
31
  # Constructor for individual flags.
22
32
  #
23
33
  # @example Generate insignia at default scale for Lt/C
@@ -126,7 +136,7 @@ class USPSFlags
126
136
  #
127
137
  # @return [String] Returns the SVG file output path, or the svg data if no path was specified.
128
138
  def svg
129
- svg = USPSFlags::Generate.get(self.type, outfile: self.svg_file, scale: self.scale, field: self.field)
139
+ svg = USPSFlags::Generate.svg(self.type, outfile: self.svg_file, scale: self.scale, field: self.field)
130
140
  (self.svg_file.nil? || self.svg_file == "") ? svg : self.svg_file
131
141
  end
132
142
 
@@ -2,11 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe USPSFlags::Generate do
4
4
  it "should generate a flag with the correct size" do
5
- expect(USPSFlags::Generate.get("LtC", outfile: "")).to include("width=\"1024pt\" height=\"682pt\" viewBox=\"0 0 3072 2048\"")
5
+ expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include(
6
+ "width=\"1024pt\" height=\"682pt\" viewBox=\"0 0 3072 2048\""
7
+ )
6
8
  end
7
9
 
8
10
  it "should generate a flag with the correct field" do
9
- expect(USPSFlags::Generate.get("LtC", outfile: "")).to include(
11
+ expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include(
10
12
  <<~SVG
11
13
  <path d="M 0 0
12
14
  l 3072 0
@@ -19,11 +21,41 @@ describe USPSFlags::Generate do
19
21
  end
20
22
 
21
23
  it "should generate a flag with the correct starting position" do
22
- expect(USPSFlags::Generate.get("LtC", outfile: "")).to include("<path d=\"M 1536 512")
24
+ expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include("<path d=\"M 1536 512")
23
25
  end
24
26
 
25
27
  it "should generate a flag with the correct trident transformations" do
26
- expect(USPSFlags::Generate.get("LtC", outfile: "")).to include("<g transform=\"translate(-512)\">")
27
- expect(USPSFlags::Generate.get("LtC", outfile: "")).to include("<g transform=\"translate(512)\">")
28
+ expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include("<g transform=\"translate(-512)\">")
29
+ expect(USPSFlags::Generate.svg("LtC", outfile: "")).to include("<g transform=\"translate(512)\">")
30
+ end
31
+
32
+ describe "special flags" do
33
+ it "should generate PortCap" do
34
+ expect(USPSFlags::Generate.svg("PortCap", outfile: "")).to include("<title>PORTCAP</title>")
35
+ end
36
+
37
+ it "should generate FleetCap" do
38
+ expect(USPSFlags::Generate.svg("FleetCap", outfile: "")).to include("<title>FLEETCAP</title>")
39
+ end
40
+
41
+ it "should generate DAide" do
42
+ expect(USPSFlags::Generate.svg("DAide", outfile: "")).to include("<title>DAIDE</title>")
43
+ end
44
+
45
+ it "should generate NAide" do
46
+ expect(USPSFlags::Generate.svg("NAide", outfile: "")).to include("<title>NAIDE</title>")
47
+ end
48
+
49
+ it "should generate FLt" do
50
+ expect(USPSFlags::Generate.svg("FLt", outfile: "")).to include("<title>FLT</title>")
51
+ end
52
+
53
+ it "should generate DFLt" do
54
+ expect(USPSFlags::Generate.svg("DFLt", outfile: "")).to include("<title>DFLT</title>")
55
+ end
56
+
57
+ it "should generate NFLt" do
58
+ expect(USPSFlags::Generate.svg("NFLt", outfile: "")).to include("<title>NFLT</title>")
59
+ end
28
60
  end
29
61
  end
@@ -7,7 +7,10 @@ describe USPSFlags::Helpers do
7
7
  end
8
8
 
9
9
  it "should return all officer flags but nothing else when given type :officer" do
10
- expect(USPSFlags::Helpers.valid_flags(:officer).sort).to eql(%w[PLTC PC PORTCAP FLEETCAP LT FLT 1LT LTC CDR PDLTC PDC DLT DAIDE DFLT D1LT DLTC DC PSTFC PRC PVC PCC NAIDE NFLT STFC RC VC CC].sort)
10
+ expect(USPSFlags::Helpers.valid_flags(:officer).sort).to eql(%w[
11
+ PLTC PC PORTCAP FLEETCAP LT FLT 1LT LTC CDR PDLTC PDC DLT DAIDE
12
+ DFLT D1LT DLTC DC PSTFC PRC PVC PCC NAIDE NFLT STFC RC VC CC
13
+ ].sort)
11
14
  end
12
15
  end
13
16
  end
@@ -1,6 +1,94 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe USPSFlags do
4
+ before(:all) do
5
+ @valid_header = <<~SVG
6
+ <?xml version="1.0" standalone="no"?>
7
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
8
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="614pt" height="409pt" viewBox="0 0 3072 2048" preserveAspectRatio="xMidYMid meet">
9
+ <title>LTC</title>
10
+ <metadata>
11
+ <desc id="created-by">Julian Fiander</desc>
12
+ SVG
13
+
14
+ @valid_body = <<~SVG
15
+ <desc id="trademark-desc">This image is a registered trademark of United States Power Squadrons.</desc>
16
+ <desc id="trademark-link">http://www.usps.org/national/itcom/trademark.html</desc>
17
+ </metadata>
18
+ <g transform="translate(-512)">
19
+ <path d="M 1536 512
20
+ l 80 136
21
+ l -40 -8
22
+ l 0 896
23
+ l -80 0
24
+ l 0 -896
25
+ l -40 8
26
+ l 80 -136
27
+ " fill="#BF0D3E" />
28
+ <path d="M 1296 1024
29
+ l 480 0
30
+ l 0 80
31
+ l -480 0
32
+ l 0 -80
33
+ " fill="#BF0D3E" />
34
+ <path d="M 1296 1025
35
+ l 0 -432
36
+ l 120 136
37
+ l -40 0
38
+ l 0 296
39
+ " fill="#BF0D3E" />
40
+ <path d="M 1776 1025
41
+ l 0 -432
42
+ l -120 136
43
+ l 40 0
44
+ l 0 296
45
+ " fill="#BF0D3E" />
46
+ <path d="M 1392 1184
47
+ l 288 0
48
+ l 0 80
49
+ l -288 0
50
+ l 0 -80
51
+ " fill="#BF0D3E" />
52
+ </g>
53
+ <g transform="translate(512)">
54
+ <path d="M 1536 512
55
+ l 80 136
56
+ l -40 -8
57
+ l 0 896
58
+ l -80 0
59
+ l 0 -896
60
+ l -40 8
61
+ l 80 -136
62
+ " fill="#BF0D3E" />
63
+ <path d="M 1296 1024
64
+ l 480 0
65
+ l 0 80
66
+ l -480 0
67
+ l 0 -80
68
+ " fill="#BF0D3E" />
69
+ <path d="M 1296 1025
70
+ l 0 -432
71
+ l 120 136
72
+ l -40 0
73
+ l 0 296
74
+ " fill="#BF0D3E" />
75
+ <path d="M 1776 1025
76
+ l 0 -432
77
+ l -120 136
78
+ l 40 0
79
+ l 0 296
80
+ " fill="#BF0D3E" />
81
+ <path d="M 1392 1184
82
+ l 288 0
83
+ l 0 80
84
+ l -288 0
85
+ l 0 -80
86
+ " fill="#BF0D3E" />
87
+ </g>
88
+ </svg>
89
+ SVG
90
+ end
91
+
4
92
  before(:each) do
5
93
  @flag = USPSFlags.new
6
94
  end
@@ -36,134 +124,21 @@ describe USPSFlags do
36
124
  expect(@flag.png_file).to eql("/path/to/png/output.png")
37
125
  end
38
126
 
39
- it "should construct and generate a flag" do
40
- @flag.type "Cdr"
41
- @flag.scale 5
42
- @flag.svg_file ""
43
-
44
- svg = @flag.svg
127
+ describe "as configured" do
128
+ before(:each) do
129
+ @flag.type "LtC"
130
+ @flag.scale 5
131
+ @flag.svg_file ""
132
+ @flag.svg
133
+ end
45
134
 
46
- expect(svg).to include(
47
- <<~SVG
48
- <?xml version="1.0" standalone="no"?>
49
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
50
- <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="614pt" height="409pt" viewBox="0 0 3072 2048" preserveAspectRatio="xMidYMid meet">
51
- <title>CDR</title>
52
- <metadata>
53
- <desc id="created-by">Julian Fiander</desc>
54
- SVG
55
- )
135
+ it "should construct and generate a flag with a valid header" do
136
+ expect(@flag.svg).to include(@valid_header)
137
+ end
56
138
 
57
- expect(svg).to include(
58
- <<~SVG
59
- <desc id="trademark-desc">This image is a registered trademark of United States Power Squadrons.</desc>
60
- <desc id="trademark-link">http://www.usps.org/national/itcom/trademark.html</desc>
61
- </metadata>
62
- <g transform="translate(-768, 192)">
63
- <path d="M 1536 512
64
- l 80 136
65
- l -40 -8
66
- l 0 896
67
- l -80 0
68
- l 0 -896
69
- l -40 8
70
- l 80 -136
71
- " fill="#041E42" />
72
- <path d="M 1296 1024
73
- l 480 0
74
- l 0 80
75
- l -480 0
76
- l 0 -80
77
- " fill="#041E42" />
78
- <path d="M 1296 1025
79
- l 0 -432
80
- l 120 136
81
- l -40 0
82
- l 0 296
83
- " fill="#041E42" />
84
- <path d="M 1776 1025
85
- l 0 -432
86
- l -120 136
87
- l 40 0
88
- l 0 296
89
- " fill="#041E42" />
90
- <path d="M 1392 1184
91
- l 288 0
92
- l 0 80
93
- l -288 0
94
- l 0 -80
95
- " fill="#041E42" />
96
- </g><g transform="translate(0, -193)">
97
- <path d="M 1536 512
98
- l 80 136
99
- l -40 -8
100
- l 0 896
101
- l -80 0
102
- l 0 -896
103
- l -40 8
104
- l 80 -136
105
- " fill="#041E42" />
106
- <path d="M 1296 1024
107
- l 480 0
108
- l 0 80
109
- l -480 0
110
- l 0 -80
111
- " fill="#041E42" />
112
- <path d="M 1296 1025
113
- l 0 -432
114
- l 120 136
115
- l -40 0
116
- l 0 296
117
- " fill="#041E42" />
118
- <path d="M 1776 1025
119
- l 0 -432
120
- l -120 136
121
- l 40 0
122
- l 0 296
123
- " fill="#041E42" />
124
- <path d="M 1392 1184
125
- l 288 0
126
- l 0 80
127
- l -288 0
128
- l 0 -80
129
- " fill="#041E42" />
130
- </g><g transform="translate(768, 192)">
131
- <path d="M 1536 512
132
- l 80 136
133
- l -40 -8
134
- l 0 896
135
- l -80 0
136
- l 0 -896
137
- l -40 8
138
- l 80 -136
139
- " fill="#041E42" />
140
- <path d="M 1296 1024
141
- l 480 0
142
- l 0 80
143
- l -480 0
144
- l 0 -80
145
- " fill="#041E42" />
146
- <path d="M 1296 1025
147
- l 0 -432
148
- l 120 136
149
- l -40 0
150
- l 0 296
151
- " fill="#041E42" />
152
- <path d="M 1776 1025
153
- l 0 -432
154
- l -120 136
155
- l 40 0
156
- l 0 296
157
- " fill="#041E42" />
158
- <path d="M 1392 1184
159
- l 288 0
160
- l 0 80
161
- l -288 0
162
- l 0 -80
163
- " fill="#041E42" />
164
- </g></svg>
165
- SVG
166
- )
139
+ it "should construct and generate a flag with a valid body" do
140
+ expect(@flag.svg).to include(@valid_body)
141
+ end
167
142
  end
168
143
  end
169
144
  end
data/usps_flags.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'usps_flags'
3
- s.version = '0.1.26'
4
- s.date = '2017-11-02'
3
+ s.version = '0.2.0'
4
+ s.date = '2017-11-03'
5
5
  s.summary = 'Flag generator for United States Power Squadrons'
6
6
  s.description = 'A flag image (PNG, SVG) generator for United States Power Squadrons.'
7
7
  s.homepage = 'http://rubygems.org/gems/usps_flags'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps_flags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.26
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
@@ -30,7 +30,7 @@ cert_chain:
30
30
  3YzYAc+kXfD7kkzA2NMvLT6Q1v03qQyIZ8BS8SNk5wLGAdLM+IravFDLEs448fjz
31
31
  lEAU0RHLFVbE+CXW6makIlWGHR0=
32
32
  -----END CERTIFICATE-----
33
- date: 2017-11-02 00:00:00.000000000 Z
33
+ date: 2017-11-03 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: file_utils
@@ -189,11 +189,15 @@ files:
189
189
  - lib/usps_flags/core/star.rb
190
190
  - lib/usps_flags/core/trident.rb
191
191
  - lib/usps_flags/core/trident_spec.rb
192
+ - lib/usps_flags/core/tridents.rb
192
193
  - lib/usps_flags/core/trumpet.rb
193
194
  - lib/usps_flags/core/us.rb
194
195
  - lib/usps_flags/core/wheel.rb
195
196
  - lib/usps_flags/generate.rb
197
+ - lib/usps_flags/generate/flag.rb
196
198
  - lib/usps_flags/helpers.rb
199
+ - lib/usps_flags/helpers/builders.rb
200
+ - lib/usps_flags/helpers/spec_arrows.rb
197
201
  - spec/rational_spec.rb
198
202
  - spec/spec_helper.rb
199
203
  - spec/usps_flags/config_spec.rb
metadata.gz.sig CHANGED
Binary file