usps_flags 0.1.18 → 0.1.19
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Gemfile.lock +1 -1
- data/lib/usps_flags/core.rb +23 -4
- data/lib/usps_flags/generate.rb +13 -7
- data/spec/usps_flags_spec.rb +14 -2
- data/usps_flags.gemspec +1 -1
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 334838e6f88c5f97f13d666ec09588632f6bd192
|
4
|
+
data.tar.gz: 705b3854cd1c94a072072475e64ab056e1a6d4ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad8ebeaceb5137f9ae20118e1e8f7213c226a87fc7d59b23e831cf595f0b6aacd53306b618b51d9627c4e8715812476dfc056b292d69ada4f3f8a9cc18803a88
|
7
|
+
data.tar.gz: fb6222886058c25b806e9691ce0f5694267ce6f325759397b0b03c2f108e350a42964d3686f5342a5c29e73eb720c8b8c7b7f5bd6bda604165b69da7168a756f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Gemfile.lock
CHANGED
data/lib/usps_flags/core.rb
CHANGED
@@ -171,7 +171,7 @@ class USPSFlags::Core
|
|
171
171
|
svg
|
172
172
|
end
|
173
173
|
|
174
|
-
def self.headers(width: nil, height: nil, pennant: false, scale: nil)
|
174
|
+
def self.headers(width: nil, height: nil, pennant: false, scale: nil, title: "USPS Flag")
|
175
175
|
if width.nil? || height.nil?
|
176
176
|
scale = 3 if scale.nil?
|
177
177
|
width ||= USPSFlags::Config::BASE_FLY / scale
|
@@ -194,12 +194,31 @@ class USPSFlags::Core
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
|
197
|
+
generated_at = Time.now.strftime("%Y%m%d.%H%S%z")
|
198
|
+
|
199
|
+
svg = ""
|
200
|
+
svg << <<~SVG
|
198
201
|
<?xml version="1.0" standalone="no"?>
|
199
202
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
200
203
|
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="#{width}pt" height="#{height}pt" viewBox="0 0 #{view_width} #{view_height}" preserveAspectRatio="xMidYMid meet">
|
201
|
-
<
|
202
|
-
|
204
|
+
<title>#{title}</title>
|
205
|
+
<metadata>
|
206
|
+
<desc id="created-by">Julian Fiander</desc>
|
207
|
+
<desc id="generated-at">#{generated_at}</desc>
|
208
|
+
SVG
|
209
|
+
|
210
|
+
unless title == "US Ensign"
|
211
|
+
svg << <<~SVG
|
212
|
+
<desc id="trademark-desc">This image is a registered trademark of United States Power Squadrons.</desc>
|
213
|
+
<desc id="trademark-link">http://www.usps.org/national/itcom/trademark.html</desc>
|
214
|
+
SVG
|
215
|
+
end
|
216
|
+
|
217
|
+
svg << <<~SVG
|
218
|
+
</metadata>
|
219
|
+
SVG
|
220
|
+
|
221
|
+
svg
|
203
222
|
end
|
204
223
|
|
205
224
|
def self.footer
|
data/lib/usps_flags/generate.rb
CHANGED
@@ -8,7 +8,7 @@ class USPSFlags::Generate
|
|
8
8
|
# @param [String] scale The image scale divisor factor.
|
9
9
|
# @return [String] Returns the SVG data.
|
10
10
|
def self.get(flag, outfile: nil, scale: nil, field: true)
|
11
|
-
flag = flag.upcase
|
11
|
+
flag = flag.upcase.gsub("/", "").gsub("_", "").gsub("PENNANT", "")
|
12
12
|
if ["CRUISE", "OIC"].include?(flag)
|
13
13
|
self.pennant(type: flag, outfile: outfile, scale: scale)
|
14
14
|
elsif flag.upcase == "ENSIGN"
|
@@ -219,7 +219,7 @@ class USPSFlags::Generate
|
|
219
219
|
def self.spec(outfile: nil, fly: nil, unit: nil, scale: nil)
|
220
220
|
fly = fly.nil? ? USPSFlags::Config::BASE_FLY : fly
|
221
221
|
final_svg = ""
|
222
|
-
final_svg << USPSFlags::Core.headers(scale: scale)
|
222
|
+
final_svg << USPSFlags::Core.headers(scale: scale, title: "USPS Trident Specifications")
|
223
223
|
final_svg << USPSFlags::Core.trident_spec(fly: fly, unit: unit)
|
224
224
|
final_svg << USPSFlags::Core.footer
|
225
225
|
|
@@ -238,7 +238,7 @@ class USPSFlags::Generate
|
|
238
238
|
raise "Error: No rank specified." if rank.nil?
|
239
239
|
final_svg = ""
|
240
240
|
|
241
|
-
final_svg << USPSFlags::Core.headers(scale: scale)
|
241
|
+
final_svg << USPSFlags::Core.headers(scale: scale, title: rank)
|
242
242
|
|
243
243
|
rank.slice!(0) if !field && rank[0].upcase == "P" && rank != "PORTCAP"
|
244
244
|
rank = "CDR" if rank == "C"
|
@@ -475,7 +475,13 @@ class USPSFlags::Generate
|
|
475
475
|
|
476
476
|
def self.pennant(type: "cruise", outfile: nil, scale: nil)
|
477
477
|
final_svg = ""
|
478
|
-
|
478
|
+
title = case type.upcase
|
479
|
+
when "CRUISE"
|
480
|
+
"Cruise Pennant"
|
481
|
+
when "OIC"
|
482
|
+
"Officer-in-Charge Pennant"
|
483
|
+
end
|
484
|
+
final_svg << USPSFlags::Core.headers(pennant: true, scale: scale, title: title)
|
479
485
|
final_svg << USPSFlags::Core.pennant(type)
|
480
486
|
final_svg << USPSFlags::Core.footer
|
481
487
|
|
@@ -491,7 +497,7 @@ class USPSFlags::Generate
|
|
491
497
|
|
492
498
|
def self.ensign(outfile: nil, scale: nil)
|
493
499
|
final_svg = ""
|
494
|
-
final_svg << USPSFlags::Core.headers(scale: scale)
|
500
|
+
final_svg << USPSFlags::Core.headers(scale: scale, title: "USPS Ensign")
|
495
501
|
final_svg << USPSFlags::Core.ensign
|
496
502
|
final_svg << USPSFlags::Core.footer
|
497
503
|
|
@@ -509,7 +515,7 @@ class USPSFlags::Generate
|
|
509
515
|
width = 4327.4667
|
510
516
|
height = 4286.9333
|
511
517
|
final_svg = ""
|
512
|
-
final_svg << USPSFlags::Core.headers(width: width, height: height, scale: scale)
|
518
|
+
final_svg << USPSFlags::Core.headers(width: width, height: height, scale: scale, title: "USPS Ensign Wheel")
|
513
519
|
final_svg << USPSFlags::Core.wheel
|
514
520
|
final_svg << USPSFlags::Core.footer
|
515
521
|
|
@@ -529,7 +535,7 @@ class USPSFlags::Generate
|
|
529
535
|
hoist = scale.nil? ? base_hoist : (base_hoist / scale)
|
530
536
|
fly = hoist * 1.91
|
531
537
|
final_svg = ""
|
532
|
-
final_svg << USPSFlags::Core.headers(width: fly, height: hoist, scale: scale)
|
538
|
+
final_svg << USPSFlags::Core.headers(width: fly, height: hoist, scale: scale, title: "US Ensign")
|
533
539
|
final_svg << USPSFlags::Core.us
|
534
540
|
final_svg << USPSFlags::Core.footer
|
535
541
|
|
data/spec/usps_flags_spec.rb
CHANGED
@@ -41,12 +41,24 @@ describe USPSFlags do
|
|
41
41
|
@flag.scale 5
|
42
42
|
@flag.svg_file ""
|
43
43
|
|
44
|
-
|
44
|
+
svg = @flag.svg
|
45
|
+
|
46
|
+
expect(svg).to include(
|
45
47
|
<<~SVG
|
46
48
|
<?xml version="1.0" standalone="no"?>
|
47
49
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
48
50
|
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="614pt" height="409pt" viewBox="0 0 3072 2048" preserveAspectRatio="xMidYMid meet">
|
49
|
-
<
|
51
|
+
<title>CDR</title>
|
52
|
+
<metadata>
|
53
|
+
<desc id="created-by">Julian Fiander</desc>
|
54
|
+
SVG
|
55
|
+
)
|
56
|
+
|
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>
|
50
62
|
<g transform="translate(-768, 192)">
|
51
63
|
<path d="M 1536 512
|
52
64
|
l 80 136
|
data/usps_flags.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'usps_flags'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.19'
|
4
4
|
s.date = '2017-10-18'
|
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.'
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|