usps_flags 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CONTRIBUTING.md +10 -3
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/usps_flags/config.rb +0 -12
- data/lib/usps_flags/core/ensign.rb +1 -1
- data/lib/usps_flags/core/headers.rb +12 -16
- data/lib/usps_flags/core/pennant.rb +1 -1
- data/lib/usps_flags/core/trident.rb +2 -2
- data/lib/usps_flags/core/trident_spec.rb +32 -10
- data/lib/usps_flags/core/us.rb +1 -1
- data/lib/usps_flags/generate/flag.rb +42 -14
- data/lib/usps_flags/generate.rb +19 -33
- data/lib/usps_flags/helpers.rb +6 -13
- data/spec/rational_spec.rb +4 -0
- data/spec/usps_flags/config_spec.rb +0 -7
- data/usps_flags.gemspec +1 -1
- data.tar.gz.sig +0 -0
- 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: 6f005b5e851564f4b8496aa3489b678a47c8cf9f
|
4
|
+
data.tar.gz: a5f44daaac686d24673233b5f503fa3d3685eeb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e3831a3046a633600d8388727461f160704229690fe4ec57ae747933c60059e09bdf3b950d1cfd4dbe6548814e8848a5d6e1fe0430b678e09b9b44f67c5ef15
|
7
|
+
data.tar.gz: 0f9387270b6fae9bc37a6a40961d75eb520f99e81dae1748f71dbeda3503d176a829c2efb14fc8a70350fad32568e5a7c9963af2774d27bcf6a8b254b69d9bbe
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CONTRIBUTING.md
CHANGED
@@ -4,7 +4,8 @@ Thank you for your interest in improving the USPSFlags generator!
|
|
4
4
|
|
5
5
|
Please feel free to ask about anything or submit an issue or pull request.
|
6
6
|
|
7
|
-
If you would like to submit a pull request, please use atomic (rather than
|
7
|
+
If you would like to submit a pull request, please use atomic (rather than
|
8
|
+
squashed) commits.
|
8
9
|
|
9
10
|
## Contact
|
10
11
|
|
@@ -12,6 +13,12 @@ You can contact me via GitHub, Twitter, or email.
|
|
12
13
|
|
13
14
|
## License
|
14
15
|
|
15
|
-
This project is released under the
|
16
|
+
This project is released under the
|
17
|
+
[GPLv3](https://raw.github.com/jfiander/usps-flags/master/LICENSE).
|
18
|
+
All images generated (other than the US Ensign) are
|
19
|
+
[registered trademarks](http://www.usps.org/national/itcom/trademark.html) of
|
20
|
+
United States Power Squadrons.
|
16
21
|
|
17
|
-
All contributions to this project will be released under the same license.
|
22
|
+
All contributions to this project will be released under the same license.
|
23
|
+
By submitting a pull request, you agree to release your code under the same
|
24
|
+
license.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -71,7 +71,7 @@ USPSFlags::Generate.svg "flag", outfile: nil, scale: nil, field: true
|
|
71
71
|
|
72
72
|
- `outfile` specifies where to save the file. If left as `nil`, this method will
|
73
73
|
`puts` the generated SVG. Either way, the SVG code is returned.
|
74
|
-
- `scale` is a divisor scaling factor – the larger it is, the smaller the
|
74
|
+
- `scale` is a divisor scaling factor – the larger it is, the smaller the
|
75
75
|
resulting SVG will be rendered. Accepted values are floats between 0 and 1,
|
76
76
|
and integers above that.
|
77
77
|
- `field` specifies whether to render the field of a flag, or to only render the
|
data/lib/usps_flags/config.rb
CHANGED
@@ -10,13 +10,11 @@ class USPSFlags::Config
|
|
10
10
|
|
11
11
|
@@flags_dir ||= defined?(::Rails) ? "#{::Rails.root}/app/assets/images/usps_flags" : "#{File.dirname(__dir__)}/output"
|
12
12
|
@@use_larger_tridents ||= true
|
13
|
-
@@log_fail_quietly ||= true
|
14
13
|
|
15
14
|
# Configuration constructor
|
16
15
|
#
|
17
16
|
# @param [String] flag_dir The path to the flags directory.
|
18
17
|
# @param [Boolean] use_larger_tridents Whether to use the larger trident configuration.
|
19
|
-
# @param [Boolean] log_fail_quietly Whether to print an error message if the log file is inaccessible.
|
20
18
|
# @param [Boolean] reset Whether to clear out the specified flags_dir.
|
21
19
|
def initialize
|
22
20
|
load_init_variables
|
@@ -28,7 +26,6 @@ class USPSFlags::Config
|
|
28
26
|
attr_accessor :flags_dir
|
29
27
|
attr_accessor :reset
|
30
28
|
attr_accessor :use_larger_tridents
|
31
|
-
attr_accessor :log_fail_quietly
|
32
29
|
|
33
30
|
# Base configuration values for trident insignia.
|
34
31
|
#
|
@@ -112,18 +109,10 @@ class USPSFlags::Config
|
|
112
109
|
@@use_larger_tridents
|
113
110
|
end
|
114
111
|
|
115
|
-
# Accessor for the boolean of whether to print an error message if the log file is inaccessible.
|
116
|
-
#
|
117
|
-
# @return [Boolean] Returns the current setting.
|
118
|
-
def self.log_fail_quietly
|
119
|
-
@@log_fail_quietly
|
120
|
-
end
|
121
|
-
|
122
112
|
private
|
123
113
|
def load_init_variables
|
124
114
|
@flags_dir = @@flags_dir
|
125
115
|
@use_larger_tridents = @@use_larger_tridents
|
126
|
-
@log_fail_quietly = @@log_fail_quietly
|
127
116
|
@reset = false
|
128
117
|
end
|
129
118
|
|
@@ -141,6 +130,5 @@ class USPSFlags::Config
|
|
141
130
|
def set_class_variables
|
142
131
|
@@flags_dir = @flags_dir
|
143
132
|
@@use_larger_tridents = @use_larger_tridents
|
144
|
-
@@log_fail_quietly = @log_fail_quietly
|
145
133
|
end
|
146
134
|
end
|
@@ -7,29 +7,19 @@ class USPSFlags::Core::Headers
|
|
7
7
|
@width = width
|
8
8
|
@height = height
|
9
9
|
@title = title
|
10
|
+
scale ||= 3
|
11
|
+
@generated_at = Time.now.strftime("%Y%m%d.%H%S%z")
|
12
|
+
|
10
13
|
if @width.nil? || @height.nil?
|
11
|
-
scale = 3 if scale.nil?
|
12
14
|
@width = USPSFlags::Config::BASE_FLY / scale
|
13
15
|
@height = (@width*Rational(2,3)).to_i
|
14
|
-
|
15
16
|
@view_width = USPSFlags::Config::BASE_FLY
|
16
17
|
@view_height = USPSFlags::Config::BASE_HOIST
|
17
|
-
|
18
|
-
if pennant
|
19
|
-
@height = @height/4
|
20
|
-
@view_height = USPSFlags::Config::BASE_HOIST/4
|
21
|
-
end
|
18
|
+
set_pennant_height(@height) if pennant
|
22
19
|
else
|
23
|
-
|
24
|
-
|
25
|
-
@view_height = @height
|
26
|
-
else
|
27
|
-
@view_width = @width * scale
|
28
|
-
@view_height = @height * scale
|
29
|
-
end
|
20
|
+
@view_width = width * scale
|
21
|
+
@view_height = height * scale
|
30
22
|
end
|
31
|
-
|
32
|
-
@generated_at = Time.now.strftime("%Y%m%d.%H%S%z")
|
33
23
|
end
|
34
24
|
|
35
25
|
def svg
|
@@ -57,4 +47,10 @@ class USPSFlags::Core::Headers
|
|
57
47
|
|
58
48
|
svg
|
59
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def set_pennant_height(height)
|
53
|
+
height = height/4
|
54
|
+
@view_height = USPSFlags::Config::BASE_HOIST/4
|
55
|
+
end
|
60
56
|
end
|
@@ -124,9 +124,9 @@ class USPSFlags::Core::Trident
|
|
124
124
|
elsif color == :blue
|
125
125
|
@color_code = USPSFlags::Config::BLUE
|
126
126
|
@field_color_code = "#FFFFFF"
|
127
|
-
elsif
|
127
|
+
elsif field_color == :red
|
128
128
|
@field_color_code = USPSFlags::Config::RED
|
129
|
-
elsif
|
129
|
+
elsif field_color == :blue
|
130
130
|
@field_color_code = USPSFlags::Config::BLUE
|
131
131
|
end
|
132
132
|
end
|
@@ -32,21 +32,36 @@ class USPSFlags::Core::TridentSpec
|
|
32
32
|
|
33
33
|
private
|
34
34
|
def configure_sizes(fly)
|
35
|
+
@fly = fly
|
36
|
+
get_hoist_from_fly(@fly)
|
37
|
+
configure_hoist_fraction
|
38
|
+
configure_fly_fraction
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_hoist_from_fly(fly)
|
35
42
|
hoist = (fly*Rational(2,3))
|
36
|
-
@hoist = hoist == hoist.to_i
|
43
|
+
@hoist = if hoist == hoist.to_i
|
44
|
+
hoist.to_i
|
45
|
+
else
|
46
|
+
hoist
|
47
|
+
end
|
48
|
+
end
|
37
49
|
|
38
|
-
|
50
|
+
def configure_hoist_fraction
|
39
51
|
@hoist_fraction = ""
|
40
|
-
if
|
41
|
-
@
|
52
|
+
if @hoist == @hoist.to_i
|
53
|
+
@hoist = @hoist.to_i
|
42
54
|
else
|
43
|
-
@
|
55
|
+
@hoist, @hoist_fraction = @hoist.to_simplified_a
|
44
56
|
end
|
57
|
+
end
|
45
58
|
|
46
|
-
|
47
|
-
|
59
|
+
def configure_fly_fraction
|
60
|
+
@fly_fraction = ""
|
61
|
+
if @fly == @fly.to_i
|
62
|
+
@fly = @fly.to_i
|
48
63
|
else
|
49
|
-
@
|
64
|
+
@fly, @fly_fraction = @fly.to_simplified_a
|
50
65
|
end
|
51
66
|
end
|
52
67
|
|
@@ -60,9 +75,16 @@ class USPSFlags::Core::TridentSpec
|
|
60
75
|
@unit_text = unit.nil? ? "" : "#{unit}"
|
61
76
|
@unit = unit
|
62
77
|
|
78
|
+
configure_barb_label
|
79
|
+
end
|
80
|
+
|
81
|
+
def configure_barb_label
|
63
82
|
barb_label = Rational(@trident_config[:main_point_barb]) * @fly / USPSFlags::Config::BASE_FLY
|
64
|
-
barb_label = barb_label == barb_label.to_i
|
65
|
-
|
83
|
+
@barb_label = if barb_label == barb_label.to_i
|
84
|
+
"#{barb_label.to_i}#{@unit_text}"
|
85
|
+
else
|
86
|
+
"#{barb_label.to_simplified_s}#{@unit_text}"
|
87
|
+
end
|
66
88
|
end
|
67
89
|
|
68
90
|
def spec_header
|
data/lib/usps_flags/core/us.rb
CHANGED
@@ -39,7 +39,7 @@ class USPSFlags::Core::US
|
|
39
39
|
rows[type].each do |r|
|
40
40
|
columns[type].each do |c|
|
41
41
|
svg << <<~SVG
|
42
|
-
<g transform="translate(#{@canton_fly*c/12}, #{@star_offset+@canton_hoist*r/10})"><g transform="scale(0.31)">#{USPSFlags::Core
|
42
|
+
<g transform="translate(#{@canton_fly*c/12}, #{@star_offset+@canton_hoist*r/10})"><g transform="scale(0.31)">#{USPSFlags::Core.star}</g></g>
|
43
43
|
SVG
|
44
44
|
end
|
45
45
|
end
|
@@ -5,22 +5,16 @@
|
|
5
5
|
class USPSFlags::Generate::Flag
|
6
6
|
class << self
|
7
7
|
def officer(rank: nil, width: USPSFlags::Config::BASE_FLY, outfile: nil, scale: nil, field: true)
|
8
|
-
raise "
|
8
|
+
raise ArgumentError, "No rank specified." if rank.nil?
|
9
9
|
@rank = rank.to_s.upcase
|
10
10
|
@field = field
|
11
11
|
|
12
12
|
svg = ""
|
13
13
|
svg << USPSFlags::Core.headers(scale: scale, title: @rank)
|
14
|
-
|
15
14
|
modify_rank_for_insignia
|
16
15
|
@flag_details = USPSFlags::Helpers.flag_details(@rank)
|
17
16
|
@trident_color = @field ? :white : @flag_details[:color]
|
18
|
-
|
19
|
-
svg << USPSFlags::Core.field(style: @flag_details[:style], color: @flag_details[:color]) if @field
|
20
|
-
svg << "<g transform=\"translate(-150, 400)\"><g transform=\"scale(0.58333)\">" if @flag_details[:style] == :past
|
21
|
-
svg << get_officer_flag
|
22
|
-
svg << "</g></g>" if @flag_details[:style] == :past
|
23
|
-
svg << USPSFlags::Core.footer
|
17
|
+
svg << officer_flag_body
|
24
18
|
|
25
19
|
USPSFlags::Helpers.output(svg, outfile: outfile)
|
26
20
|
end
|
@@ -97,26 +91,60 @@ class USPSFlags::Generate::Flag
|
|
97
91
|
|
98
92
|
private
|
99
93
|
def get_officer_flag
|
100
|
-
if
|
94
|
+
if cc?
|
101
95
|
USPSFlags::Core::Tridents.cc(@flag_details[:type], trident_color: @trident_color)
|
102
|
-
elsif
|
96
|
+
elsif vc?
|
103
97
|
USPSFlags::Core::Tridents.vc(@flag_details[:type], trident_color: @trident_color)
|
104
|
-
elsif
|
98
|
+
elsif cdr_or_dc?
|
105
99
|
USPSFlags::Core::Tridents.three(@flag_details[:type], trident_color: @trident_color, field_color: @flag_details[:color])
|
106
|
-
elsif
|
100
|
+
elsif ltc_or_dltc?
|
107
101
|
USPSFlags::Core::Tridents.two(@flag_details[:type], trident_color: @trident_color, field_color: @flag_details[:color])
|
108
|
-
elsif
|
102
|
+
elsif lt_or_dlt?
|
109
103
|
USPSFlags::Core::Tridents.offset(@flag_details[:type], field_color: @flag_details[:color], field: @field)
|
110
|
-
elsif
|
104
|
+
elsif special_officer?
|
111
105
|
special(@flag_details[:type], level: @flag_details[:level], field: @field)
|
112
106
|
else
|
113
107
|
USPSFlags::Core.trident(@flag_details[:type], field_color: @flag_details[:color])
|
114
108
|
end
|
115
109
|
end
|
116
110
|
|
111
|
+
def officer_flag_body
|
112
|
+
svg = ""
|
113
|
+
svg << USPSFlags::Core.field(style: @flag_details[:style], color: @flag_details[:color]) if @field
|
114
|
+
svg << "<g transform=\"translate(-150, 400)\"><g transform=\"scale(0.58333)\">" if @flag_details[:style] == :past
|
115
|
+
svg << get_officer_flag
|
116
|
+
svg << "</g></g>" if @flag_details[:style] == :past
|
117
|
+
svg << USPSFlags::Core.footer
|
118
|
+
svg
|
119
|
+
end
|
120
|
+
|
117
121
|
def modify_rank_for_insignia
|
118
122
|
@rank.slice!(0) if !@field && USPSFlags::Helpers.valid_flags(:past).include?(@rank)
|
119
123
|
@rank = "CDR" if @rank == "C"
|
120
124
|
end
|
125
|
+
|
126
|
+
def cc?
|
127
|
+
@flag_details[:type] == :n && @flag_details[:count] == 3
|
128
|
+
end
|
129
|
+
|
130
|
+
def vc?
|
131
|
+
@flag_details[:type] == :n && @flag_details[:count] == 2
|
132
|
+
end
|
133
|
+
|
134
|
+
def cdr_or_dc?
|
135
|
+
[:s, :d].include?(@flag_details[:type]) && @flag_details[:count] == 3
|
136
|
+
end
|
137
|
+
|
138
|
+
def ltc_or_dltc?
|
139
|
+
[:s, :d].include?(@flag_details[:type]) && @flag_details[:count] == 2
|
140
|
+
end
|
141
|
+
|
142
|
+
def lt_or_dlt?
|
143
|
+
%w[LT DLT].include?(@rank)
|
144
|
+
end
|
145
|
+
|
146
|
+
def special_officer?
|
147
|
+
[:a, :f, :fc, :pc].include?(@flag_details[:type])
|
148
|
+
end
|
121
149
|
end
|
122
150
|
end
|
data/lib/usps_flags/generate.rb
CHANGED
@@ -57,29 +57,13 @@ class USPSFlags::Generate
|
|
57
57
|
raise USPSFlags::Errors::StaticFilesGenerationError, "At least one argument switch must be true out of [svg, png, zips]." unless svg || png || zips
|
58
58
|
|
59
59
|
remove_static_files if reset
|
60
|
-
|
61
|
-
puts "\nSVGs generate a single file.",
|
62
|
-
"PNGs generate full-res, 1500w, 1000w, 500w, and thumbnail files.",
|
63
|
-
"Corresponding rank insignia (including smaller sizes) are also generated, as appropriate."
|
64
|
-
USPSFlags::Helpers.log "\nGeneration location: #{USPSFlags::Config.flags_dir}\n"
|
65
|
-
USPSFlags::Helpers.log "\n#{Time.now.strftime('%Y%m%d.%H%M%S%z')} – Generating static files...\n\n"
|
66
|
-
USPSFlags::Helpers.log "Flag | SVG | PNG | Run time\n".rjust(USPSFlags::Helpers.max_flag_name_length+31),
|
67
|
-
"\n".rjust(USPSFlags::Helpers.max_flag_name_length+32, "-")
|
68
|
-
|
60
|
+
static_generation_header
|
69
61
|
overall_start_time = Time.now
|
70
|
-
|
71
62
|
USPSFlags::Helpers.valid_flags(:all).each do |flag|
|
72
63
|
generate_static_images_for(flag, svg: svg, png: png)
|
73
64
|
end
|
74
|
-
|
75
65
|
zips(svg: svg, png: png) if zips
|
76
|
-
|
77
66
|
USPSFlags::Helpers.log "\nTotal run time: #{Time.now - overall_start_time} s\n\n"
|
78
|
-
|
79
|
-
nil
|
80
|
-
rescue => e
|
81
|
-
raise e if e.is_a?(USPSFlags::Errors::StaticFilesGenerationError)
|
82
|
-
raise USPSFlags::Errors::StaticFilesGenerationError, cause: e
|
83
67
|
end
|
84
68
|
|
85
69
|
# Generate zip archives of current static image files.
|
@@ -90,9 +74,6 @@ class USPSFlags::Generate
|
|
90
74
|
raise USPSFlags::Errors::ZipGenerationError, "At least one argument switch must be true out of [svg, png]." unless svg || png
|
91
75
|
generate_zip("svg") if svg
|
92
76
|
generate_zip("png") if png
|
93
|
-
rescue => e
|
94
|
-
raise e if e.is_a?(USPSFlags::Errors::ZipGenerationError)
|
95
|
-
raise USPSFlags::Errors::ZipGenerationError, cause: e
|
96
77
|
end
|
97
78
|
|
98
79
|
# Generate trident spec sheet as an SVG image.
|
@@ -130,8 +111,18 @@ class USPSFlags::Generate
|
|
130
111
|
[@svg_file, @png_file, @svg_ins_file, @png_ins_file]
|
131
112
|
end
|
132
113
|
|
114
|
+
def static_generation_header
|
115
|
+
puts "\nSVGs generate a single file.",
|
116
|
+
"PNGs generate full-res, 1500w, 1000w, 500w, and thumbnail files.",
|
117
|
+
"Corresponding rank insignia (including smaller sizes) are also generated, as appropriate."
|
118
|
+
USPSFlags::Helpers.log "\nGeneration location: #{USPSFlags::Config.flags_dir}\n"
|
119
|
+
USPSFlags::Helpers.log "\n#{Time.now.strftime('%Y%m%d.%H%M%S%z')} – Generating static files...\n\n"
|
120
|
+
USPSFlags::Helpers.log "Flag | SVG | PNG | Run time\n".rjust(USPSFlags::Helpers.max_flag_name_length+31),
|
121
|
+
"\n".rjust(USPSFlags::Helpers.max_flag_name_length+32, "-")
|
122
|
+
end
|
123
|
+
|
133
124
|
def generate_zip(type)
|
134
|
-
raise "
|
125
|
+
raise USPSFlags::Errors::ZipGenerationError, "Flags directory not found." unless ::Dir.exist?("#{USPSFlags::Config.flags_dir}/ZIP")
|
135
126
|
|
136
127
|
zip = "#{USPSFlags::Config.flags_dir}/ZIP/USPS_Flags.#{type}.zip"
|
137
128
|
::File.delete(zip) if ::File.exist?(zip)
|
@@ -158,17 +149,8 @@ class USPSFlags::Generate
|
|
158
149
|
|
159
150
|
set_file_paths(flag)
|
160
151
|
|
161
|
-
|
162
|
-
|
163
|
-
else
|
164
|
-
USPSFlags::Helpers.log "-"
|
165
|
-
end
|
166
|
-
|
167
|
-
if png
|
168
|
-
generate_static_png(flag)
|
169
|
-
else
|
170
|
-
USPSFlags::Helpers.log "- "
|
171
|
-
end
|
152
|
+
svg ? generate_static_svg(flag) : USPSFlags::Helpers.log("-")
|
153
|
+
png ? generate_static_png(flag) : USPSFlags::Helpers.log("- ")
|
172
154
|
|
173
155
|
run_time = (Time.now - start_time).round(4).to_s[(0..5)].ljust(6, "0")
|
174
156
|
USPSFlags::Helpers.log " | #{run_time} s\n"
|
@@ -199,7 +181,7 @@ class USPSFlags::Generate
|
|
199
181
|
end
|
200
182
|
|
201
183
|
def generate_fullsize_png_insignia(flag)
|
202
|
-
if
|
184
|
+
if can_have_insignia?(flag)
|
203
185
|
USPSFlags::Helpers.log "-"
|
204
186
|
else
|
205
187
|
png(File.read(@svg_ins_file), outfile: @png_ins_file, trim: true) unless ::File.exist?(@png_ins_file)
|
@@ -207,6 +189,10 @@ class USPSFlags::Generate
|
|
207
189
|
end
|
208
190
|
end
|
209
191
|
|
192
|
+
def can_have_insignia?(flag)
|
193
|
+
USPSFlags::Helpers.valid_flags(:past).include?(flag) || !USPSFlags::Helpers.valid_flags(:insignia).include?(flag)
|
194
|
+
end
|
195
|
+
|
210
196
|
def generate_reduced_size_pngs(flag)
|
211
197
|
USPSFlags::Helpers.png_sizes.keys.each do |size|
|
212
198
|
USPSFlags::Helpers.log(".") and next if ::File.exist?("#{USPSFlags::Config.flags_dir}/PNG/#{flag}.#{size}.png")
|
data/lib/usps_flags/helpers.rb
CHANGED
@@ -89,12 +89,8 @@ class USPSFlags::Helpers
|
|
89
89
|
::FileUtils.mkdir_p(USPSFlags::Config.log_path)
|
90
90
|
outputs = [STDOUT]
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
outputs << log_file
|
95
|
-
rescue Errno::EACCES => e
|
96
|
-
puts "\nError accessing log file." unless USPSFlags::Config.log_fail_quietly
|
97
|
-
end
|
92
|
+
log_file = File.open("#{USPSFlags::Config.log_path}/flag.log", 'a')
|
93
|
+
outputs << log_file
|
98
94
|
|
99
95
|
messages.each do |message|
|
100
96
|
outputs.each { |f| f.write(message) }
|
@@ -207,13 +203,10 @@ class USPSFlags::Helpers
|
|
207
203
|
end
|
208
204
|
end
|
209
205
|
|
210
|
-
def flag_type(rank)
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
:fc
|
215
|
-
elsif rank == "STFC"
|
216
|
-
:stf
|
206
|
+
def flag_type(rank) # Complexity
|
207
|
+
specifics = {"PORTCAP" => :pc, "FLEETCAP" => :fc, "STFC" => :stf}
|
208
|
+
if specifics.keys.include?(rank)
|
209
|
+
specifics[rank]
|
217
210
|
elsif rank.match /.AIDE/
|
218
211
|
:a
|
219
212
|
elsif rank.match /.?FLT/
|
data/spec/rational_spec.rb
CHANGED
@@ -6,6 +6,10 @@ describe Rational do
|
|
6
6
|
expect(Rational(4,3).to_simplified_a).to eql([1, Rational(1,3)])
|
7
7
|
end
|
8
8
|
|
9
|
+
it "should render a proper fraction as String" do
|
10
|
+
expect(Rational(2,3).to_simplified_a).to eql("2/3")
|
11
|
+
end
|
12
|
+
|
9
13
|
it "should render a simplified fraction as a String" do
|
10
14
|
expect(Rational(4,3).to_simplified_s).to eql("1 1/3")
|
11
15
|
end
|
@@ -26,12 +26,6 @@ describe USPSFlags::Config do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe "log_fail_quietly" do
|
30
|
-
it "should return a Boolean from log_fail_quietly" do
|
31
|
-
expect([true, false]).to include(USPSFlags::Config.log_fail_quietly)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
29
|
describe "configuration constructor" do
|
36
30
|
it "should return a properly constructed configuration" do
|
37
31
|
@config = USPSFlags::Config.new do |config|
|
@@ -41,7 +35,6 @@ describe USPSFlags::Config do
|
|
41
35
|
expect(@config.flags_dir).to eql($tmp_flags_dir)
|
42
36
|
expect(@config.reset).to eql(false)
|
43
37
|
expect(@config.use_larger_tridents).to eql(true)
|
44
|
-
expect(@config.log_fail_quietly).to eql(true)
|
45
38
|
end
|
46
39
|
end
|
47
40
|
end
|
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.3.
|
3
|
+
s.version = '0.3.5'
|
4
4
|
s.date = '2017-11-06'
|
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.'
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|