usps_flags 0.5.0 → 0.5.1
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/.rubocop.yml +22 -11
- data/.travis.yml +1 -1
- data/Gemfile.lock +5 -2
- data/README.md +6 -0
- data/lib/usps_flags.rb +35 -44
- data/lib/usps_flags/config.rb +89 -87
- data/lib/usps_flags/core.rb +44 -42
- data/lib/usps_flags/core/ensign.rb +53 -49
- data/lib/usps_flags/core/field.rb +96 -92
- data/lib/usps_flags/core/footer.rb +9 -5
- data/lib/usps_flags/core/headers.rb +58 -48
- data/lib/usps_flags/core/icons.rb +11 -7
- data/lib/usps_flags/core/icons/anchor.rb +62 -56
- data/lib/usps_flags/core/icons/binoculars.rb +21 -15
- data/lib/usps_flags/core/icons/lighthouse.rb +28 -22
- data/lib/usps_flags/core/icons/star.rb +21 -15
- data/lib/usps_flags/core/icons/trident.rb +136 -127
- data/lib/usps_flags/core/icons/trident_parts/hashes.rb +62 -55
- data/lib/usps_flags/core/icons/trumpet.rb +34 -28
- data/lib/usps_flags/core/pennant.rb +50 -46
- data/lib/usps_flags/core/trident_spec.rb +135 -131
- data/lib/usps_flags/core/trident_specs.rb +11 -7
- data/lib/usps_flags/core/trident_specs/base.rb +36 -26
- data/lib/usps_flags/core/trident_specs/circle.rb +36 -30
- data/lib/usps_flags/core/trident_specs/delta.rb +41 -30
- data/lib/usps_flags/core/trident_specs/header.rb +56 -50
- data/lib/usps_flags/core/trident_specs/horizontal.rb +80 -0
- data/lib/usps_flags/core/trident_specs/long.rb +41 -25
- data/lib/usps_flags/core/trident_specs/overlay.rb +40 -0
- data/lib/usps_flags/core/trident_specs/short.rb +30 -156
- data/lib/usps_flags/core/trident_specs/vertical.rb +108 -0
- data/lib/usps_flags/core/tridents.rb +54 -50
- data/lib/usps_flags/core/us.rb +40 -44
- data/lib/usps_flags/core/wheel.rb +7 -3
- data/lib/usps_flags/errors.rb +25 -23
- data/lib/usps_flags/generate.rb +111 -107
- data/lib/usps_flags/generate/flag.rb +160 -157
- data/lib/usps_flags/generate/generator_methods.rb +139 -0
- data/lib/usps_flags/generate/helper_methods.rb +88 -0
- data/lib/usps_flags/helpers.rb +163 -165
- data/lib/usps_flags/helpers/builders.rb +92 -85
- data/lib/usps_flags/helpers/spec_arrows.rb +127 -123
- data/lib/usps_flags/helpers/valid_flags.rb +45 -41
- data/lib/usps_flags/rational.rb +35 -0
- data/spec/usps_flags/config_spec.rb +17 -10
- data/spec/usps_flags/core_spec.rb +31 -31
- data/spec/usps_flags/generate_spec.rb +76 -73
- data/spec/usps_flags/helpers_spec.rb +8 -8
- data/spec/usps_flags/rational_spec.rb +17 -0
- data/spec/usps_flags_spec.rb +19 -21
- data/usps_flags.gemspec +7 -6
- metadata +34 -10
- data/lib/rational.rb +0 -39
- data/lib/usps_flags/generate/private.rb +0 -199
- data/spec/rational_spec.rb +0 -19
@@ -4,11 +4,15 @@
|
|
4
4
|
#
|
5
5
|
# These methods should never need to be called directly.
|
6
6
|
# @private
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
class USPSFlags
|
8
|
+
class Core
|
9
|
+
module TridentSpecs
|
10
|
+
require 'usps_flags/core/trident_specs/base'
|
11
|
+
require 'usps_flags/core/trident_specs/header'
|
12
|
+
require 'usps_flags/core/trident_specs/short'
|
13
|
+
require 'usps_flags/core/trident_specs/delta'
|
14
|
+
require 'usps_flags/core/trident_specs/long'
|
15
|
+
require 'usps_flags/core/trident_specs/circle'
|
16
|
+
end
|
17
|
+
end
|
14
18
|
end
|
@@ -4,36 +4,46 @@
|
|
4
4
|
#
|
5
5
|
# This class should never need to be called directly.
|
6
6
|
# @private
|
7
|
-
class USPSFlags
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
class USPSFlags
|
8
|
+
class Core
|
9
|
+
module TridentSpecs
|
10
|
+
class Base
|
11
|
+
require 'usps_flags/core/trident_specs/vertical'
|
12
|
+
require 'usps_flags/core/trident_specs/horizontal'
|
13
|
+
require 'usps_flags/core/trident_specs/overlay'
|
14
|
+
|
15
|
+
SA = USPSFlags::Helpers::SpecArrows
|
16
|
+
BF = USPSFlags::Config::BASE_FLY
|
17
|
+
BH = USPSFlags::Config::BASE_HOIST
|
18
|
+
|
19
|
+
def initialize(options = {})
|
20
|
+
@config = options[:config]
|
21
|
+
@box_top = options[:bt]
|
22
|
+
@box_bottom = options[:bb]
|
23
|
+
@box_left = options[:bl]
|
24
|
+
@box_right = options[:br]
|
25
|
+
@fly = options[:fly]
|
26
|
+
@unit = options[:unit]
|
27
|
+
@heading = options[:heading]
|
28
|
+
end
|
22
29
|
|
23
|
-
private
|
30
|
+
private
|
24
31
|
|
25
|
-
|
26
|
-
|
32
|
+
def output(name, x_offset, key)
|
33
|
+
body = block_given? ? yield : (boundary_box + right + left)
|
27
34
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
<<~SVG
|
36
|
+
<!-- #{name} Trident -->
|
37
|
+
<g transform="translate(#{BF * x_offset / 80},#{BH * 9 / 32})"><g transform="scale(0.7)">
|
38
|
+
#{@heading}
|
32
39
|
|
33
|
-
|
40
|
+
#{USPSFlags::Core::Icons::Trident.new(key).svg}
|
34
41
|
|
35
|
-
|
36
|
-
|
37
|
-
|
42
|
+
#{body}
|
43
|
+
</g></g>
|
44
|
+
SVG
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
38
48
|
end
|
39
49
|
end
|
@@ -4,41 +4,47 @@
|
|
4
4
|
#
|
5
5
|
# This class should never need to be called directly.
|
6
6
|
# @private
|
7
|
-
class USPSFlags
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
class USPSFlags
|
8
|
+
class Core
|
9
|
+
module TridentSpecs
|
10
|
+
class Circle < USPSFlags::Core::TridentSpecs::Long
|
11
|
+
def p
|
12
|
+
output('Circle', 23, :stf)
|
13
|
+
end
|
11
14
|
|
12
|
-
private
|
15
|
+
private
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
def right
|
18
|
+
<<~SVG
|
19
|
+
<!-- Right -->
|
20
|
+
#{inner_diameter} <!-- Inner circle diameter -->
|
21
|
+
#{outer_diameter} <!-- Outer circle diameter -->
|
22
|
+
#{circle_to_bottom} <!-- Circle to bottom -->
|
23
|
+
SVG
|
24
|
+
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def inner_diameter
|
27
|
+
<<~SVG
|
28
|
+
#{SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] * 2, @box_top + @config[:crossbar_from_top] + @config[:width], pointer_top: @config[:center_point], pointer_bottom: @config[:center_point], fly: @fly, unit: @unit)} <!-- Inner circle diameter -->
|
29
|
+
SVG
|
30
|
+
end
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
def outer_diameter
|
33
|
+
<<~SVG
|
34
|
+
#{SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] + @config[:width], pointer_bottom: outer_box_right, fly: @fly, unit: @unit)} <!-- Outer circle diameter -->
|
35
|
+
SVG
|
36
|
+
end
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
def outer_box_right
|
39
|
+
@config[:center_point] + @config[:bar_width] / 2
|
40
|
+
end
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
def circle_to_bottom
|
43
|
+
<<~SVG
|
44
|
+
#{SA.vertical(@box_right + @config[:bar_width], @box_top + @config[:crossbar_from_top] + @config[:bar_width] + @config[:width], @box_bottom, pointer_bottom: @box_right, fly: @fly, unit: @unit)} <!-- Circle to bottom -->
|
45
|
+
SVG
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
43
49
|
end
|
44
50
|
end
|
@@ -4,41 +4,52 @@
|
|
4
4
|
#
|
5
5
|
# This class should never need to be called directly.
|
6
6
|
# @private
|
7
|
-
class USPSFlags
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
class USPSFlags
|
8
|
+
class Core
|
9
|
+
module TridentSpecs
|
10
|
+
class Delta < USPSFlags::Core::TridentSpecs::Base
|
11
|
+
def p
|
12
|
+
output('Delta', 5, :d)
|
13
|
+
end
|
11
14
|
|
12
|
-
private
|
15
|
+
private
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def boundary_box
|
18
|
+
<<~SVG
|
19
|
+
<!-- Boundary box -->
|
20
|
+
<rect x="#{@box_left}" y="#{@box_top}" width="#{@box_right - @box_left}" height="#{BH * 5 / 8}" stroke="#666666" stroke-width="#{BF / 600}" stroke-dasharray="15, 15" fill="none" />
|
21
|
+
SVG
|
22
|
+
end
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
def right
|
25
|
+
<<~SVG
|
26
|
+
<!-- Right -->
|
27
|
+
#{gap_height} <!-- Delta gap height -->
|
28
|
+
#{SA.vertical(@box_right + @config[:bar_width], @box_bottom - @config[:delta_from_bottom] - @config[:bar_width], @box_bottom - @config[:delta_from_bottom], pointer_bottom: @box_right, fly: @fly, unit: @unit)} <!-- Delta width -->
|
29
|
+
#{SA.vertical(@box_right + @config[:bar_width], @box_bottom - @config[:delta_from_bottom], @box_bottom, pointer_bottom: @box_right, fly: @fly, unit: @unit)} <!-- Delta to bottom -->
|
30
|
+
SVG
|
31
|
+
end
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
def gap_height
|
34
|
+
SA.vertical(
|
35
|
+
@box_right + @config[:bar_width], gap_height_top,
|
36
|
+
@box_bottom - @config[:delta_from_bottom] - @config[:bar_width],
|
37
|
+
pointer_top: @config[:center_point], pointer_bottom: @config[:center_point] + @config[:delta_gap_width],
|
38
|
+
fly: @fly, unit: @unit
|
39
|
+
)
|
40
|
+
end
|
33
41
|
|
34
|
-
|
35
|
-
|
36
|
-
|
42
|
+
def gap_height_top
|
43
|
+
@box_bottom - @config[:delta_from_bottom] - @config[:bar_width] - @config[:delta_gap_height]
|
44
|
+
end
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
def left
|
47
|
+
<<~SVG
|
48
|
+
<!-- Left -->
|
49
|
+
#{SA.vertical(@box_left - @config[:bar_width] * 1.5, @box_top, @box_bottom, pointer_top: @box_left, pointer_bottom: @box_left, label_offset: -BF / 30, label_offset_y: -BF * 2 / 11, label_align: 'middle', fly: @fly, unit: @unit)} <!-- Boundary height -->
|
50
|
+
SVG
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
43
54
|
end
|
44
55
|
end
|
@@ -4,62 +4,68 @@
|
|
4
4
|
#
|
5
5
|
# This class should never need to be called directly.
|
6
6
|
# @private
|
7
|
-
class USPSFlags
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
class USPSFlags
|
8
|
+
class Core
|
9
|
+
module TridentSpecs
|
10
|
+
class Header < USPSFlags::Core::TridentSpecs::Base
|
11
|
+
def initialize(options = {})
|
12
|
+
@fly = options[:fly]
|
13
|
+
@fly_fraction = options[:fly_fraction]
|
14
|
+
@hoist = options[:hoist]
|
15
|
+
@hoist_fraction = options[:hoist_fraction]
|
16
|
+
@unit_text = options[:unit_text]
|
17
|
+
@scaled_border = options[:scaled_border]
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
def p
|
21
|
+
<<~SVG
|
22
|
+
#{field}
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
#{heading}
|
25
|
+
#{units}
|
26
|
+
SVG
|
27
|
+
end
|
25
28
|
|
26
|
-
private
|
29
|
+
private
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
def field
|
32
|
+
<<~SVG
|
33
|
+
<!-- Field -->
|
34
|
+
#{USPSFlags::Core.field}
|
35
|
+
SVG
|
36
|
+
end
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
def heading
|
39
|
+
<<~SVG
|
40
|
+
<!-- Specification Heading Information -->
|
41
|
+
<g>
|
42
|
+
<style><![CDATA[tspan.heading{font-size: 50%;}]]></style>
|
43
|
+
<text x="#{BF / 2}" y="#{BH * 3 / 40}" font-family="sans-serif" font-size="#{BH / 20}px" font-weight="bold" fill="#041E42" text-anchor="middle">United States Power Squadrons<tspan class="heading" dy ="-#{BH / 50}">®</tspan></text>
|
44
|
+
</g>
|
45
|
+
<text x="#{BF / 2}" y="#{BH / 8}" font-family="sans-serif" font-size="#{BH / 30}px" fill="#041E42" text-anchor="middle">Officer Flag Trident Specification</text>
|
46
|
+
<text x="#{BF / 2}" y="#{BH * 2 / 11}" font-family="sans-serif" font-size="#{BH / 40}px" fill="#041E42" text-anchor="middle">All measurements are relative to a field with</text>
|
47
|
+
SVG
|
48
|
+
end
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
def units
|
51
|
+
<<~SVG
|
52
|
+
<g>
|
53
|
+
<style><![CDATA[tspan.title{font-size: #{USPSFlags::Config::FRACTION_SCALE * 9 / 10}%;}]]></style>
|
54
|
+
<text x="#{BF / 2}" y="#{BH * 4 / 19}" font-family="sans-serif" font-size="#{BH / 40}px" fill="#041E42" text-anchor="middle">fly of #{@fly} <tspan class="title">#{@fly_fraction}</tspan> #{@unit_text} and hoist of #{@hoist} <tspan class="title">#{@hoist_fraction}</tspan> #{@unit_text}.</text>
|
55
|
+
</g>
|
56
|
+
<text x="#{BF / 2}" y="#{BH / 4}" font-family="sans-serif" font-size="#{BH / 40}px" fill="#041E42" text-anchor="middle">Measurements not specified are the same as on the short trident.</text>
|
57
|
+
#{scaled_border if @scaled_border}
|
58
|
+
SVG
|
59
|
+
end
|
57
60
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
def scaled_border
|
62
|
+
<<~SVG
|
63
|
+
<!-- Flag border scaled to spec trident size -->
|
64
|
+
<rect x="#{BF * 0.41}" y="#{BH * 0.38}" width="#{BF}" height="#{BH}" transform="scale(0.7)" style="fill: none; stroke: #E0E0E0; stroke-width: 5px;" />
|
65
|
+
<text x="#{BF * 0.64}" y="#{BH * 0.96}" font-family="sans-serif" font-size="#{BH / 60}px" fill="#CCCCCC" text-anchor="middle">Scale size of a flag.</text>
|
66
|
+
SVG
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
64
70
|
end
|
65
71
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
# Core SVG data for the trident specification sheet.
|
4
|
+
#
|
5
|
+
# This class should never need to be called directly.
|
6
|
+
# @private
|
7
|
+
class USPSFlags
|
8
|
+
class Core
|
9
|
+
module TridentSpecs
|
10
|
+
module Horizontal
|
11
|
+
# This module defined no public methods
|
12
|
+
def _; end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def bottom
|
17
|
+
<<~SVG
|
18
|
+
<!-- Bottom -->
|
19
|
+
#{bottom_bar_width} <!-- Bar width -->
|
20
|
+
#{bottom_hash_width} <!-- Hash width -->
|
21
|
+
#{Base::SA.horizontal(@box_bottom + @config[:bar_width] * 4, @box_left, @box_right, pointer_left: @box_bottom, pointer_right: @box_bottom, fly: @fly, unit: @unit)} <!-- Boundary width -->
|
22
|
+
SVG
|
23
|
+
end
|
24
|
+
|
25
|
+
def bottom_bar_width
|
26
|
+
Base::SA.horizontal(
|
27
|
+
@box_bottom + @config[:bar_width], @config[:center_point] - @config[:bar_width] / 2,
|
28
|
+
@config[:center_point] + @config[:bar_width] / 2,
|
29
|
+
pointer_left: @box_bottom, pointer_right: @box_bottom, fly: @fly, unit: @unit
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def bottom_hash_width
|
34
|
+
Base::SA.horizontal(
|
35
|
+
@box_bottom + @config[:bar_width] * 2.5, @config[:center_point] - @config[:hash_width] / 2,
|
36
|
+
@config[:center_point] + @config[:hash_width] / 2,
|
37
|
+
pointer_left: bottom_hash_width_pointer_left, pointer_right: bottom_hash_width_pointer_right,
|
38
|
+
fly: @fly, unit: @unit
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def bottom_hash_width_pointer_left
|
43
|
+
@box_top + @config[:bar_width] * 4 + @config[:center_point_height] + @config[:side_spike_height]
|
44
|
+
end
|
45
|
+
|
46
|
+
def bottom_hash_width_pointer_right
|
47
|
+
@box_top + @config[:bar_width] * 4 + @config[:center_point_height] + @config[:side_spike_height]
|
48
|
+
end
|
49
|
+
|
50
|
+
def top
|
51
|
+
<<~SVG
|
52
|
+
<!-- Top -->
|
53
|
+
#{top_side_point_width} <!-- Side point width -->
|
54
|
+
#{top_main_point_width} <!-- Main point width -->
|
55
|
+
SVG
|
56
|
+
end
|
57
|
+
|
58
|
+
def top_side_point_width
|
59
|
+
Base::SA.horizontal(
|
60
|
+
@box_top - @config[:bar_width], @box_left, @box_left + @config[:bar_width] * 3 / 2,
|
61
|
+
pointer_left: @box_top, pointer_right: @box_top + @config[:bar_width] * 4 / 5 + @config[:side_point_height],
|
62
|
+
label_offset: -Base::BF / 60, fly: @fly, unit: @unit
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
def top_main_point_width
|
67
|
+
Base::SA.horizontal(
|
68
|
+
@box_top - @config[:bar_width] * 2.5, top_main_point_top, @config[:center_point] + @config[:bar_width],
|
69
|
+
pointer_left: @box_top + @config[:center_point_height], fly: @fly, unit: @unit,
|
70
|
+
pointer_right: @box_top + @config[:center_point_height], label_offset: -Base::BF / 60
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
def top_main_point_top
|
75
|
+
@config[:center_point] - @config[:bar_width]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|