ebook_renamer 0.0.2 → 0.0.3
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/README.md +47 -5
- data/bin/ebook_renamer +4 -1
- data/lib/ebook_renamer/helpers.rb +8 -1
- data/lib/ebook_renamer/options.rb +10 -0
- data/lib/ebook_renamer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c2b2bf7c2b9d1e2920c4634db1c348ec8db3fda
|
4
|
+
data.tar.gz: df92456b316428948cd8d27eb9a9765da785243a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39c8b4cbf1b95036c45c693a3bf37fb371ad3222dc40a715ba81e84e8cdec072e2ad7b7f39910309b1bb21df2b0c9a91a5567dc38875bf5a50619fc5ec4f12b1
|
7
|
+
data.tar.gz: b67d518a78608658c0f6defe6fe2eb58351746da8927f4efb873d2e230d936493d48803f2273d3b968c4d08dfdba0e54347c9402099025dbeccd3eee7576017a
|
data/README.md
CHANGED
@@ -1,14 +1,36 @@
|
|
1
|
-
##
|
1
|
+
## Ebook_Renamer
|
2
2
|
|
3
3
|
Simple utility to perform bulk rename of the ebooks(epub,mobi,pdf) based on
|
4
4
|
the metadata within the ebook itself (if available).
|
5
5
|
|
6
|
-
###
|
6
|
+
### Why do I wrote this gem
|
7
|
+
|
8
|
+
Almost alwasy when I purchase a new ebooks (or download them from the internet) they always came with the
|
9
|
+
bad name. I really like the meaningful name to the file that I have. This make it easy to search for them
|
10
|
+
and give you the context to the content of the file.
|
11
|
+
|
12
|
+
I wrote this gem just to make it possible to rename in bulk and recursively.
|
13
|
+
|
14
|
+
This gem will rename any ebook files (currently only pdf, epub, mobi) using the available
|
15
|
+
meta-data that embedded within the ebook.
|
16
|
+
|
17
|
+
So if you don't like to spend time renaming them manually then this gem is for you.
|
18
|
+
|
19
|
+
### What you will need
|
7
20
|
|
8
21
|
* You will need to install the [Calibre](http://www.calibre-ebook.com/) and
|
9
|
-
[Calibre CLI](http://manual.calibre-ebook.com/cli/cli-index.html)
|
22
|
+
[Calibre CLI](http://manual.calibre-ebook.com/cli/cli-index.html) on your OS.
|
10
23
|
|
11
|
-
*
|
24
|
+
* This gem should work on OSX/Linux like system. It may work with Windows system but I can't confirm
|
25
|
+
as I don't use windows for quite sometime now.
|
26
|
+
|
27
|
+
### Problems/Issues
|
28
|
+
|
29
|
+
- Error may be raised if the combined meta-data is too long.
|
30
|
+
e.g. if your files is stored in NTFS drive then you may get the error indicate the file is too long
|
31
|
+
or something similar. I will try to handle this error in the next few release.
|
32
|
+
|
33
|
+
### Installation and Usage:
|
12
34
|
|
13
35
|
```sh
|
14
36
|
bundle
|
@@ -37,7 +59,7 @@ ebook_rename --recursive
|
|
37
59
|
ebook_renamer --recusive --commit
|
38
60
|
```
|
39
61
|
|
40
|
-
###
|
62
|
+
### Sample Usage (from `ebook_renamer --help`)
|
41
63
|
|
42
64
|
```
|
43
65
|
Usage: ebook_renamer [options]
|
@@ -57,15 +79,35 @@ ebook_renamer --recusive --commit
|
|
57
79
|
5) $ebook_renamer --base-dir ~/Dropbox/ebooks
|
58
80
|
--recursive
|
59
81
|
--commit
|
82
|
+
|
83
|
+
6) $ebook_renamer --base-dir ~/Dropbox/ebooks
|
84
|
+
--meta-binary /usr/bin/ebook-meta
|
85
|
+
--recursive
|
86
|
+
--commit
|
87
|
+
|
60
88
|
Options:
|
61
89
|
|
62
90
|
-b, --base-dir directory Starting directory [default - current directory]
|
91
|
+
-m, --meta-binary path Path to the ebook-meta executable [default - '/usr/bin/ebook-meta']
|
63
92
|
-r, --recursive Process the files recursively [default - false]
|
64
93
|
-c, --commit Perform the actual rename [default - false]
|
65
94
|
-v, --version Display version number
|
66
95
|
-h, --help Display this screen
|
67
96
|
```
|
68
97
|
|
98
|
+
### Changelog
|
99
|
+
|
100
|
+
#### 0.0.3
|
101
|
+
|
102
|
+
- make it possible to change the path to the binary
|
103
|
+
|
104
|
+
#### 0.0.2
|
105
|
+
|
106
|
+
- fix the silly refactoring bug
|
107
|
+
|
108
|
+
#### 0.0.1
|
109
|
+
- Initial release
|
110
|
+
|
69
111
|
### Contributing
|
70
112
|
|
71
113
|
1. Fork it
|
data/bin/ebook_renamer
CHANGED
@@ -14,9 +14,12 @@ require 'ostruct'
|
|
14
14
|
begin
|
15
15
|
options = parse_options()
|
16
16
|
EbookRenamer.logger.info "Your options: #{options}"
|
17
|
+
meta_binary = options.delete(:meta_binary)
|
18
|
+
#
|
17
19
|
# Note: if we need to adjust the path to the executable
|
18
20
|
EbookRenamer.configure do |config|
|
19
|
-
config.meta_binary = '/usr/bin/ebook-meta'
|
21
|
+
#config.meta_binary = '/usr/bin/ebook-meta'
|
22
|
+
config.meta_binary = meta_binary unless meta_binary.nil?
|
20
23
|
end
|
21
24
|
|
22
25
|
cli = EbookRenamer::CLI.new(EbookRenamer.configuration)
|
@@ -4,6 +4,9 @@ require 'shellwords'
|
|
4
4
|
|
5
5
|
module EbookRenamer
|
6
6
|
class Helpers
|
7
|
+
|
8
|
+
EbookMetaNotInstall = Class.new(StandardError)
|
9
|
+
|
7
10
|
class << self
|
8
11
|
|
9
12
|
# Extract meta data from the input file using the ebook-meta tool
|
@@ -12,8 +15,12 @@ module EbookRenamer
|
|
12
15
|
# @param [String] binary the executable for use to extract the metadata
|
13
16
|
# @return [String] result of the output from running the command
|
14
17
|
def meta(filename, binary = 'ebook-meta')
|
18
|
+
binary_path = which(binary)
|
19
|
+
|
20
|
+
raise EbookMetaNotInstall, "Need to install ebook-meta to use this gem" if binary_path.nil?
|
21
|
+
|
15
22
|
command = [
|
16
|
-
|
23
|
+
binary_path,
|
17
24
|
Shellwords.escape(filename)
|
18
25
|
]
|
19
26
|
|
@@ -26,6 +26,11 @@ module EbookRenamer::Options
|
|
26
26
|
| --recursive
|
27
27
|
| --commit
|
28
28
|
|
|
29
|
+
| 6) $ebook_renamer --base-dir ~/Dropbox/ebooks
|
30
|
+
| --meta-binary /usr/bin/ebook-meta
|
31
|
+
| --recursive
|
32
|
+
| --commit
|
33
|
+
|
|
29
34
|
| Options:
|
30
35
|
|
|
31
36
|
END
|
@@ -35,6 +40,11 @@ module EbookRenamer::Options
|
|
35
40
|
options[:base_dir] = base_dir
|
36
41
|
end
|
37
42
|
|
43
|
+
options[:meta_binary] ||= '/usr/bin/ebook-meta'
|
44
|
+
opts.on('-m', '--meta-binary path', "Path to the ebook-meta executable [default - '/usr/bin/ebook-meta']") do |binary|
|
45
|
+
options[:meta_binary] = binary
|
46
|
+
end
|
47
|
+
|
38
48
|
options[:recursive] = false
|
39
49
|
opts.on('-r', '--recursive', 'Process the files recursively [default - false]') do
|
40
50
|
options[:recursive] = true
|
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.0.
|
4
|
+
version: 0.0.3
|
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-04-
|
11
|
+
date: 2014-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|