slice_rename 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c39f6bd103c00ab992d7b9c17f6c08b6a0cdf38
4
- data.tar.gz: 0e337de5de580b2b097cf6305457b42263b34310
3
+ metadata.gz: aac69eaad8ffe87dfad9544205cabbc910fdf99d
4
+ data.tar.gz: 3450638f1bb048993031bd9ff8e912d4c6a0b108
5
5
  SHA512:
6
- metadata.gz: 8f06d1977e0a6a71bdb9cfb41482126cc34ba8b77e15496ce7bbc4c06cd7a89f63c856fbf7a7777dd8201242976650a5ce5f4f8794e56354e3a941df20833763
7
- data.tar.gz: 060c59b227d0ba97d10b0f6f364a0b8bd8dc7d82696c743989d3ec772c4f64a44c958c7fc5b0860b31e02b84e15fa3360b84e8a92cacc9e4c65b9ee3daa87a75
6
+ metadata.gz: 4bf959f753e60da6758a368b222c744f39b84113ffade1fdd0bd948c565ffeb67936e7104313fc60f67622c3b16a96ea91ac5f0303f38f31fb2e43d776e0c24c
7
+ data.tar.gz: d0245a15c94568ed488dc653e0a143f5ec910ec2795780e922bfeda75f06c31a34d776d145d2a077fa3e6c649d4986c83e633cbb64390c9362995c63ba6b1d4f
@@ -1,7 +1,6 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slice_rename (0.4.0)
5
4
 
6
5
  GEM
7
6
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -7,9 +7,15 @@ configuration file. The output will be placed in the same folder as the input
7
7
  image. If you don't provide a configuration file it will use default settings
8
8
  which aren't useful for anything.
9
9
 
10
+ The `fallback` argument can be used if you are combining slices but are missing
11
+ some slices for the specific variation. When combining slices it will first
12
+ look for a file based on the input path (name + suffix), if it doesn't find a
13
+ file that way it will use the fallback (fallback + suffix).
14
+
10
15
  ```
11
16
  -c, --config MANDATORY Configuration file (see below)
12
17
  -k, --combine Combine all slices to one image
18
+ -f, --fallback A base name used if a file can't be found
13
19
  -d, --debug Output debug info
14
20
  -v, --version Display the version
15
21
  -h, --help Display this message
data/Rakefile CHANGED
@@ -30,6 +30,6 @@ namespace :run do
30
30
  end
31
31
 
32
32
  task :char do
33
- ruby '-I ./lib bin/slice_rename spec/fixtures/char4/char4.png -d -k -c spec/fixtures/config_new.yml'
33
+ ruby '-I ./lib bin/slice_rename spec/fixtures/char4/char1.png -d -k -f char4 -c spec/fixtures/config_new.yml'
34
34
  end
35
35
  end
@@ -1,5 +1,5 @@
1
1
  require 'slice_rename/cli'
2
2
 
3
3
  module SliceRename
4
- VERSION = '0.5.1'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -21,6 +21,10 @@ module SliceRename
21
21
  combine = true
22
22
  end
23
23
 
24
+ opts.on("-f", "--fallback [FALLBACK]", "A base name used if a file can't be found") do |v|
25
+ config.fallback = v
26
+ end
27
+
24
28
  opts.on("-d", "--debug", "Output debug info") do |v|
25
29
  config.debug = true
26
30
  end
@@ -15,7 +15,14 @@ module SliceRename
15
15
 
16
16
  config.suffixes.each do |suffix|
17
17
  if suffix != nil
18
- images << "#{path}/#{name}#{suffix}#{extension}"
18
+ input_path = "#{path}/#{name}#{suffix}#{extension}"
19
+
20
+ if !Pathname.new(input_path).file?
21
+ input_path = "#{path}/#{config.fallback}#{suffix}#{extension}"
22
+ input_path = 'null:' if !Pathname.new(input_path).file?
23
+ end
24
+
25
+ images << input_path
19
26
  else
20
27
  images << 'null:'
21
28
  end
@@ -2,7 +2,7 @@ require 'yaml'
2
2
 
3
3
  module SliceRename
4
4
  class Config
5
- attr_accessor :path, :debug
5
+ attr_accessor :path, :debug, :fallback
6
6
  attr_reader :rows, :columns, :width, :height, :padding, :collapse_padding,
7
7
  :padding_color, :background_color
8
8
 
@@ -18,6 +18,7 @@ module SliceRename
18
18
  @collapse_padding = false
19
19
  @padding_color = 'none'
20
20
  @background_color = 'none'
21
+ @fallback = ''
21
22
  end
22
23
 
23
24
  def load(config_path)
@@ -60,5 +60,21 @@ RSpec.describe SliceRename::Config do
60
60
  it 'exposes a list of suffixes for the resulting file names' do
61
61
  expect(config.suffixes).to be_an Array
62
62
  end
63
+
64
+ it 'exposes the wether to collapse padding or not' do
65
+ expect(config.collapse_padding).to be_falsy
66
+ end
67
+
68
+ it 'exposes the padding color' do
69
+ expect(config.padding_color).to be_a String
70
+ end
71
+
72
+ it 'exposes the background color' do
73
+ expect(config.background_color).to be_a String
74
+ end
75
+
76
+ it 'exposes the fallback file name' do
77
+ expect(config.fallback).to be_a String
78
+ end
63
79
  end
64
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slice_rename
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoee Silcock