ebook_renamer 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +95 -1
- data/{CHANGELOGS.md → CHANGELOG.md} +6 -0
- data/Gemfile +1 -1
- data/README.md +47 -78
- data/Rakefile +7 -7
- data/bin/ebook_renamer +6 -2
- data/ebook_renamer.gemspec +1 -1
- data/lib/ebook_renamer.rb +7 -7
- data/lib/ebook_renamer/cli.rb +21 -18
- data/lib/ebook_renamer/logger.rb +1 -1
- data/lib/ebook_renamer/utils.rb +21 -21
- data/lib/ebook_renamer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6bba50365efb81f33dce0f30ef03102b16403c4
|
4
|
+
data.tar.gz: bbb8ad9d2bd0bf5848d296c3c036ff7fa1a79747
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 598190f6dff26c016d9b18b68bd635469d53d3a9f28bbc3ced27a4cd42ba321369ab62d4a45ae33bc68d9092707ed50b08f256b80cee3f155f57b36fbd0fca2c
|
7
|
+
data.tar.gz: e1d9e9328d652e45317e71f349d0d615db64d2f8cb0d2f9bb1324201321f2783f2de19f7cc098a67eb8876ef856c72726f19b6c79e8e5a5e0a8fd6bc0f06b583
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1 +1,95 @@
|
|
1
|
-
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- Gemfile
|
4
|
+
- Rakefile
|
5
|
+
- bin/*
|
6
|
+
- ebook_renamer.gemspec
|
7
|
+
- lib/**/*.rb
|
8
|
+
- test/**/*.rb
|
9
|
+
# Avoid long parameter lists
|
10
|
+
ParameterLists:
|
11
|
+
Max: 5
|
12
|
+
CountKeywordArgs: true
|
13
|
+
|
14
|
+
MethodLength:
|
15
|
+
CountComments: false
|
16
|
+
Max: 15
|
17
|
+
|
18
|
+
# Avoid more than `Max` levels of nesting.
|
19
|
+
BlockNesting:
|
20
|
+
Max: 4
|
21
|
+
|
22
|
+
# Align with the style guide.
|
23
|
+
CollectionMethods:
|
24
|
+
PreferredMethods:
|
25
|
+
collect: 'map'
|
26
|
+
inject: 'reduce'
|
27
|
+
find: 'detect'
|
28
|
+
find_all: 'select'
|
29
|
+
|
30
|
+
# Do not force public/protected/private keyword to be indented at the same
|
31
|
+
# level as the def keyword. My personal preference is to outdent these keywords
|
32
|
+
# because I think when scanning code it makes it easier to identify the
|
33
|
+
# sections of code and visually separate them. When the keyword is at the same
|
34
|
+
# level I think it sort of blends in with the def keywords and makes it harder
|
35
|
+
# to scan the code and see where the sections are.
|
36
|
+
AccessModifierIndentation:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
# Limit line length
|
40
|
+
LineLength:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# Disable documentation checking until a class needs to be documented once
|
44
|
+
Documentation:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
# Enforce Ruby 1.8-compatible hash syntax
|
48
|
+
HashSyntax:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
# No spaces inside hash literals
|
52
|
+
SpaceInsideHashLiteralBraces:
|
53
|
+
EnforcedStyle: no_space
|
54
|
+
|
55
|
+
# Allow dots at the end of lines
|
56
|
+
DotPosition:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
# Don't require magic comment at the top of every file
|
60
|
+
Encoding:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
# Enforce outdenting of access modifiers (i.e. public, private, protected)
|
64
|
+
AccessModifierIndentation:
|
65
|
+
EnforcedStyle: outdent
|
66
|
+
|
67
|
+
EmptyLinesAroundAccessModifier:
|
68
|
+
Enabled: true
|
69
|
+
|
70
|
+
# Align ends correctly
|
71
|
+
EndAlignment:
|
72
|
+
AlignWith: variable
|
73
|
+
|
74
|
+
# Indentation of when/else
|
75
|
+
CaseIndentation:
|
76
|
+
IndentWhenRelativeTo: end
|
77
|
+
IndentOneStep: false
|
78
|
+
|
79
|
+
DoubleNegation:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
PercentLiteralDelimiters:
|
83
|
+
PreferredDelimiters:
|
84
|
+
'%': ()
|
85
|
+
'%i': ()
|
86
|
+
'%q': ()
|
87
|
+
'%Q': ()
|
88
|
+
'%r': '{}'
|
89
|
+
'%s': ()
|
90
|
+
'%w': '[]'
|
91
|
+
'%W': '[]'
|
92
|
+
'%x': ()
|
93
|
+
|
94
|
+
StringLiterals:
|
95
|
+
EnforcedStyle: double_quotes
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -57,28 +57,55 @@ The shortest command that you can run to rename files is
|
|
57
57
|
# This will rename any ebook files under the directory `~/Dropbox/ebooks`
|
58
58
|
# and any sub-directory for (*.epub, *.pdf, *.mobi) using the default settings
|
59
59
|
cd ~/Dropbox/ebooks
|
60
|
-
ebook_renamer
|
60
|
+
ebook_renamer --commit
|
61
61
|
```
|
62
62
|
|
63
|
-
To see what the result would be like without making any changes
|
63
|
+
To see what the result would be like without making any changes
|
64
64
|
|
65
65
|
```sh
|
66
|
-
cd ~/Dropbox/ebooks
|
67
|
-
ebook_renamer
|
66
|
+
cd ~/Dropbox/ebooks/
|
67
|
+
ebook_renamer --base-dir .
|
68
|
+
```
|
69
|
+
|
70
|
+
Should see the result like
|
71
|
+
|
72
|
+
```
|
73
|
+
-----------------------------------------------------------
|
74
|
+
FYI: no changes as this is a dry-run, please use --commit
|
75
|
+
-----------------------------------------------------------
|
76
|
+
1 of 4 old name : ./demo1.pdf
|
77
|
+
1 of 4 new name : ./Fearless.Refactoring.by.Andrzej.Krzywda.pdf
|
78
|
+
2 of 4 old name : ./demo2.epub
|
79
|
+
2 of 4 new name : ./EPUB.3.0.Specification.by.EPUB.3.Working.Group.epub
|
80
|
+
3 of 4 old name : ./subdir/demo3.pdf
|
81
|
+
3 of 4 new name : ./subdir/Reliably.Deploying.Rails.Applications.by.Ben.Dixon.pdf
|
82
|
+
4 of 4 old name : ./subdir/demo4.epub
|
83
|
+
4 of 4 new name : ./subdir/EPUB.3.0.Specification.by.EPUB.3.Working.Group.epub
|
84
|
+
```
|
85
|
+
|
86
|
+
with `--sep-string` option
|
87
|
+
|
88
|
+
```sh
|
89
|
+
cd ~/Dropbox/ebooks/
|
90
|
+
ebook_renamer --base-dir . --sep-string _
|
68
91
|
```
|
69
|
-
|
92
|
+
|
93
|
+
Should see the result like
|
70
94
|
|
71
95
|
```
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
96
|
+
-----------------------------------------------------------
|
97
|
+
FYI: no changes as this is a dry-run, please use --commit
|
98
|
+
-----------------------------------------------------------
|
99
|
+
1 of 4 old name : ./demo1.pdf
|
100
|
+
1 of 4 new name : ./Fearless_Refactoring_by_Andrzej_Krzywda.pdf
|
101
|
+
2 of 4 old name : ./demo2.epub
|
102
|
+
2 of 4 new name : ./EPUB_3_0_Specification_by_EPUB_3_Working_Group.epub
|
103
|
+
3 of 4 old name : ./subdir/demo3.pdf
|
104
|
+
3 of 4 new name : ./subdir/Reliably_Deploying_Rails_Applications_by_Ben_Dixon.pdf
|
105
|
+
4 of 4 old name : ./subdir/demo4.epub
|
106
|
+
4 of 4 new name : ./subdir/EPUB_3_0_Specification_by_EPUB_3_Working_Group.epub
|
81
107
|
```
|
108
|
+
|
82
109
|
### Detail Usage
|
83
110
|
|
84
111
|
Run the following command from the directory that contain the file(s) that
|
@@ -90,84 +117,26 @@ cd ~/Dropbox/ebooks/
|
|
90
117
|
|
91
118
|
# Or specify the directory as an option from any where if you set appropriate
|
92
119
|
# version of ruby (e.g. rbenv local 2.1.1 or rvm use 2.1.1)
|
93
|
-
ebook_renamer
|
120
|
+
ebook_renamer --base-dir ~/Dropbox/ebooks/samples
|
94
121
|
|
95
122
|
# For help on how to use the gem just type without any options.
|
96
123
|
ebook_renamer
|
97
124
|
|
98
125
|
# Run the command without making any changes to the files (dry-run) in the current directory
|
99
|
-
ebook_renamer
|
126
|
+
ebook_renamer --base-dir . --recursive
|
100
127
|
|
101
128
|
# Once you are happy with the result then
|
102
|
-
ebook_renamer
|
129
|
+
ebook_renamer --base-dir . --recursive --commit
|
103
130
|
|
104
131
|
# Or using the short version
|
105
|
-
|
106
|
-
$ebook_renamer rename -b . -r -c
|
107
|
-
```
|
108
|
-
|
109
|
-
### Example Outputs
|
110
|
-
|
111
|
-
Original files before
|
112
|
-
|
132
|
+
ebook_renamer -b . -r -c
|
113
133
|
```
|
114
|
-
test/fixtures/
|
115
|
-
└── ebooks
|
116
|
-
├── demo1.pdf
|
117
|
-
├── demo2.epub
|
118
|
-
└── subdir
|
119
|
-
├── demo1.pdf
|
120
|
-
└── demo2.epub
|
121
|
-
2 directories, 4 files
|
122
|
-
```
|
123
|
-
|
124
|
-
Run the command without making any changes
|
125
|
-
|
126
|
-
```sh
|
127
|
-
ebook_renamer rename --base-dir ./test/fixtures/ebooks --recursive
|
128
|
-
```
|
129
|
-
|
130
|
-
You should see the result like the following
|
131
|
-
|
132
|
-
```
|
133
|
-
Changes will not be applied without the --commit option.
|
134
|
-
1 of 4::[./demo1.pdf] -> [./Fearless.Refactoring.by.Andrzej.Krzywda.pdf]
|
135
|
-
2 of 4::[./demo2.epub] -> [./EPUB.3.0.Specification.by.EPUB.3.Working.Group.epub]
|
136
|
-
3 of 4::[./subdir/demo1.pdf] -> [./subdir/Reliably.Deploying.Rails.Applications.by.Ben.Dixon.pdf]
|
137
|
-
4 of 4::[./subdir/demo2.epub] -> [./subdir/EPUB.3.0.Specification.by.EPUB.3.Working.Group.epub]
|
138
|
-
```
|
139
|
-
|
140
|
-
To actually make the actual rename just pass in the `--commit` option like so:
|
141
|
-
|
142
|
-
```sh
|
143
|
-
ebook_renamer rename --base-dir ./test/fixtures/ebooks --recursive --commit
|
144
|
-
```
|
145
|
-
or the short version
|
146
|
-
|
147
|
-
```sh
|
148
|
-
ebook_renamer rename -b ./test/fixtures/ebooks -r -c
|
149
|
-
```
|
150
|
-
|
151
|
-
The final output should be something like:
|
152
|
-
|
153
|
-
```
|
154
|
-
test/fixtures/
|
155
|
-
└── ebooks
|
156
|
-
├── Fearless.Refactoring.by.Andrzej.Krzywda.pdf
|
157
|
-
├── EPUB.3.0.Specification.by.EPUB.3.Working.Group.epub
|
158
|
-
└── subdir
|
159
|
-
├── Fearless.Refactoring.by.Andrzej.Krzywda.pdf
|
160
|
-
└── EPUB.3.0.Specification.by.EPUB.3.Working.Group.epub
|
161
|
-
2 directories, 4 files
|
162
|
-
```
|
163
|
-
|
164
|
-
### Sample Usage
|
165
134
|
|
166
|
-
|
135
|
+
### Usage/Synopsis
|
167
136
|
|
168
137
|
```
|
169
138
|
Usage:
|
170
|
-
ebook_renamer
|
139
|
+
ebook_renamer
|
171
140
|
|
172
141
|
Options:
|
173
142
|
-b, [--base-dir=BASE_DIR] # Base directory
|
data/Rakefile
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
4
|
Rake::TestTask.new do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.test_files = FileList[
|
5
|
+
t.libs << "lib/ebook_renamer"
|
6
|
+
t.test_files = FileList["test/lib/ebook_renamer/test_*.rb"]
|
7
7
|
t.verbose = true
|
8
8
|
end
|
9
9
|
|
10
10
|
task default: :test
|
11
11
|
|
12
12
|
task :pry do
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
13
|
+
require "pry"
|
14
|
+
require "awesome_print"
|
15
|
+
require "ebook_renamer"
|
16
16
|
include EbookRenamer
|
17
17
|
ARGV.clear
|
18
18
|
Pry.start
|
data/bin/ebook_renamer
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require_relative
|
2
|
+
require_relative "../lib/ebook_renamer"
|
3
3
|
include EbookRenamer
|
4
|
-
|
4
|
+
if ARGV.empty?
|
5
|
+
EbookRenamer::CLI.start(%w[usage])
|
6
|
+
else
|
7
|
+
EbookRenamer::CLI.start(%w[rename].concat(ARGV))
|
8
|
+
end
|
data/ebook_renamer.gemspec
CHANGED
data/lib/ebook_renamer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
1
|
+
require "thor"
|
2
|
+
require "code_lister"
|
3
|
+
require "agile_utils"
|
4
|
+
require_relative "ebook_renamer/version"
|
5
|
+
require_relative "ebook_renamer/logger"
|
6
|
+
require_relative "ebook_renamer/utils"
|
7
|
+
require_relative "ebook_renamer/cli"
|
data/lib/ebook_renamer/cli.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require_relative
|
1
|
+
require "agile_utils"
|
2
|
+
require "code_lister"
|
3
|
+
require "fileutils"
|
4
|
+
require_relative "../ebook_renamer"
|
5
5
|
module EbookRenamer
|
6
6
|
class CLI < Thor
|
7
|
-
desc
|
7
|
+
desc "rename", "Rename multiple ebook files (pdf,epub,mobi) from a given directory"
|
8
8
|
method_option *AgileUtils::Options::BASE_DIR
|
9
9
|
method_option *AgileUtils::Options::RECURSIVE
|
10
10
|
method_option :sep_string,
|
11
|
-
aliases:
|
12
|
-
desc:
|
13
|
-
default:
|
11
|
+
aliases: "-s",
|
12
|
+
desc: "Separator string between words in output filename",
|
13
|
+
default: "."
|
14
14
|
method_option :commit,
|
15
|
-
aliases:
|
16
|
-
desc:
|
15
|
+
aliases: "-c",
|
16
|
+
desc: "Make change permanent",
|
17
17
|
type: :boolean,
|
18
18
|
default: false
|
19
19
|
method_option *AgileUtils::Options::VERSION
|
20
20
|
def rename
|
21
21
|
opts = options.symbolize_keys
|
22
22
|
# Explicitly add the :exts options
|
23
|
-
opts[:exts] = %w
|
23
|
+
opts[:exts] = %w[pdf epub mobi]
|
24
24
|
if opts[:version]
|
25
25
|
puts "You are using EbookRenamer version #{EbookRenamer::VERSION}"
|
26
26
|
exit
|
@@ -28,11 +28,11 @@ module EbookRenamer
|
|
28
28
|
execute(opts)
|
29
29
|
end
|
30
30
|
|
31
|
-
desc
|
31
|
+
desc "usage", "Display help screen"
|
32
32
|
def usage
|
33
33
|
puts <<-EOS
|
34
34
|
Usage:
|
35
|
-
ebook_renamer
|
35
|
+
ebook_renamer
|
36
36
|
|
37
37
|
Options:
|
38
38
|
-b, [--base-dir=BASE_DIR] # Base directory
|
@@ -50,7 +50,7 @@ Rename multiple ebook files (pdf,epub,mobi) from a given directory
|
|
50
50
|
|
51
51
|
default_task :usage
|
52
52
|
|
53
|
-
|
53
|
+
private
|
54
54
|
|
55
55
|
# Rename the file from the given directory
|
56
56
|
# Using the with the argurment options as follow
|
@@ -62,7 +62,7 @@ Rename multiple ebook files (pdf,epub,mobi) from a given directory
|
|
62
62
|
#
|
63
63
|
# @param args [Hash<Symbol, Object>] options argument
|
64
64
|
def execute(options = {})
|
65
|
-
meta_binary =
|
65
|
+
meta_binary = "ebook-meta"
|
66
66
|
|
67
67
|
input_files = CodeLister.files(options)
|
68
68
|
|
@@ -72,7 +72,9 @@ Rename multiple ebook files (pdf,epub,mobi) from a given directory
|
|
72
72
|
end
|
73
73
|
|
74
74
|
unless options[:commit]
|
75
|
-
puts
|
75
|
+
puts "-----------------------------------------------------------"
|
76
|
+
puts " FYI: no changes as this is a dry-run, please use --commit "
|
77
|
+
puts "-----------------------------------------------------------"
|
76
78
|
end
|
77
79
|
|
78
80
|
FileUtils.chdir(options[:base_dir])
|
@@ -80,9 +82,10 @@ Rename multiple ebook files (pdf,epub,mobi) from a given directory
|
|
80
82
|
extension = File.extname(file)
|
81
83
|
begin
|
82
84
|
hash = meta_to_hash(meta(file, meta_binary))
|
83
|
-
full_name = formatted_name(hash, sep_char:
|
85
|
+
full_name = formatted_name(hash, sep_char: " by ")
|
84
86
|
new_name = "#{File.dirname(file)}/#{sanitize_filename(full_name, options[:sep_string])}#{extension}"
|
85
|
-
puts "#{index + 1} of #{input_files.size}
|
87
|
+
puts "#{index + 1} of #{input_files.size} old name : #{file}"
|
88
|
+
puts "#{index + 1} of #{input_files.size} new name : #{new_name}"
|
86
89
|
FileUtils.mv(file, new_name) if options[:commit] && file != new_name
|
87
90
|
rescue RuntimeError => e
|
88
91
|
puts e.backtrace
|
data/lib/ebook_renamer/logger.rb
CHANGED
data/lib/ebook_renamer/utils.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require_relative
|
1
|
+
require "open3"
|
2
|
+
require "fileutils"
|
3
|
+
require "shellwords"
|
4
|
+
require_relative "../ebook_renamer"
|
5
5
|
module EbookRenamer
|
6
6
|
EbookMetaNotInstall = Class.new(StandardError)
|
7
7
|
|
@@ -10,15 +10,15 @@ module EbookRenamer
|
|
10
10
|
# @param [String] filename the input file name
|
11
11
|
# @param [String] binary the executable for use to extract the metadata
|
12
12
|
# @return [String] result of the output from running the command
|
13
|
-
def meta(filename, binary =
|
14
|
-
fail EbookMetaNotInstall,
|
13
|
+
def meta(filename, binary = "ebook-meta")
|
14
|
+
fail EbookMetaNotInstall, "Need to install ebook-meta to use this gem" if AgileUtils::Helper.which(binary).nil?
|
15
15
|
command = [
|
16
16
|
binary,
|
17
17
|
Shellwords.escape(filename)
|
18
18
|
]
|
19
19
|
|
20
|
-
stdout_str, stderr_str, status = Open3.capture3(command.join(
|
21
|
-
|
20
|
+
stdout_str, stderr_str, status = Open3.capture3(command.join(" "))
|
21
|
+
fail "Problem processing #{filename}" unless status.success?
|
22
22
|
stdout_str
|
23
23
|
end
|
24
24
|
|
@@ -55,11 +55,11 @@ module EbookRenamer
|
|
55
55
|
#
|
56
56
|
# @return [String] the new file name with special characters replaced or removed.
|
57
57
|
def sanitize_filename(filename, sep_char = nil)
|
58
|
-
dot =
|
58
|
+
dot = "."
|
59
59
|
# Note exclude the '.' (dot)
|
60
60
|
filename.gsub!(/[^0-9A-Za-z\-_ ]/, dot)
|
61
61
|
# replace multiple occurrences of a given char with a dot
|
62
|
-
[
|
62
|
+
["-", "_", " "].each do |c|
|
63
63
|
filename.gsub!(/#{Regexp.quote(c)}+/, dot)
|
64
64
|
end
|
65
65
|
|
@@ -75,16 +75,16 @@ module EbookRenamer
|
|
75
75
|
# @param [Hash<Symbol,String>] fields list of fields that will be used to set the name
|
76
76
|
def formatted_name(meta_hash = {}, fields = {})
|
77
77
|
if hash.nil? || fields.nil?
|
78
|
-
fail ArgumentError.new(
|
78
|
+
fail ArgumentError.new("Argument must not be nil")
|
79
79
|
end
|
80
80
|
|
81
81
|
# The keys that we get from the 'mdls' or 'exiftool'
|
82
82
|
args = {
|
83
83
|
keys: [
|
84
|
-
|
85
|
-
|
84
|
+
"title",
|
85
|
+
"author(s)"
|
86
86
|
],
|
87
|
-
sep_char:
|
87
|
+
sep_char: " "
|
88
88
|
}.merge(fields)
|
89
89
|
|
90
90
|
keys = args[:keys]
|
@@ -92,18 +92,18 @@ module EbookRenamer
|
|
92
92
|
|
93
93
|
# Note: only show if we have the value for title
|
94
94
|
result = []
|
95
|
-
if meta_hash.fetch(
|
95
|
+
if meta_hash.fetch("title", nil)
|
96
96
|
keys.each do |k|
|
97
97
|
value = meta_hash.fetch(k, nil)
|
98
98
|
# Note: don't add 'Author(s)' => 'Unknown' to keep the result clean
|
99
|
-
if value && value.downcase !=
|
99
|
+
if value && value.downcase != "unknown"
|
100
100
|
result << meta_hash[k]
|
101
101
|
end
|
102
102
|
end
|
103
103
|
return result.join(sep_char)
|
104
104
|
end
|
105
105
|
# Note: if no title we choose to return empty value for result
|
106
|
-
|
106
|
+
""
|
107
107
|
end
|
108
108
|
|
109
109
|
# Ensure that the values in hash are sanitized
|
@@ -113,7 +113,7 @@ module EbookRenamer
|
|
113
113
|
# @see #sanitize_filename
|
114
114
|
def sanitize_values(hash = {})
|
115
115
|
hash.each do |key, value|
|
116
|
-
hash[key] = sanitize_filename(value,
|
116
|
+
hash[key] = sanitize_filename(value, " ")
|
117
117
|
end
|
118
118
|
hash
|
119
119
|
end
|
@@ -129,11 +129,11 @@ module EbookRenamer
|
|
129
129
|
def files(base_dir = Dir.pwd, options = {})
|
130
130
|
args = {
|
131
131
|
recursive: false,
|
132
|
-
exts: %w
|
132
|
+
exts: %w[epub mobi pdf]
|
133
133
|
}.merge(options)
|
134
134
|
|
135
|
-
wildcard = args[:recursive] ?
|
136
|
-
patterns = File.join(base_dir, wildcard, "*.{#{(args[:exts]).join(
|
135
|
+
wildcard = args[:recursive] ? "**" : ""
|
136
|
+
patterns = File.join(base_dir, wildcard, "*.{#{(args[:exts]).join(",")}}")
|
137
137
|
Dir.glob(patterns) || []
|
138
138
|
end
|
139
139
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ebook_renamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burin Choomnuan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -216,7 +216,7 @@ extra_rdoc_files: []
|
|
216
216
|
files:
|
217
217
|
- ".gitignore"
|
218
218
|
- ".rubocop.yml"
|
219
|
-
-
|
219
|
+
- CHANGELOG.md
|
220
220
|
- Gemfile
|
221
221
|
- LICENSE
|
222
222
|
- README.md
|