usps_flags-grades 0.0.9 → 0.0.10

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
  SHA256:
3
- metadata.gz: 05ef811705f59246447d5cb9642e13c36407dae0baee020e37c3a7f48c5ff056
4
- data.tar.gz: 9c06c5ff525ec4cc62fc9d11d0137d0d2b0aaef9c85b67dd4491815c5b8d22eb
3
+ metadata.gz: 271a447b5f4384d9153f4b836eb24f6502bf8ae10f276151871248c4c414176d
4
+ data.tar.gz: 2423607b8cfc2571c754f66c1da65075d1429bb31704644de4efc14f0a41fa4f
5
5
  SHA512:
6
- metadata.gz: 77387cba6b6e2927cd2c683d45ef396b0d534fedf150d52a34efd5dc9d3169ab6745ceb94c5e64e33a738d75886f8d08b6e5f3fbe15e0ffd496f7d252aa7460d
7
- data.tar.gz: 5e9423feff3fd75ce60a61691dd5fa673bc951eb7c1f2b7827d9477e50bd9ff616376b4433193a05c534dffff47fc8c08bf60d41d4a49848b1821a33f99c2658
6
+ metadata.gz: 271530863b761dde5a7c83a6b582071b3323b5285f16636ed503c9159ed3eb979b688a5f7e2a31da30274ad874ec0692879e517d4b591a58b08bdfed0514b870
7
+ data.tar.gz: ef7e8099916ed471b6d373924a237051a78d2b9ab87edc609884b0e8703eaf448923a3056029fd0814c9390652b2f44d0041846c830812421376c5db8f26d20b
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  doc/
2
- coverage/
2
+ coverage/
3
+ output/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps_flags-grades (0.0.9)
4
+ usps_flags-grades (0.0.10)
5
5
  usps_flags (~> 0.4, >= 0.4.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -18,6 +18,13 @@ insignia = USPSFlags::Grades.new do |g|
18
18
  g.outfile = "/path/to/svg/output.svg"
19
19
  end
20
20
 
21
+ insignia = USPSFlags::Grades.new(
22
+ grade: :sn,
23
+ membership: :senior,
24
+ merit_marks: 20,
25
+ outfile: "/path/to/svg/output.svg"
26
+ )
27
+
21
28
  insignia.svg #=> Generates SVG file at "/path/to/svg/output.svg"
22
29
  ```
23
30
 
@@ -9,6 +9,12 @@ class USPSFlags::Grades
9
9
  require 'usps_flags/grades/edpro'
10
10
  require 'usps_flags/grades/merit_marks'
11
11
 
12
+ ALL_CONFIGS ||= [
13
+ [:s, false, nil], [:p, false, nil], [:ap, false, nil], [:ap, true, nil],
14
+ [:jn, false, nil], [:jn, true, nil], [:n, false, nil], [:n, true, nil],
15
+ [:sn, false, nil], [nil, false, :senior], [nil, false, :life]
16
+ ].freeze
17
+
12
18
  # Constructor for generating grade insignia.
13
19
  #
14
20
  # @example Generate JN with EdPro and Senior Member
@@ -20,12 +26,12 @@ class USPSFlags::Grades
20
26
  # end
21
27
  #
22
28
  # insignia.svg #=> Generates SVG file at "/path/to/svg/output.svg"
23
- def initialize
24
- @grade = nil
25
- @edpro = false
26
- @membership = nil
27
- @merit_marks = 0
28
- @outfile = nil
29
+ def initialize(options = {})
30
+ @grade = options[:grade] || nil
31
+ @edpro = options[:edpro] || false
32
+ @membership = options[:membership] || nil
33
+ @merit_marks = options[:merit_marks] || 0
34
+ @outfile = options[:outfile] || nil
29
35
  @generated_at = Time.now.strftime("%Y%m%d.%H%S%z")
30
36
  yield self if block_given?
31
37
  end
@@ -73,6 +79,22 @@ class USPSFlags::Grades
73
79
  "#{grade}#{edpro}#{membership}"
74
80
  end
75
81
 
82
+ def self.all(dir = nil)
83
+ dir ||= USPSFlags.configuration.flags_dir
84
+
85
+ ALL_CONFIGS.each do |grade, edpro, membership|
86
+ path = "#{dir}/#{grade}"
87
+ path += '_edpro' if edpro
88
+
89
+ insignia = USPSFlags::Grades.new(
90
+ grade: grade, edpro: edpro, membership: membership,
91
+ outfile: "#{path}.svg"
92
+ )
93
+
94
+ USPSFlags::Generate.png(insignia.svg, outfile: "#{path}.png", trim: true)
95
+ end
96
+ end
97
+
76
98
  private
77
99
 
78
100
  def validate
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'usps_flags-grades'
3
- s.version = '0.0.9'
4
- s.date = '2019-06-01'
3
+ s.version = '0.0.10'
4
+ s.date = '2019-06-02'
5
5
  s.summary = 'Insignia generator for United States Power Squadrons'
6
6
  s.description = 'An extension to the flag image (PNG, SVG) generator for United States Power Squadrons to generate grade insignia.'
7
7
  s.homepage = 'http://rubygems.org/gems/usps_flags-grades'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps_flags-grades
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
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-01 00:00:00.000000000 Z
11
+ date: 2019-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: usps_flags