usps_flags 0.5.9 → 0.6.0
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
- data/Gemfile.lock +2 -2
- data/lib/usps_flags/core/tridents.rb +53 -13
- data/lib/usps_flags/helpers.rb +1 -0
- data/spec/usps_flags/core_spec.rb +3 -3
- data/spec/usps_flags/generate_spec.rb +3 -3
- data/spec/usps_flags/helpers_spec.rb +1 -1
- data/spec/usps_flags_spec.rb +1 -1
- data/usps_flags.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 834c5fd9b07cda04e1abbb43ce057be5bcb75a2338c4c9c9b30bf90e873c70a3
|
4
|
+
data.tar.gz: 2c1967a3acab412d00a70d2b7b529494128daf71c99c9484f8fd5dc51edade5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79d043fc636b58a3bc1181716b9a21fb2fe64b552b6e376035b096ea97682aa2d36bb24896ae711b86baef52779c457dadabf17b364cc23500cb1edb1d802145
|
7
|
+
data.tar.gz: 3eef4c97b191637097e01444658635882cb1b4552c2705543b6c0c77e4c5923a211430d1026f9a202d6f637a101128df6224ef5f90e0be070d4b0efa64554ab4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
usps_flags (0.
|
4
|
+
usps_flags (0.6.0)
|
5
5
|
file_utils (~> 1.1, >= 1.1.2)
|
6
6
|
mini_magick (~> 4.9, >= 4.9.4)
|
7
7
|
rubyzip (~> 1.3, >= 1.3.0)
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
file_utils (1.1.2)
|
16
16
|
jaro_winkler (1.5.4)
|
17
17
|
json (2.1.0)
|
18
|
-
mini_magick (4.
|
18
|
+
mini_magick (4.10.1)
|
19
19
|
parallel (1.19.1)
|
20
20
|
parser (2.6.5.0)
|
21
21
|
ast (~> 2.4.0)
|
@@ -8,30 +8,47 @@ class USPSFlags
|
|
8
8
|
class Core
|
9
9
|
class Tridents
|
10
10
|
class << self
|
11
|
+
# The side C/C tridents are angled 45 degrees, and intersect the central one at 1/3 up from the bottom
|
12
|
+
#
|
13
|
+
# Note: translate(132, 130) corrects the center of rotation for each angled trident due to the (transparent)
|
14
|
+
# field size of the include trident SVG
|
15
|
+
#
|
16
|
+
# Center of rotation:
|
17
|
+
# # radius = USPSFlags.configuration.trident[:bar_width] / 2
|
18
|
+
# <circle cx="#{cc_center[:x]}" cy="#{cc_center[:y]}" r="#{radius}" fill="red" />
|
11
19
|
def cc(type, trident_color:)
|
12
|
-
# The side C/C tridents are angled 45 degrees, and intersect the central one at 1/3 up from the bottom
|
13
20
|
trident = USPSFlags::Core.trident(type, color: trident_color)
|
14
|
-
x_distance = USPSFlags::Config::BASE_FLY * 4 / 39
|
15
|
-
y_distance = USPSFlags::Config::BASE_FLY * 5 / 78
|
16
21
|
<<~SVG
|
17
|
-
<g transform="translate(
|
18
|
-
|
19
|
-
|
22
|
+
<g transform="translate(132, 130)">
|
23
|
+
<g transform="rotate(-45, #{cc_center[:x]}, #{cc_center[:y]})">
|
24
|
+
#{trident}
|
25
|
+
</g>
|
26
|
+
<g transform="rotate(45, #{cc_center[:x]}, #{cc_center[:y]})">
|
27
|
+
#{trident}
|
28
|
+
</g>
|
29
|
+
</g>
|
30
|
+
#{trident}
|
20
31
|
SVG
|
21
32
|
end
|
22
33
|
|
34
|
+
# V/C tridents are angled 45 degrees, and intersect at 15/32 up from the bottom
|
35
|
+
#
|
36
|
+
# Note: translate(132, 50) corrects the center of rotation for each angled trident due to the (transparent)
|
37
|
+
# field size of the include trident SVG
|
23
38
|
def vc(type, trident_color:)
|
24
|
-
# V/C tridents are angled 45 degrees, and intersect at 15/32 up from the bottom
|
25
39
|
trident = USPSFlags::Core.trident(type, color: trident_color)
|
26
|
-
x_distance = USPSFlags::Config::BASE_FLY * 4 / 55
|
27
40
|
<<~SVG
|
28
|
-
<g transform="translate(
|
29
|
-
|
41
|
+
<g transform="translate(132, 50) rotate(-45, #{vc_center[:x]}, #{vc_center[:y]})">
|
42
|
+
#{trident}
|
43
|
+
</g>
|
44
|
+
<g transform="translate(132, 50) rotate(45, #{vc_center[:x]}, #{vc_center[:y]})">
|
45
|
+
#{trident}
|
46
|
+
</g>
|
30
47
|
SVG
|
31
48
|
end
|
32
49
|
|
50
|
+
# Cdr and D/C tridents are spaced 1/2 the fly apart with the central one 1/4 the fly above the sides
|
33
51
|
def three(type, trident_color:, field_color:)
|
34
|
-
# Cdr and D/C tridents are spaced 1/2 the fly apart with the central one 1/4 the fly above the sides
|
35
52
|
trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
|
36
53
|
x_distance = USPSFlags::Config::BASE_FLY / 4
|
37
54
|
y_distance = USPSFlags::Config::BASE_FLY / 16
|
@@ -42,8 +59,8 @@ class USPSFlags
|
|
42
59
|
SVG
|
43
60
|
end
|
44
61
|
|
62
|
+
# Lt/C and D/Lt/C tridents are spaced 1/3 the fly apart
|
45
63
|
def two(type, trident_color:, field_color:)
|
46
|
-
# Lt/C and D/Lt/C tridents are spaced 1/3 the fly apart
|
47
64
|
trident = USPSFlags::Core.trident(type, color: trident_color, field_color: field_color)
|
48
65
|
x_distance = USPSFlags::Config::BASE_FLY / 6
|
49
66
|
<<~SVG
|
@@ -52,8 +69,8 @@ class USPSFlags
|
|
52
69
|
SVG
|
53
70
|
end
|
54
71
|
|
72
|
+
# Swallowtail tridents need to move towards the hoist due to the tails
|
55
73
|
def offset(type, field_color:, field: true)
|
56
|
-
# Swallowtail tridents need to move towards the hoist due to the tails
|
57
74
|
x_distance = USPSFlags::Config::BASE_FLY / 10 if field
|
58
75
|
svg = +''
|
59
76
|
svg << "<g transform=\"translate(-#{x_distance})\">" if field
|
@@ -61,6 +78,29 @@ class USPSFlags
|
|
61
78
|
svg << '</g>' if field
|
62
79
|
svg
|
63
80
|
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def rotation_center(height_fraction)
|
85
|
+
{
|
86
|
+
x: USPSFlags::Config::BASE_FLY / 2,
|
87
|
+
y: (USPSFlags::Config::BASE_HOIST * 7 / 8) - (n_staff_height * height_fraction)
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
def cc_center
|
92
|
+
rotation_center(Rational(1, 3))
|
93
|
+
end
|
94
|
+
|
95
|
+
def vc_center
|
96
|
+
rotation_center(Rational(15, 32))
|
97
|
+
end
|
98
|
+
|
99
|
+
def n_staff_height
|
100
|
+
top_height = USPSFlags.configuration.trident[:crossbar_from_top]
|
101
|
+
bars = (USPSFlags.configuration.trident[:bar_width] * 3)
|
102
|
+
USPSFlags.configuration.trident_heights[:n] - top_height - bars
|
103
|
+
end
|
64
104
|
end
|
65
105
|
end
|
66
106
|
end
|
data/lib/usps_flags/helpers.rb
CHANGED
@@ -42,7 +42,7 @@ describe USPSFlags::Core do
|
|
42
42
|
l #{@fly} 0
|
43
43
|
l 0 #{@hoist}
|
44
44
|
l -#{@fly} 0
|
45
|
-
l 0 -#{@hoist}
|
45
|
+
l 0 -#{@hoist} z
|
46
46
|
" fill="#FFFFFF" stroke="#000000" stroke-width="#{USPSFlags::Config::BASE_FLY / 600}" />
|
47
47
|
SVG
|
48
48
|
)
|
@@ -55,7 +55,7 @@ describe USPSFlags::Core do
|
|
55
55
|
l #{@fly} 0
|
56
56
|
l 0 #{@hoist}
|
57
57
|
l -#{@fly} 0
|
58
|
-
l 0 -#{@hoist}
|
58
|
+
l 0 -#{@hoist} z
|
59
59
|
" fill="#{@red}" />
|
60
60
|
SVG
|
61
61
|
)
|
@@ -78,7 +78,7 @@ describe USPSFlags::Core do
|
|
78
78
|
expect(described_class.field(style: :past, color: :blue)).to eql(
|
79
79
|
<<~SVG
|
80
80
|
<g transform="translate(2, 1)">
|
81
|
-
<path d="M 0
|
81
|
+
<path d="M 0 2 l #{@fly / 2} #{@hoist * 1 / 12}
|
82
82
|
l 0 #{@hoist * 10 / 12}
|
83
83
|
l -#{@fly / 2} #{@hoist * 1 / 12}
|
84
84
|
" fill="#{@blue}" />
|
@@ -6,7 +6,7 @@ describe USPSFlags::Generate do
|
|
6
6
|
describe 'general features' do
|
7
7
|
it 'generates a flag with the correct size' do
|
8
8
|
expect(described_class.svg('LtC', outfile: '')).to include(
|
9
|
-
'width="1024" height="682" viewBox="
|
9
|
+
'width="1024" height="682" viewBox="-3.072 -4.096 3084.288 2058.24"'
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
@@ -17,7 +17,7 @@ describe USPSFlags::Generate do
|
|
17
17
|
l 3072 0
|
18
18
|
l 0 2048
|
19
19
|
l -3072 0
|
20
|
-
l 0 -2048
|
20
|
+
l 0 -2048 z
|
21
21
|
" fill="#E4002B" />
|
22
22
|
SVG
|
23
23
|
)
|
@@ -40,7 +40,7 @@ describe USPSFlags::Generate do
|
|
40
40
|
|
41
41
|
describe 'officer flags' do
|
42
42
|
%w[
|
43
|
-
PLTC PC PDLTC PDC PSTFC PRC PVC PCC
|
43
|
+
PLTC PC PDLTC PDC PNFLT PSTFC PRC PVC PCC
|
44
44
|
PORTCAP FLEETCAP FLT DAIDE DFLT NAIDE NFLT
|
45
45
|
LT 1LT LTC CDR DLT D1LT DLTC DC STFC RC VC CC
|
46
46
|
].each do |flag|
|
@@ -11,7 +11,7 @@ describe USPSFlags::Helpers do
|
|
11
11
|
it 'returns all officer flags but nothing else when given type :officer' do
|
12
12
|
expect(described_class.valid_flags(:officer).sort).to eql(%w[
|
13
13
|
PLTC PC PORTCAP FLEETCAP LT FLT 1LT LTC CDR PDLTC PDC DLT DAIDE
|
14
|
-
DFLT D1LT DLTC DC PSTFC PRC PVC PCC NAIDE NFLT STFC RC VC CC
|
14
|
+
DFLT D1LT DLTC DC PNFLT PSTFC PRC PVC PCC NAIDE NFLT STFC RC VC CC
|
15
15
|
].sort)
|
16
16
|
end
|
17
17
|
|
data/spec/usps_flags_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe USPSFlags do
|
|
7
7
|
@valid_header = <<~SVG
|
8
8
|
<?xml version="1.0" standalone="no"?>
|
9
9
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
10
|
-
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="614" height="409" viewBox="
|
10
|
+
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="614" height="409" viewBox="-3.072 -4.096 3084.288 2058.24" preserveAspectRatio="xMidYMid meet">
|
11
11
|
<title>LTC</title>
|
12
12
|
<metadata>
|
13
13
|
<desc id="created-by">Julian Fiander</desc>
|
data/usps_flags.gemspec
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'usps_flags'
|
5
|
-
s.version = '0.
|
6
|
-
s.date = '
|
5
|
+
s.version = '0.6.0'
|
6
|
+
s.date = '2020-02-17'
|
7
7
|
s.summary = 'Flag generator for United States Power Squadrons'
|
8
8
|
s.description = 'A flag image (PNG, SVG) generator for United States Power Squadrons.'
|
9
9
|
s.homepage = 'http://rubygems.org/gems/usps_flags'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usps_flags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Fiander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: file_utils
|