usps_flags 0.3.8 → 0.3.9
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.tar.gz.sig +0 -0
- data/.gitignore +2 -0
- data/Gemfile.lock +1 -1
- data/lib/usps_flags/config.rb +19 -14
- data/lib/usps_flags/generate.rb +1 -1
- data/spec/usps_flags/generate_spec.rb +45 -0
- 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: 89aee583c2bef9f84f8e950a6964459f7e2f0588
|
4
|
+
data.tar.gz: 4e955787d40313d4f10f6b0e57fa1bc210a872a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 985b6074040f4664ba27a04ba0109739ca846adc701755d6ffb4e94f812ce623a3c67d38ea38db46afb4a88a2617f9ac226f017d20839de433ba1c15cbc27f9b
|
7
|
+
data.tar.gz: ab8dd0f944595a3c5bd36e75f19140cb5340f06ec6e9f4e25ba4ba586ddc8ca6c360391a0e32fd1a03680e1f9a12249db393479a64dfb3078e8834347f3881b1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/usps_flags/config.rb
CHANGED
@@ -7,9 +7,9 @@ class USPSFlags::Config
|
|
7
7
|
BASE_FLY ||= 3072
|
8
8
|
BASE_HOIST ||= BASE_FLY*2/3
|
9
9
|
FRACTION_SCALE ||= 85
|
10
|
-
|
11
|
-
@@flags_dir
|
12
|
-
@@use_larger_tridents
|
10
|
+
|
11
|
+
@@flags_dir = "#{File.dirname(__dir__)}/output"
|
12
|
+
@@use_larger_tridents = true
|
13
13
|
|
14
14
|
# Configuration constructor
|
15
15
|
#
|
@@ -19,8 +19,8 @@ class USPSFlags::Config
|
|
19
19
|
def initialize
|
20
20
|
load_init_variables
|
21
21
|
yield self if block_given?
|
22
|
-
set_flags_dir(reset: @reset)
|
23
22
|
set_class_variables
|
23
|
+
set_flags_dir(reset: @reset)
|
24
24
|
end
|
25
25
|
|
26
26
|
attr_accessor :flags_dir
|
@@ -84,7 +84,11 @@ class USPSFlags::Config
|
|
84
84
|
#
|
85
85
|
# @return [String] The current path to the flags directory.
|
86
86
|
def self.flags_dir
|
87
|
-
@@flags_dir
|
87
|
+
@@flags_dir || if defined?(::Rails)
|
88
|
+
"#{::Rails.root}/app/assets/images/usps-flags"
|
89
|
+
else
|
90
|
+
"#{File.dirname(__dir__)}/output"
|
91
|
+
end
|
88
92
|
end
|
89
93
|
|
90
94
|
# Alias for the directory to store generated log files.
|
@@ -116,19 +120,20 @@ class USPSFlags::Config
|
|
116
120
|
@reset = false
|
117
121
|
end
|
118
122
|
|
123
|
+
def set_class_variables
|
124
|
+
@@flags_dir = @flags_dir
|
125
|
+
@@use_larger_tridents = @use_larger_tridents
|
126
|
+
end
|
127
|
+
|
119
128
|
def set_flags_dir(reset: false)
|
120
|
-
|
129
|
+
return false if @@flags_dir.nil? || @@flags_dir.empty?
|
130
|
+
::FileUtils.rm_rf(@@flags_dir) if reset
|
121
131
|
[
|
122
|
-
"#{
|
123
|
-
"#{
|
124
|
-
"#{
|
132
|
+
"#{@@flags_dir}/SVG/insignia",
|
133
|
+
"#{@@flags_dir}/PNG/insignia",
|
134
|
+
"#{@@flags_dir}/ZIP"
|
125
135
|
].each do |dir|
|
126
136
|
::FileUtils.mkdir_p(dir)
|
127
137
|
end
|
128
138
|
end
|
129
|
-
|
130
|
-
def set_class_variables
|
131
|
-
@@flags_dir = @flags_dir
|
132
|
-
@@use_larger_tridents = @use_larger_tridents
|
133
|
-
end
|
134
139
|
end
|
data/lib/usps_flags/generate.rb
CHANGED
@@ -200,7 +200,7 @@ class USPSFlags::Generate
|
|
200
200
|
def generate_reduced_size_pngs
|
201
201
|
USPSFlags::Helpers.png_sizes.keys.each do |size|
|
202
202
|
size, size_key = USPSFlags::Helpers.size_and_key(size: size, flag: @flag)
|
203
|
-
@sized_png_file = "#{USPSFlags::Config.flags_dir}/PNG/#{@flag}.#{
|
203
|
+
@sized_png_file = "#{USPSFlags::Config.flags_dir}/PNG/#{@flag}.#{size_key}.png"
|
204
204
|
@sized_png_ins_file = @sized_png_file.gsub("/PNG/", "/PNG/insignia/")
|
205
205
|
|
206
206
|
generate_smaller_png(size, size_key)
|
@@ -183,6 +183,51 @@ describe USPSFlags::Generate do
|
|
183
183
|
expect { USPSFlags::Generate.all(reset: false) }.to_not raise_error # (USPSFlags::Errors::StaticFilesGenerationError)
|
184
184
|
end
|
185
185
|
|
186
|
+
it "should have generated the correct log output" do
|
187
|
+
correct_log_pattern = <<~LOG
|
188
|
+
Flag | SVG | PNG | Run time
|
189
|
+
---------------------------------------
|
190
|
+
PLTC | S- | F-H-K-D-T- | .*? s
|
191
|
+
PC | S- | F-H-K-D-T- | .*? s
|
192
|
+
1LT | SI | FIH\\+K\\+DiT\\. | .*? s
|
193
|
+
LTC | SI | FIHiKiDiTi | .*? s
|
194
|
+
CDR | SI | FIHiKiDiTi | .*? s
|
195
|
+
PORTCAP | SI | FIH\\+K\\+DiTi | .*? s
|
196
|
+
FLEETCAP | SI | FIH\\+KiDiTi | .*? s
|
197
|
+
LT | SI | F\\.H\\+K\\+DiTi | .*? s
|
198
|
+
FLT | SI | \\.IH\\+K\\+DiTi | .*? s
|
199
|
+
PDLTC | S- | F-H-K-D-T- | .*? s
|
200
|
+
PDC | S- | F-H-K-D-T- | .*? s
|
201
|
+
D1LT | SI | FIH\\+K\\+DiTi | .*? s
|
202
|
+
DLTC | SI | FIHiKiDiTi | .*? s
|
203
|
+
DC | SI | FIHiKiDiTi | .*? s
|
204
|
+
DLT | SI | FIH\\+K\\+DiTi | .*? s
|
205
|
+
DAIDE | SI | FIH\\+KiDiTi | .*? s
|
206
|
+
DFLT | SI | FIHiKiDiTi | .*? s
|
207
|
+
PSTFC | S- | F-H-K-D-T- | .*? s
|
208
|
+
PRC | S- | F-H-K-D-T- | .*? s
|
209
|
+
PVC | S- | F-H-K-D-T- | .*? s
|
210
|
+
PCC | S- | F-H-K-D-T- | .*? s
|
211
|
+
NAIDE | SI | FIH\\+KiDiTi | .*? s
|
212
|
+
NFLT | SI | FIHiKiDiTi | .*? s
|
213
|
+
STFC | SI | FIH\\+K\\+DiTi | .*? s
|
214
|
+
RC | SI | FIH\\+K\\+DiTi | .*? s
|
215
|
+
VC | SI | FIHiKiDiTi | .*? s
|
216
|
+
CC | SI | FIHiKiDiTi | .*? s
|
217
|
+
CRUISE | S- | F-H-K-D-T- | .*? s
|
218
|
+
OIC | S- | F-H-K-D-T- | .*? s
|
219
|
+
ENSIGN | S- | F-H-K-D-T- | .*? s
|
220
|
+
WHEEL | S- | F-H-K-D-T- | .*? s
|
221
|
+
US | S- | F-H-K-D-T- | .*? s
|
222
|
+
Generated SVG Zip
|
223
|
+
Generated PNG Zip
|
224
|
+
LOG
|
225
|
+
|
226
|
+
log_contents = ::File.read("#{USPSFlags::Config.log_path}/flag.log")
|
227
|
+
|
228
|
+
expect(log_contents).to match(Regexp.new(correct_log_pattern))
|
229
|
+
end
|
230
|
+
|
186
231
|
it "should not raise an error while clearing all static files" do
|
187
232
|
expect { USPSFlags::Generate.all(svg: false, png: false, zips: false, reset: true) }.to_not raise_error # (USPSFlags::Errors::StaticFilesGenerationError)
|
188
233
|
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.9'
|
4
4
|
s.date = '2017-11-08'
|
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
|