usps_flags 0.1.25 → 0.1.26
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/.travis.yml +4 -0
- data/CONTRIBUTING.md +2 -2
- data/Gemfile.lock +1 -1
- data/lib/usps_flags/generate.rb +327 -404
- data/lib/usps_flags/helpers.rb +330 -249
- data/usps_flags.gemspec +2 -2
- data.tar.gz.sig +3 -2
- metadata +2 -2
- metadata.gz.sig +0 -0
data/lib/usps_flags/helpers.rb
CHANGED
|
@@ -1,276 +1,357 @@
|
|
|
1
1
|
# Container class for helper methods.
|
|
2
2
|
class USPSFlags::Helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
PLTC
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
squadron_swallowtail = %w[
|
|
28
|
-
PORTCAP
|
|
29
|
-
FLEETCAP
|
|
30
|
-
LT
|
|
31
|
-
FLT
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
district_past = %w[
|
|
35
|
-
PDLTC
|
|
36
|
-
PDC
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
district_elected = %w[
|
|
40
|
-
D1LT
|
|
41
|
-
DLTC
|
|
42
|
-
DC
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
district_swallowtail = %w[
|
|
46
|
-
DLT
|
|
47
|
-
DAIDE
|
|
48
|
-
DFLT
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
national_past = %w[
|
|
52
|
-
PSTFC
|
|
53
|
-
PRC
|
|
54
|
-
PVC
|
|
55
|
-
PCC
|
|
56
|
-
]
|
|
57
|
-
|
|
58
|
-
national_elected = %w[
|
|
59
|
-
NAIDE
|
|
60
|
-
NFLT
|
|
61
|
-
STFC
|
|
62
|
-
RC
|
|
63
|
-
VC
|
|
64
|
-
CC
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
special = %w[
|
|
68
|
-
CRUISE
|
|
69
|
-
OIC
|
|
70
|
-
ENSIGN
|
|
71
|
-
WHEEL
|
|
72
|
-
]
|
|
73
|
-
|
|
74
|
-
us = %w[
|
|
75
|
-
US
|
|
76
|
-
]
|
|
77
|
-
|
|
78
|
-
squadron = squadron_past + squadron_elected + squadron_swallowtail
|
|
79
|
-
district = district_past + district_elected + district_swallowtail
|
|
80
|
-
national = national_past + national_elected
|
|
81
|
-
past = squadron_past + district_past + national_past
|
|
82
|
-
|
|
83
|
-
case type
|
|
84
|
-
when :all
|
|
85
|
-
squadron + district + national + special + us
|
|
86
|
-
when :officer
|
|
87
|
-
squadron + district + national
|
|
88
|
-
when :insignia
|
|
89
|
-
squadron + district + national - past
|
|
90
|
-
when :squadron
|
|
91
|
-
squadron
|
|
92
|
-
when :district
|
|
93
|
-
district
|
|
94
|
-
when :national
|
|
95
|
-
national
|
|
96
|
-
when :special
|
|
97
|
-
special
|
|
98
|
-
when :us
|
|
99
|
-
us
|
|
100
|
-
when :past
|
|
101
|
-
past
|
|
102
|
-
when :swallowtail
|
|
103
|
-
past + squadron_swallowtail + district_swallowtail
|
|
104
|
-
when :bridge
|
|
105
|
-
squadron_elected.last(2) + squadron_past.last(2) +
|
|
106
|
-
district_elected.last(2) + district_past.last(2) +
|
|
107
|
-
national_elected.last(2) + national_past.last(2)
|
|
108
|
-
when :command
|
|
109
|
-
[squadron_elected.last, squadron_past.last,
|
|
110
|
-
district_elected.last, district_past.last,
|
|
111
|
-
national_elected.last, national_past.last]
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# Displays an overlay grid with regularly spaced locator markers.
|
|
116
|
-
#
|
|
117
|
-
# This is useful for adjusting or creating new SVG data generators, but should not otherwise need to be called.
|
|
118
|
-
# @private
|
|
119
|
-
def self.grid(width: USPSFlags::Config::BASE_FLY, height: USPSFlags::Config::BASE_HOIST)
|
|
120
|
-
<<~SVG
|
|
121
|
-
<circle cx="0" cy="0" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
|
|
122
|
-
<circle cx="#{width}" cy="0" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
|
|
123
|
-
<circle cx="#{width}" cy="#{height}" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
|
|
124
|
-
<circle cx="0" cy="#{height}" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
|
|
125
|
-
|
|
126
|
-
<circle cx="#{width*1/4}" cy="#{height/2}" r="#{width/60}" fill="#999999" fill-opacity="0.4" />
|
|
127
|
-
<circle cx="#{width*3/4}" cy="#{height/2}" r="#{width/60}" fill="#999999" fill-opacity="0.4" />
|
|
128
|
-
|
|
129
|
-
<circle cx="#{width/2}" cy="#{height*1/4}" r="#{width/60}" fill="#999999" fill-opacity="0.4" />
|
|
130
|
-
<circle cx="#{width/2}" cy="#{height/2}" r="#{width/60}" fill="#000000" fill-opacity="0.4" />
|
|
131
|
-
<circle cx="#{width/2}" cy="#{height/2}" r="#{width/75}" fill="#CCCCCC" fill-opacity="0.4" />
|
|
132
|
-
<circle cx="#{width/2}" cy="#{height/2}" r="#{width/100}" fill="#000000" fill-opacity="0.4" />
|
|
133
|
-
<circle cx="#{width/2}" cy="#{height*3/4}" r="#{width/60}" fill="#999999" fill-opacity="0.4" />
|
|
134
|
-
|
|
135
|
-
<line x1="0" y1="0" x2="#{width}" y2="0" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
136
|
-
<line x1="0" y1="#{height*1/4}" x2="#{width}" y2="#{height*1/4}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
137
|
-
<line x1="0" y1="#{height/2}" x2="#{width}" y2="#{height/2}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
138
|
-
<line x1="0" y1="#{height*3/4}" x2="#{width}" y2="#{height*3/4}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
139
|
-
<line x1="0" y1="#{height}" x2="#{width}" y2="#{height}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
140
|
-
|
|
141
|
-
<line y1="0" x1="0" y2="#{height}" x2="0" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
142
|
-
<line y1="0" x1="#{width*1/6}" y2="#{height}" x2="#{width*1/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
143
|
-
<line y1="0" x1="#{width*2/6}" y2="#{height}" x2="#{width*2/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
144
|
-
<line y1="0" x1="#{width*3/6}" y2="#{height}" x2="#{width*3/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
145
|
-
<line y1="0" x1="#{width*4/6}" y2="#{height}" x2="#{width*4/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
146
|
-
<line y1="0" x1="#{width*5/6}" y2="#{height}" x2="#{width*5/6}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
147
|
-
<line y1="0" x1="#{width}" y2="#{height}" x2="#{width}" stroke="#333333" stroke-width="#{width/600}" stroke-opacity="0.5" />
|
|
148
|
-
|
|
149
|
-
<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" />
|
|
150
|
-
<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" />
|
|
151
|
-
<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" />
|
|
152
|
-
<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" />
|
|
153
|
-
|
|
154
|
-
SVG
|
|
155
|
-
end
|
|
3
|
+
class << self
|
|
4
|
+
# Valid options for flag generation.
|
|
5
|
+
#
|
|
6
|
+
# @param [Symbol] type Specify subset of flags.
|
|
7
|
+
# @option type [Symbol] :all All flags
|
|
8
|
+
# @option type [Symbol] :officer Officer flags
|
|
9
|
+
# @option type [Symbol] :insignia Insignia-eligible officer flags (no past officers)
|
|
10
|
+
# @option type [Symbol] :squadron Squadron-level officer flags
|
|
11
|
+
# @option type [Symbol] :district District-level officer flags
|
|
12
|
+
# @option type [Symbol] :national National-level officer flags
|
|
13
|
+
# @option type [Symbol] :special Special flags
|
|
14
|
+
# @option type [Symbol] :us US flag
|
|
15
|
+
# @return [Array] Valid options for flag generation (based on the provided type).
|
|
16
|
+
def valid_flags(type = :all)
|
|
17
|
+
squadron_past = %w[PLTC PC]
|
|
18
|
+
squadron_elected = %w[1LT LTC CDR]
|
|
19
|
+
squadron_swallowtail = %w[PORTCAP FLEETCAP LT FLT]
|
|
20
|
+
district_past = %w[PDLTC PDC]
|
|
21
|
+
district_elected = %w[D1LT DLTC DC]
|
|
22
|
+
district_swallowtail = %w[DLT DAIDE DFLT]
|
|
23
|
+
national_past = %w[PSTFC PRC PVC PCC]
|
|
24
|
+
national_elected = %w[NAIDE NFLT STFC RC VC CC]
|
|
25
|
+
special = %w[CRUISE OIC ENSIGN WHEEL]
|
|
26
|
+
us = %w[US]
|
|
156
27
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
def self.locator
|
|
162
|
-
<<~SVG
|
|
163
|
-
<circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY*2}" fill="#000000" fill-opacity="0.4" />
|
|
164
|
-
<circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY}" fill="#333333" fill-opacity="0.4" />
|
|
165
|
-
<circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY/2}" fill="#666666" fill-opacity="0.4" />
|
|
166
|
-
<circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY/4}" fill="#999999" fill-opacity="0.4" />
|
|
167
|
-
<circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY/8}" fill="#CCCCCC" fill-opacity="0.4" />
|
|
168
|
-
<circle cx="0" cy="0" r="#{USPSFlags::Config::BASE_FLY/16}" fill="#FFFFFF" fill-opacity="0.4" />
|
|
169
|
-
|
|
170
|
-
<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}" />
|
|
171
|
-
<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}" />
|
|
172
|
-
<line x1="0" y1="#{USPSFlags::Config::BASE_HOIST}" x2="0" y2="-#{USPSFlags::Config::BASE_HOIST}" stroke="#FFFFFF" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" />
|
|
173
|
-
<line x1="-#{USPSFlags::Config::BASE_FLY}" y1="0" x2="#{USPSFlags::Config::BASE_FLY}" y2="0" stroke="#FFFFFF" stroke-width="#{USPSFlags::Config::BASE_FLY/600}" />
|
|
174
|
-
|
|
175
|
-
<rect x="0" y="0" width="#{USPSFlags::Config::BASE_FLY/30}" height="#{USPSFlags::Config::BASE_FLY/30}" fill="#333333" fill-opacity="0.6" />
|
|
176
|
-
SVG
|
|
177
|
-
end
|
|
28
|
+
squadron = squadron_past + squadron_elected + squadron_swallowtail
|
|
29
|
+
district = district_past + district_elected + district_swallowtail
|
|
30
|
+
national = national_past + national_elected
|
|
31
|
+
past = squadron_past + district_past + national_past
|
|
178
32
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
33
|
+
case type
|
|
34
|
+
when :all
|
|
35
|
+
squadron + district + national + special + us
|
|
36
|
+
when :officer
|
|
37
|
+
squadron + district + national
|
|
38
|
+
when :insignia
|
|
39
|
+
squadron + district + national - past
|
|
40
|
+
when :squadron
|
|
41
|
+
squadron
|
|
42
|
+
when :district
|
|
43
|
+
district
|
|
44
|
+
when :national
|
|
45
|
+
national
|
|
46
|
+
when :special
|
|
47
|
+
special
|
|
48
|
+
when :us
|
|
49
|
+
us
|
|
50
|
+
when :past
|
|
51
|
+
past
|
|
52
|
+
when :swallowtail
|
|
53
|
+
past + squadron_swallowtail + district_swallowtail
|
|
54
|
+
when :bridge
|
|
55
|
+
squadron_elected.last(2) + squadron_past.last(2) +
|
|
56
|
+
district_elected.last(2) + district_past.last(2) +
|
|
57
|
+
national_elected.last(2) + national_past.last(2)
|
|
58
|
+
when :command
|
|
59
|
+
[squadron_elected.last, squadron_past.last,
|
|
60
|
+
district_elected.last, district_past.last,
|
|
61
|
+
national_elected.last, national_past.last]
|
|
62
|
+
end
|
|
192
63
|
end
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
64
|
+
|
|
65
|
+
# Gets the generation details for the given rank.
|
|
66
|
+
#
|
|
67
|
+
# This is used USPSFlags::Generate, and should never need to be called directly.
|
|
68
|
+
# @private
|
|
69
|
+
def flag_details(rank)
|
|
70
|
+
{
|
|
71
|
+
style: flag_style(rank),
|
|
72
|
+
color: flag_color(rank),
|
|
73
|
+
type: flag_type(rank),
|
|
74
|
+
level: flag_level(rank),
|
|
75
|
+
count: flag_count(rank)
|
|
76
|
+
}
|
|
198
77
|
end
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
78
|
+
|
|
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
|
+
|
|
202
118
|
SVG
|
|
203
119
|
end
|
|
204
120
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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" />
|
|
212
133
|
|
|
213
|
-
|
|
214
|
-
|
|
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}" />
|
|
215
138
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
# This is used USPSFlags::Core.trident_spec, and should never need to be called directly.
|
|
219
|
-
# @private
|
|
220
|
-
def self.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)
|
|
221
|
-
label = right - left if label.nil?
|
|
222
|
-
label = label.to_i if label - label.to_i == 0
|
|
223
|
-
label = Rational(label) * fly / USPSFlags::Config::BASE_FLY
|
|
224
|
-
if label == label.to_i
|
|
225
|
-
label = label.to_i
|
|
226
|
-
label_fraction = ""
|
|
227
|
-
else
|
|
228
|
-
label, label_fraction = label.to_simplified_a
|
|
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
|
|
229
141
|
end
|
|
230
|
-
|
|
231
|
-
|
|
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
|
+
|
|
232
169
|
svg << <<~SVG
|
|
233
|
-
<
|
|
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>
|
|
234
175
|
SVG
|
|
176
|
+
|
|
177
|
+
svg
|
|
235
178
|
end
|
|
236
|
-
|
|
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
|
+
|
|
237
206
|
svg << <<~SVG
|
|
238
|
-
<
|
|
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>
|
|
239
212
|
SVG
|
|
213
|
+
|
|
214
|
+
svg
|
|
240
215
|
end
|
|
241
216
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
217
|
+
# Resizes and saves a PNG image.
|
|
218
|
+
#
|
|
219
|
+
# This is used USPSFlags::Generate, and should never need to be called directly.
|
|
220
|
+
# @private
|
|
221
|
+
def resize_png(png_ins_file, flag:, size:, size_key:)
|
|
222
|
+
MiniMagick::Tool::Convert.new do |convert|
|
|
223
|
+
convert << "-background" << "none"
|
|
224
|
+
convert << "-format" << "png"
|
|
225
|
+
convert << "-resize" << "#{size}"
|
|
226
|
+
convert << png_ins_file
|
|
227
|
+
convert << "#{USPSFlags::Config.flags_dir}/PNG/insignia/#{flag}.#{size_key}.png"
|
|
228
|
+
end
|
|
229
|
+
end
|
|
249
230
|
|
|
250
|
-
|
|
251
|
-
|
|
231
|
+
# Image sizes for generated PNG images.
|
|
232
|
+
#
|
|
233
|
+
# This is used USPSFlags::Generate, and should never need to be called directly.
|
|
234
|
+
# @private
|
|
235
|
+
def png_sizes
|
|
236
|
+
{1500 => "H", 1000 => "K", 500 => "D", "thumb" => "T"}
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Gets size key for saving PNG images.
|
|
240
|
+
#
|
|
241
|
+
# This is used USPSFlags::Generate, and should never need to be called directly.
|
|
242
|
+
# @private
|
|
243
|
+
def size_and_key(size:, flag:)
|
|
244
|
+
return [size, size] unless size == "thumb"
|
|
245
|
+
|
|
246
|
+
size = case flag
|
|
247
|
+
when "ENSIGN"
|
|
248
|
+
200
|
|
249
|
+
when "US"
|
|
250
|
+
300
|
|
251
|
+
else
|
|
252
|
+
150
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
[size, "thumb"]
|
|
256
|
+
end
|
|
252
257
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
258
|
+
# Prints message(s) to the console and logs them.
|
|
259
|
+
#
|
|
260
|
+
# This should never need to be called directly.
|
|
261
|
+
# @private
|
|
262
|
+
def log(*messages)
|
|
263
|
+
::FileUtils.mkdir_p(USPSFlags::Config.log_path)
|
|
264
|
+
outputs = [STDOUT]
|
|
265
|
+
|
|
266
|
+
begin
|
|
267
|
+
log_file = File.open("#{USPSFlags::Config.log_path}/flag.log", 'a')
|
|
268
|
+
outputs << log_file
|
|
269
|
+
rescue Errno::EACCES => e
|
|
270
|
+
puts "\nError accessing log file." unless USPSFlags::Config.log_fail_quietly
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
messages.each do |message|
|
|
274
|
+
outputs.each { |f| f.write(message) }
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
messages
|
|
278
|
+
ensure
|
|
279
|
+
log_file.close if log_file.is_a?(File)
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
private
|
|
283
|
+
def flag_style(rank)
|
|
284
|
+
if valid_flags(:past).include?(rank)
|
|
285
|
+
:past
|
|
286
|
+
elsif valid_flags(:swallowtail).include?(rank)
|
|
287
|
+
:swallowtail
|
|
288
|
+
else
|
|
289
|
+
:regular
|
|
290
|
+
end
|
|
266
291
|
end
|
|
267
292
|
|
|
268
|
-
|
|
269
|
-
|
|
293
|
+
def flag_color(rank)
|
|
294
|
+
if valid_flags(:command).include?(rank)
|
|
295
|
+
count = 3
|
|
296
|
+
:blue
|
|
297
|
+
elsif valid_flags(:bridge).include?(rank)
|
|
298
|
+
count = 2
|
|
299
|
+
:red
|
|
300
|
+
else
|
|
301
|
+
:white
|
|
302
|
+
end
|
|
270
303
|
end
|
|
271
304
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
305
|
+
def flag_level(rank)
|
|
306
|
+
if rank == "DAIDE"
|
|
307
|
+
:d
|
|
308
|
+
elsif rank == "NAIDE"
|
|
309
|
+
:n
|
|
310
|
+
elsif rank == "FLT"
|
|
311
|
+
:s
|
|
312
|
+
elsif rank == "DFLT"
|
|
313
|
+
:d
|
|
314
|
+
elsif rank == "NFLT"
|
|
315
|
+
:n
|
|
316
|
+
else
|
|
317
|
+
nil
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
def flag_count(rank)
|
|
322
|
+
if valid_flags(:command).include?(rank)
|
|
323
|
+
3
|
|
324
|
+
elsif valid_flags(:bridge).include?(rank)
|
|
325
|
+
2
|
|
326
|
+
else
|
|
327
|
+
1
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
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"
|
|
341
|
+
:pc
|
|
342
|
+
elsif rank == "FLEETCAP"
|
|
343
|
+
:fc
|
|
344
|
+
elsif rank == "DAIDE"
|
|
345
|
+
:a
|
|
346
|
+
elsif rank == "NAIDE"
|
|
347
|
+
:a
|
|
348
|
+
elsif rank == "FLT"
|
|
349
|
+
:f
|
|
350
|
+
elsif rank == "DFLT"
|
|
351
|
+
:f
|
|
352
|
+
elsif rank == "NFLT"
|
|
353
|
+
:f
|
|
354
|
+
end
|
|
355
|
+
end
|
|
275
356
|
end
|
|
276
357
|
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.
|
|
4
|
-
s.date = '2017-
|
|
3
|
+
s.version = '0.1.26'
|
|
4
|
+
s.date = '2017-11-02'
|
|
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
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
4��i����b��~f�g�z�HjA
|
|
2
|
+
�'䤚�q0��{�j˖�,��ϳS_�yn���&Iq�Y�)����Ix숐M���)o}$6g�%����#��
|
|
3
|
+
C��+4�}Vq=�����e
|
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.
|
|
4
|
+
version: 0.1.26
|
|
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-
|
|
33
|
+
date: 2017-11-02 00:00:00.000000000 Z
|
|
34
34
|
dependencies:
|
|
35
35
|
- !ruby/object:Gem::Dependency
|
|
36
36
|
name: file_utils
|
metadata.gz.sig
CHANGED
|
Binary file
|