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 +4 -4
- data/Gemfile.lock +0 -1
- data/README.md +6 -0
- data/Rakefile +1 -1
- data/lib/slice_rename.rb +1 -1
- data/lib/slice_rename/cli.rb +4 -0
- data/lib/slice_rename/combiner.rb +8 -1
- data/lib/slice_rename/config.rb +2 -1
- data/spec/slice_rename/config_spec.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aac69eaad8ffe87dfad9544205cabbc910fdf99d
|
4
|
+
data.tar.gz: 3450638f1bb048993031bd9ff8e912d4c6a0b108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bf959f753e60da6758a368b222c744f39b84113ffade1fdd0bd948c565ffeb67936e7104313fc60f67622c3b16a96ea91ac5f0303f38f31fb2e43d776e0c24c
|
7
|
+
data.tar.gz: d0245a15c94568ed488dc653e0a143f5ec910ec2795780e922bfeda75f06c31a34d776d145d2a077fa3e6c649d4986c83e633cbb64390c9362995c63ba6b1d4f
|
data/Gemfile.lock
CHANGED
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/
|
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
|
data/lib/slice_rename.rb
CHANGED
data/lib/slice_rename/cli.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/slice_rename/config.rb
CHANGED
@@ -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
|