usps_flags 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1fd4b4ded781d5f92daab3ad5228aaaae47c094
4
- data.tar.gz: 3ee7c59c943e9a002146488d46bd244015f5de58
3
+ metadata.gz: 6c0c1f0bda8f7052219bda470fc994d22195eecf
4
+ data.tar.gz: f595f0370e6d6c2dd737d5ff445423851bb98f76
5
5
  SHA512:
6
- metadata.gz: 76911aa567b3e85f5d4563f5d032913394d4bc4e189f00e7637c1b6de7b81ceaeeeb85e0a50b490ff53a9e60989dbc9e48f349523e07b7ceaae762dad32c1c6f
7
- data.tar.gz: 479f6fc5245d2fdb11845831c6582dc9415944b21871bb89b3c884d7d4dc21d21b1ec30bdc992365b50658458275bd7ea2d1c9af56be803a62a05c94a38d142d
6
+ metadata.gz: d5221d60c22cc8b72373262b3d77659745f3799cb96391869169398ee322db05121bfa17f76036b2f69db55730044dfbded1ebaae3352c4505fd90072e772692
7
+ data.tar.gz: a5335d9c8d8010514d736174a4aad8073c414d9bf007b6b1bf88fcc7ad251ac4646f8aa314ca60adee97f269050c6eab614f514117da302ac0d622104cc88e91
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps_flags (0.3.7)
4
+ usps_flags (0.3.8)
5
5
  file_utils (~> 1.1, >= 1.1.2)
6
6
  mini_magick (~> 4.8, >= 4.8.0)
7
7
  rubyzip (~> 1.2, >= 1.2.1)
data/README.md CHANGED
@@ -128,6 +128,11 @@ flag.png #=> Generates PNG file at "/path/to/png/output.png"
128
128
  to console/log.
129
129
  - Calling `.png` requires `png_file` to be set.
130
130
 
131
+ ## Burgees Extension
132
+
133
+ There is an extension to this gem for handling squadron burgees:
134
+ [USPSFlags::Burgees](https://github.com/jfiander/usps-flags_burgees)
135
+
131
136
  ## Security
132
137
 
133
138
  This gem is cryptographically signed. To be sure the gem code hasn’t been
@@ -8,6 +8,12 @@ module USPSFlags::Errors
8
8
  end
9
9
  end
10
10
 
11
+ class PNGConversionError < StandardError
12
+ def initialize(msg = "There was an error converting the PNG file.")
13
+ super(msg)
14
+ end
15
+ end
16
+
11
17
  class StaticFilesGenerationError < StandardError
12
18
  def initialize(msg = "There was an error generating the static files.", cause: nil)
13
19
  super(msg)
@@ -18,6 +18,27 @@ class USPSFlags::Helpers
18
18
  valid_flags_for(type)
19
19
  end
20
20
 
21
+ # Resizes and saves a PNG image.
22
+ #
23
+ # One of the params [file, outfile] is required, and outfile takes precedence.
24
+ #
25
+ # @param [String] png_file Path to the PNG file to resize.
26
+ # @param [String] file Abbreviated key for the output file (e.g. "LTC", "insignia/FLT").
27
+ # @param [String] outfile Path to the output file.
28
+ # @param [String] size Actual size to output as.
29
+ # @param [String] size_key Size suffix to attach to the file name.
30
+ def resize_png(png_file, file: nil, outfile: nil, size:, size_key:)
31
+ raise USPSFlags::Errors::PNGConversionError if outfile.nil? && file.nil?
32
+ output_file_name = outfile || "#{USPSFlags::Config.flags_dir}/PNG/#{file}.#{size_key}.png"
33
+ MiniMagick::Tool::Convert.new do |convert|
34
+ convert << "-background" << "none"
35
+ convert << "-format" << "png"
36
+ convert << "-resize" << "#{size}"
37
+ convert << png_file
38
+ convert << output_file_name
39
+ end
40
+ end
41
+
21
42
  # Gets the maximum length among valid flags.
22
43
  #
23
44
  # This is used USPSFlags::Generate, and should never need to be called directly.
@@ -40,20 +61,6 @@ class USPSFlags::Helpers
40
61
  }
41
62
  end
42
63
 
43
- # Resizes and saves a PNG image.
44
- #
45
- # This is used USPSFlags::Generate, and should never need to be called directly.
46
- # @private
47
- def resize_png(png_file, file:, size:, size_key:)
48
- MiniMagick::Tool::Convert.new do |convert|
49
- convert << "-background" << "none"
50
- convert << "-format" << "png"
51
- convert << "-resize" << "#{size}"
52
- convert << png_file
53
- convert << "#{USPSFlags::Config.flags_dir}/PNG/#{file}.#{size_key}.png"
54
- end
55
- end
56
-
57
64
  # Image sizes for generated PNG images.
58
65
  #
59
66
  # This is used USPSFlags::Generate, and should never need to be called directly.
@@ -5,10 +5,7 @@ CodeClimate::TestReporter.start
5
5
 
6
6
  require 'usps_flags'
7
7
 
8
- # The spec for USPSFlags and USPSFlags::Generate contain some examples that check for
9
- # USPSFlags::Errors::PNGGenerationError
10
- # USPSFlags::Errors::StaticFilesGenerationError
11
- # USPSFlags::Errors::ZipGenerationError
8
+ # Some specs contain examples that check for the custom examples from USPSFlags::Errors
12
9
  RSpec::Expectations.configuration.on_potential_false_positives = :nothing
13
10
 
14
11
  RSpec.configure do |config|
@@ -21,4 +21,10 @@ describe USPSFlags::Helpers do
21
21
  expect(USPSFlags::Helpers::Builders.locator).to include("<rect x=\"0\" y=\"0\" width=\"#{USPSFlags::Config::BASE_FLY/30}\" height=\"#{USPSFlags::Config::BASE_FLY/30}\" fill=\"#333333\" fill-opacity=\"0.6\" />")
22
22
  end
23
23
  end
24
+
25
+ describe "resize_png" do
26
+ it "should raise USPSFlags::Errors::PNGConversionError with invalid parameters" do
27
+ expect { USPSFlags::Helpers.resize_png("path/to/image.png", size: 100, size_key: "thumb") }.to raise_error(USPSFlags::Errors::PNGConversionError)
28
+ end
29
+ end
24
30
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'usps_flags'
3
- s.version = '0.3.7'
4
- s.date = '2017-11-07'
3
+ s.version = '0.3.8'
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.'
7
7
  s.homepage = 'http://rubygems.org/gems/usps_flags'
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.3.7
4
+ version: 0.3.8
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-11-07 00:00:00.000000000 Z
33
+ date: 2017-11-08 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: file_utils
@@ -161,11 +161,6 @@ files:
161
161
  - ".gitignore"
162
162
  - ".rspec"
163
163
  - ".travis.yml"
164
- - ".yardoc/checksums"
165
- - ".yardoc/complete"
166
- - ".yardoc/object_types"
167
- - ".yardoc/objects/root.dat"
168
- - ".yardoc/proxy_types"
169
164
  - ".yardopts"
170
165
  - CONTRIBUTING.md
171
166
  - Gemfile
metadata.gz.sig CHANGED
Binary file
@@ -1,6 +0,0 @@
1
- lib/rational.rb fb59739135ea56b703fb68b67bf4ffa890bc399f
2
- lib/usps_flags.rb 84e186ba350cb82a4e446a777664537c48273df6
3
- lib/usps_flags/core.rb ea613497346f50853ba5851bb73a6d5bc412b1c3
4
- lib/usps_flags/config.rb 9b11afcdd8d3dd5951491647e7898540efb68cff
5
- lib/usps_flags/helpers.rb 13444e114123242790ea4ca50f924c19f7ebcad6
6
- lib/usps_flags/generate.rb 44bfd236560a471ac818297148198ee6015c1b74
File without changes
Binary file
Binary file
Binary file