usps_flags-burgees 0.0.22 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/Gemfile +3 -1
- data/Gemfile.lock +3 -3
- data/Rakefile +5 -3
- data/lib/usps_flags/burgees.rb +8 -11
- data/lib/usps_flags/burgees/builtins.rb +4 -1
- data/lib/usps_flags/burgees/config.rb +4 -1
- data/lib/usps_flags/burgees/crossed.rb +4 -2
- data/lib/usps_flags/burgees/customs.rb +4 -1
- data/lib/usps_flags/burgees/errors.rb +8 -4
- data/spec/spec_helper.rb +5 -3
- data/spec/usps_flags/burgees/config_spec.rb +8 -6
- data/spec/usps_flags/burgees_spec.rb +16 -15
- data/usps_flags-burgees.gemspec +5 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9adce14ca7f45dfb8d87491bdc9cd818f1cf1cdd4b0b65c68eb1c1afbdae4d1d
|
4
|
+
data.tar.gz: 1c63c01c7727429ec03d934245183989d4833ed377a317207efc7f3f703a462a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e8434af3ea3aa96a5f788bd4388410a3eeab39e4e1cbb8a2f7d52165550d19e6fb702ae9c28d13b8d1c4ae1732908d568bcdb263d2efbf9169a736fed1c96a6
|
7
|
+
data.tar.gz: 16c72e98e56ccf7adb790db41e9b3af0d50e04da931224fedb6633e71d612b90dba32a40244b5c023096e49c5ef6623b8eb532ae7a9adbf488a28e51693733b3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
usps_flags-burgees (0.0
|
5
|
-
usps_flags (~> 0.
|
4
|
+
usps_flags-burgees (0.1.0)
|
5
|
+
usps_flags (~> 0.5, >= 0.5.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -32,7 +32,7 @@ GEM
|
|
32
32
|
json (>= 1.8, < 3)
|
33
33
|
simplecov-html (~> 0.10.0)
|
34
34
|
simplecov-html (0.10.2)
|
35
|
-
usps_flags (0.
|
35
|
+
usps_flags (0.5.1)
|
36
36
|
file_utils (~> 1.1, >= 1.1.2)
|
37
37
|
mini_magick (~> 4.8, >= 4.8.0)
|
38
38
|
rubyzip (~> 1.2, >= 1.2.1)
|
data/Rakefile
CHANGED
data/lib/usps_flags/burgees.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'usps_flags'
|
2
4
|
require 'usps_flags/burgees/config'
|
3
5
|
require 'usps_flags/burgees/errors'
|
@@ -28,7 +30,7 @@ class USPSFlags::Burgees
|
|
28
30
|
# @width = 3000
|
29
31
|
# @height = 2000
|
30
32
|
@title = nil
|
31
|
-
@generated_at = Time.now.strftime(
|
33
|
+
@generated_at = Time.now.strftime('%Y%m%d.%H%S%z')
|
32
34
|
yield self if block_given?
|
33
35
|
@title ||= title(@squadron)
|
34
36
|
end
|
@@ -47,13 +49,8 @@ class USPSFlags::Burgees
|
|
47
49
|
def svg(crossed: false)
|
48
50
|
raise USPSFlags::Errors::UnknownBurgee unless USPSFlags::Burgees.available.include?(@squadron)
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
header_opts = { width: 1200, height: 600, scale: 7.25 }
|
53
|
-
else
|
54
|
-
burgee = core(@squadron)
|
55
|
-
header_opts = {}
|
56
|
-
end
|
52
|
+
burgee = crossed ? crossed(@squadron) : core(@squadron)
|
53
|
+
header_opts = crossed ? { width: 1200, height: 600, scale: 7.25 } : {}
|
57
54
|
|
58
55
|
@svg = <<~SVG
|
59
56
|
#{USPSFlags::Core.headers(header_opts.merge(title: @title))}
|
@@ -64,7 +61,7 @@ class USPSFlags::Burgees
|
|
64
61
|
USPSFlags::Helpers.output(@svg, outfile: @outfile)
|
65
62
|
end
|
66
63
|
|
67
|
-
|
64
|
+
private
|
68
65
|
|
69
66
|
def core(burgee)
|
70
67
|
if custom?(burgee)
|
@@ -88,8 +85,8 @@ class USPSFlags::Burgees
|
|
88
85
|
|
89
86
|
def title(burgee)
|
90
87
|
burgee_string = burgee.to_s
|
91
|
-
|
92
|
-
burgee_string.gsub(
|
88
|
+
if burgee_string.match?(/_/)
|
89
|
+
burgee_string.gsub('_', ' ').split(' ').map { |word| word.capitalize }.join(' ') + ' Burgee'
|
93
90
|
else
|
94
91
|
"#{burgee_string.capitalize} Burgee"
|
95
92
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Helper class for handling built-in burgees.
|
2
4
|
#
|
3
5
|
# @private
|
@@ -6,12 +8,13 @@ class USPSFlags::Burgees::Builtins
|
|
6
8
|
|
7
9
|
def self.available
|
8
10
|
Dir.glob("#{@@builtins_dir}/**/*.svg").map { |b|
|
9
|
-
b.split(
|
11
|
+
b.split('/').last.split('.svg').first
|
10
12
|
}.map(&:to_sym)
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.get(burgee)
|
14
16
|
raise USPSFlags::Errors::UnknownBurgee "Looked in #{@@builtins_dir}" unless self.available.include?(burgee)
|
17
|
+
|
15
18
|
::File.read("#{@@builtins_dir}/#{burgee}.svg")
|
16
19
|
end
|
17
20
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Extension of USPSFlags::Config to allow including custom burgee files.
|
2
4
|
#
|
3
5
|
# @private
|
@@ -10,7 +12,8 @@ class USPSFlags::Config
|
|
10
12
|
yield self if block_given?
|
11
13
|
end
|
12
14
|
|
13
|
-
|
15
|
+
private
|
16
|
+
|
14
17
|
def get_extension_defaults
|
15
18
|
@burgees_dir ||= defined?(::Rails) ? "#{::Rails.root}/app/lib/usps-burgees" : "#{File.dirname(__dir__)}/output"
|
16
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Helper class for generating crossed-staves.
|
2
4
|
#
|
3
5
|
# @private
|
@@ -11,12 +13,12 @@ class USPSFlags::Burgees::Crossed
|
|
11
13
|
<g id="burgee" transform="translate(3000) rotate(30)">
|
12
14
|
#{svg}
|
13
15
|
</g>
|
14
|
-
|
16
|
+
|
15
17
|
<g id="ensign" transform="scale(-0.9765625, 0.9765625) rotate(30)">
|
16
18
|
#{ensign}
|
17
19
|
</g>
|
18
20
|
</g>
|
19
|
-
|
21
|
+
|
20
22
|
<g id="flag-poles">
|
21
23
|
<rect fill="#041E42" x="0" y="0" width="150" height="4000" transform="rotate(-30)" />
|
22
24
|
<rect fill="#041E42" x="0" y="0" width="150" height="4000" transform="translate(2850) rotate(30, 150, 0)" />
|
@@ -1,15 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Helper class for handling user-provided burgees.
|
2
4
|
#
|
3
5
|
# @private
|
4
6
|
class USPSFlags::Burgees::Customs
|
5
7
|
def self.available
|
6
8
|
Dir.glob("#{USPSFlags.configuration.burgees_dir}/**/*.svg").map do |b|
|
7
|
-
b.split(
|
9
|
+
b.split('/').last.split('.svg').first.to_sym
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.get(burgee)
|
12
14
|
raise USPSFlags::Errors::UnknownBurgee unless self.available.include?(burgee)
|
15
|
+
|
13
16
|
::File.read("#{USPSFlags.configuration.burgees_dir}/#{burgee}.svg")
|
14
17
|
end
|
15
18
|
end
|
@@ -1,10 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Custom errors.
|
2
4
|
#
|
3
5
|
# @private
|
4
|
-
|
5
|
-
class
|
6
|
-
|
7
|
-
|
6
|
+
class USPSFlags
|
7
|
+
class Errors
|
8
|
+
class UnknownBurgee < StandardError
|
9
|
+
def initialize(msg = 'You have requested an unknown burgee.')
|
10
|
+
super(msg)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/setup'
|
2
4
|
Bundler.setup
|
3
5
|
require 'simplecov'
|
@@ -12,8 +14,8 @@ RSpec::Expectations.configuration.on_potential_false_positives = :nothing
|
|
12
14
|
|
13
15
|
RSpec.configure do |config|
|
14
16
|
config.before(:suite) do
|
15
|
-
$tmp_flags_dir =
|
16
|
-
$tmp_burgees_dir =
|
17
|
+
$tmp_flags_dir = 'tmp/flags'
|
18
|
+
$tmp_burgees_dir = 'tmp/path/to/burgees'
|
17
19
|
|
18
20
|
USPSFlags.configure do |c|
|
19
21
|
c.flags_dir = $tmp_flags_dir
|
@@ -22,7 +24,7 @@ RSpec.configure do |config|
|
|
22
24
|
end
|
23
25
|
|
24
26
|
config.after(:suite) do
|
25
|
-
::FileUtils.rm_rf(
|
27
|
+
::FileUtils.rm_rf('tmp') if ::Dir.exist?('tmp')
|
26
28
|
::FileUtils.rm_rf(USPSFlags.configuration.burgees_dir) if ::Dir.exist?(USPSFlags.configuration.burgees_dir)
|
27
29
|
end
|
28
30
|
end
|
@@ -1,25 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe USPSFlags::Config do
|
4
|
-
describe
|
5
|
-
it
|
6
|
+
describe 'general configuration' do
|
7
|
+
it 'should correctly set the burgees_dir in USPSFlags::Config' do
|
6
8
|
expect(USPSFlags.configuration.burgees_dir).to eql($tmp_burgees_dir)
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
10
|
-
describe
|
12
|
+
describe 'Rails configuration' do
|
11
13
|
before(:each) do
|
12
14
|
class Rails
|
13
15
|
def self.root
|
14
|
-
|
16
|
+
'tmp/rails_app'
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
20
|
@config = USPSFlags::Config.new
|
19
21
|
end
|
20
22
|
|
21
|
-
it
|
22
|
-
expect(@config.burgees_dir).to eql(
|
23
|
+
it 'should use the default Rails log directory' do
|
24
|
+
expect(@config.burgees_dir).to eql('tmp/rails_app/app/lib/usps-burgees')
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -1,23 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe USPSFlags::Burgees do
|
4
|
-
it
|
6
|
+
it 'should return the list of available burgees from available' do
|
5
7
|
expect(USPSFlags::Burgees.available).to eql([:birmingham])
|
6
8
|
end
|
7
9
|
|
8
|
-
it
|
10
|
+
it 'should raise USPSFlags::Errors::UnknownBurgee if an invalid burgee is entered' do
|
9
11
|
@burgee = USPSFlags::Burgees.new do |b|
|
10
12
|
b.squadron = :not_a_squadron
|
11
|
-
b.outfile =
|
13
|
+
b.outfile = ''
|
12
14
|
end
|
13
15
|
|
14
16
|
expect { @burgee.svg }.to raise_error(USPSFlags::Errors::UnknownBurgee)
|
15
17
|
end
|
16
18
|
|
17
|
-
it
|
19
|
+
it 'should generate a burgee from the builtins' do
|
18
20
|
@burgee = USPSFlags::Burgees.new do |b|
|
19
21
|
b.squadron = :birmingham
|
20
|
-
b.outfile =
|
22
|
+
b.outfile = ''
|
21
23
|
end
|
22
24
|
|
23
25
|
expect(@burgee.svg).to include(
|
@@ -36,7 +38,6 @@ describe USPSFlags::Burgees do
|
|
36
38
|
<desc id="trademark-desc">This image is a registered trademark of United States Power Squadrons.</desc>
|
37
39
|
<desc id="trademark-link">https://www.usps.org/images/secretary/itcom/trademark.pdf</desc>
|
38
40
|
</metadata>
|
39
|
-
|
40
41
|
<g transform="translate(0.000000,2000.000000) scale(0.1,0.1)" fill="#1086FF" stroke="none">
|
41
42
|
<polyline points="0,-20000 30000,-10000 0,0" fill="#1086FF" />
|
42
43
|
<path d="M 22500 -10750
|
@@ -115,29 +116,29 @@ describe USPSFlags::Burgees do
|
|
115
116
|
)
|
116
117
|
end
|
117
118
|
|
118
|
-
it
|
119
|
+
it 'should generate a burgee from the custom directory' do
|
119
120
|
@custom_file = "#{USPSFlags.configuration.burgees_dir}/birmingham.svg"
|
120
121
|
::FileUtils.mkdir_p(USPSFlags.configuration.burgees_dir)
|
121
|
-
::FileUtils.cp(
|
122
|
-
f = ::File.open(@custom_file,
|
123
|
-
f.write(
|
122
|
+
::FileUtils.cp('lib/usps_flags/burgees/builtins/birmingham.svg', @custom_file)
|
123
|
+
f = ::File.open(@custom_file, 'w+')
|
124
|
+
f.write('<!-- Custom -->')
|
124
125
|
f.close
|
125
126
|
|
126
127
|
@burgee = USPSFlags::Burgees.new do |b|
|
127
128
|
b.squadron = :birmingham
|
128
|
-
b.outfile =
|
129
|
+
b.outfile = ''
|
129
130
|
end
|
130
131
|
|
131
|
-
expect(@burgee.svg).to include(
|
132
|
-
expect(@burgee.svg).to include(
|
132
|
+
expect(@burgee.svg).to include('<title>Birmingham Burgee</title>')
|
133
|
+
expect(@burgee.svg).to include('<!-- Custom -->')
|
133
134
|
|
134
135
|
::FileUtils.rm_rf(USPSFlags.configuration.burgees_dir)
|
135
136
|
end
|
136
137
|
|
137
|
-
it
|
138
|
+
it 'should generate a crossed-staves burgee' do
|
138
139
|
@burgee = USPSFlags::Burgees.new do |b|
|
139
140
|
b.squadron = :birmingham
|
140
|
-
b.outfile =
|
141
|
+
b.outfile = ''
|
141
142
|
end
|
142
143
|
|
143
144
|
expect(@burgee.svg(crossed: true)).to include('<g id="crossed-flags"')
|
data/usps_flags-burgees.gemspec
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = 'usps_flags-burgees'
|
3
|
-
s.version = '0.0
|
4
|
-
s.date = '2019-06-
|
5
|
+
s.version = '0.1.0'
|
6
|
+
s.date = '2019-06-08'
|
5
7
|
s.summary = 'Flag generator for United States Power Squadrons burgees'
|
6
8
|
s.description = 'An extension to the flag image (PNG, SVG) generator for United States Power Squadrons to generate burgees.'
|
7
9
|
s.homepage = 'http://rubygems.org/gems/usps_flags-burgees'
|
@@ -14,7 +16,7 @@ Gem::Specification.new do |s|
|
|
14
16
|
|
15
17
|
s.required_ruby_version = '~> 2.4'
|
16
18
|
|
17
|
-
s.add_runtime_dependency 'usps_flags', '~> 0.
|
19
|
+
s.add_runtime_dependency 'usps_flags', '~> 0.5', '>= 0.5.1'
|
18
20
|
|
19
21
|
s.add_development_dependency 'rake', '~> 12.2', '>= 12.2.1'
|
20
22
|
s.add_development_dependency 'rspec', '~> 3.7', '>= 3.7.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usps_flags-burgees
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.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: 2019-06-
|
11
|
+
date: 2019-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: usps_flags
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.5'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.5.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
29
|
+
version: '0.5'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.5.1
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.6
|
143
|
+
rubygems_version: 2.7.6
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Flag generator for United States Power Squadrons burgees
|