ebook_renamer 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: a8a64ca3175a4c4bed67276095ece3989599899b
4
- data.tar.gz: 87b77360c94a40e519044592bd43f3c9983b904a
3
+ metadata.gz: 5f39498062a55b4aebada821cdbf80f7c1a6c1f9
4
+ data.tar.gz: 674a76061a72b872079b73cde77fbad5560ab42d
5
5
  SHA512:
6
- metadata.gz: 5ed719c07b3eeabac5ed9ff4e80d850448fd3f80c87bfd7b1e34f2bdea8267b250ee438c42e347c2f4afff18b764402803c6df24c52ba181cbaf64264457875f
7
- data.tar.gz: d885702e217df52ebe83ee2e9a14993ebf84a5163966715ac2619750012ac231956776b0336dd5dbc73fd23fa030359b5a1c79cf6b9c2578e7389e1f8243e9af
6
+ metadata.gz: 40deb11d8c50096a8e934fb135b10a9588a50379ae6e2f004517dca2d7a0135a45c229ddb6350b3826a83e42ba1d61736660f97679e57432bc6a9a721d7d8db2
7
+ data.tar.gz: d837cb3895f94cb3c354db45587b5606f237dd77ea6a0cbf66b9b63053bd2e2ae49c871bc7c8bab6e94058e4d2ebfaf469ed89fb9bbf5c7ab39b73f60d083ab8
data/.gitignore CHANGED
@@ -15,5 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- ## Note for testing only!!
19
- misc/
18
+ ## Custom ignore list
19
+ rubocop-todo.yml
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ inherit_from: rubocop-todo.yml
data/CHANGELOGS.md ADDED
@@ -0,0 +1,61 @@
1
+ ### Changelog
2
+
3
+ #### 0.1.5
4
+
5
+ - Simplify the interface to only support epub, pdf and mobi format
6
+ - Reduce the options for the CLI
7
+ * remove --exc-words
8
+ * remove --inc_words
9
+ * remove --ignore-case
10
+ * remove --non-exts
11
+ - Update gemspec to include files explicitly without using git
12
+ - Update 'code_lister' to 0.0.9
13
+ - Update 'thor' to 0.19.1
14
+ - Code cleanup and refactoring
15
+ - Remove list of changes from README.md to CHANGELOGS.md
16
+
17
+ #### 0.1.4
18
+
19
+ - Make use of functions from 'agile_utils' to promote code re-use
20
+ - Make Rakefile pickup the right code for testing
21
+ - Update README.md to include code_climate and gemnasium
22
+
23
+ #### 0.1.3
24
+
25
+ - Make sanitize_filename work properly with `--sep-string` option
26
+ - Use symbolize_keys from [agile_utils][] gem
27
+ - Fix the Guardfile and misc cleanup
28
+
29
+ #### 0.1.2
30
+
31
+ - Make use of [agile_utils] gem
32
+ - Add TODOs.md
33
+
34
+ #### 0.1.1
35
+
36
+ - Make use of the [code_lister][] gem
37
+
38
+ #### 0.1.0
39
+
40
+ - Add link to the version badge to link to latest gem.
41
+ - Implicitly set the default value for extension to `pdf,epub,mobi` if
42
+ not explicitly set by the user at the command line.
43
+
44
+ #### 0.0.9
45
+
46
+ - Make sure the gemspec include the proper dependencies.
47
+
48
+ #### 0.0.8
49
+
50
+ - Use Thor instead of OptionParser for parsing of options
51
+
52
+ #### 0.0.2 - 0.0.7
53
+
54
+ - Improvement of code and fix a few bugs a long the way
55
+
56
+ #### 0.0.1
57
+
58
+ - Initial release
59
+
60
+ [agile_utils]: https://rubygems.org/gems/agile_utils
61
+ [code_lister]: https://rubygems.org/gems/code_lister
data/README.md CHANGED
@@ -4,8 +4,9 @@
4
4
  [![Dependency Status](https://gemnasium.com/agilecreativity/ebook_renamer.png)](https://gemnasium.com/agilecreativity/ebook_renamer)
5
5
  [![Code Climate](https://codeclimate.com/github/agilecreativity/ebook_renamer.png)](https://codeclimate.com/github/agilecreativity/ebook_renamer)
6
6
 
7
- Perform bulk rename of ebook files (epub,mobi,pdf, and any other extensions supported by Calibre)
8
- based on the embedded meta-data (title, author(s)).
7
+ Perform bulk rename of ebook files (epub,mobi,pdf) based on the embedded metadata (title, author(s)).
8
+ This version depends on the opensource software called [Calibre][] which provide the tools
9
+ called [Calibre CLI][] which is very easy to install on OSX or Linux system.
9
10
 
10
11
  ### How the file is renamed
11
12
 
@@ -39,7 +40,28 @@ bundle
39
40
  gem install ebook_renamer
40
41
  ```
41
42
 
42
- ### Usage
43
+ ### Quick Usage
44
+
45
+ The shortest command that you can run to rename files is
46
+
47
+ ```sh
48
+ # This will rename any ebook files under the directory `~/Dropbox/ebooks`
49
+ # and any sub-directory for (*.epub, *.pdf, *.mobi) using the default settings
50
+ cd ~/Dropbox/ebooks
51
+ ebook_renamer rename --commit
52
+ ```
53
+
54
+ To see what the result would be like without making any changes to any files
55
+
56
+ ```sh
57
+ cd ~/Dropbox/ebooks
58
+ ebook_renamer rename
59
+ ```
60
+ Which should produce something like
61
+
62
+ ```
63
+ ```
64
+ ### Detail Usage
43
65
 
44
66
  Run the following command from the directory that contain the file(s) that
45
67
  you want to rename.
@@ -57,9 +79,11 @@ $ebook_renamer
57
79
  # Run the command without making any changes to the files (dry-run) in the current directory
58
80
  $ebook_renamer rename --base-dir . --recursive
59
81
 
60
- # Once you are happy with what result then
82
+ # Once you are happy with the result then
61
83
  $ebook_renamer rename --base-dir . --recursive --commit
84
+
62
85
  or the short version
86
+
63
87
  $ebook_renamer rename -b . -r -c
64
88
  ```
65
89
 
@@ -81,37 +105,28 @@ test/fixtures/
81
105
  Run the command without making any changes
82
106
 
83
107
  ```sh
84
- ebook_renamer rename --base-dir -e epub pdf ./test/fixtures/ebooks --recursive
108
+ ebook_renamer rename --base-dir ./test/fixtures/ebooks --recursive
85
109
  ```
86
110
 
87
111
  You should see the result like the following
88
112
 
89
113
  ```
90
- Your options :{:base_dir=>"test/fixtures/ebooks/",
91
- :exts=>["epub", "pdf"],
92
- :non_exts=>[],
93
- :inc_words=>[],
94
- :exc_words=>[],
95
- :ignore_case=>true,
96
- :recursive=>true,
97
- :version=>false,
98
- :sep_string=>".",
99
- :commit=>false}
100
114
  Changes will not be applied without the --commit option.
101
-
102
115
  [test/fixtures/ebooks/demo1.pdf] -> [test/fixtures/ebooks/Fearless.Refactoring.by.Andrzej.Krzywda.pdf]
103
116
  [test/fixtures/ebooks/demo2.epub] -> [test/fixtures/ebooks/EPUB.3.0.Specification.by.EPUB.3.Working.Group.epub]
104
117
  [test/fixtures/ebooks/subdir/demo1.pdf] -> [test/fixtures/ebooks/subdir/Reliably.Deploying.Rails.Applications.by.Ben.Dixon.pdf]
105
118
  [test/fixtures/ebooks/subdir/demo2.epub] -> [test/fixtures/ebooks/subdir/EPUB.3.0.Specification.by.EPUB.3.Working.Group.epub]
106
-
107
119
  ```
108
120
 
109
121
  To actually make the actual rename just pass in the `--commit` option like so:
110
122
 
111
123
  ```sh
112
- ./bin/ebook_renamer rename --base-dir ./test/fixtures/ebooks -e epub pdf --recursive --commit
113
- # or short version
114
- ./bin/ebook_renamer rename -b ./test/fixtures/ebooks -e epub pdf -r -c
124
+ ./bin/ebook_renamer rename --base-dir ./test/fixtures/ebooks --recursive --commit
125
+ ```
126
+ or the short version
127
+
128
+ ```sh
129
+ ./bin/ebook_renamer rename -b ./test/fixtures/ebooks -r -c
115
130
  ```
116
131
 
117
132
  The final output should be something like:
@@ -133,72 +148,21 @@ To get the help just type `ebook_renamer` without any argument
133
148
 
134
149
  ```
135
150
  Usage:
136
- ebook_renamer rename [OPTIONS]
151
+ ebook_renamer rename
137
152
 
138
153
  Options:
139
- -b, [--base-dir=BASE_DIR] # Base directory
140
- # Default: . (current directory)
141
- -e, [--exts=one two three] # List of extensions to search for
142
- -f, [--non-exts=one two three] # List of files without extension to search for
143
- -n, [--inc-words=one two three] # List of words to be included in the result if any
144
- -x, [--exc-words=one two three] # List of words to be excluded from the result if any
145
- -i, [--ignore-case], [--no-ignore-case] # Match case insensitively
146
- # Default: true
147
- -r, [--recursive], [--no-recursive] # Search for files recursively
148
- # Default: true
149
- -v, [--version], [--no-version] # Display version information
150
- -s, [--sep-string=SEP_STRING] # Separator string between words in filename
151
- # Default: .
152
- -c, [--commit], [--no-commit] # Make change permanent
153
-
154
- Rename multiple ebook files (pdf,epub,mobi)
154
+ -b, [--base-dir=BASE_DIR] # Base directory
155
+ # Default: . (current directory)
156
+ -r, [--recursive], [--no-recursive] # Search for files recursively
157
+ # Default: true
158
+ -s, [--sep-string=SEP_STRING] # Separator string between words in output filename
159
+ # Default: .
160
+ -c, [--commit], [--no-commit] # Make change permanent
161
+ -v, [--version], [--no-version] # Display version information
162
+
163
+ Rename multiple ebook files (pdf,epub,mobi) from a given directory
155
164
  ```
156
165
 
157
- ### Changelog
158
-
159
- #### 0.1.4
160
-
161
- - Make use of functions from 'agile_utils' to promote code re-use
162
- - Make Rakefile pickup the right code for testing
163
- - Update README.md to include code_climate and gemnasium
164
-
165
- #### 0.1.3
166
-
167
- - Make sanitize_filename work properly with `--sep-string` option
168
- - Use symbolize_keys from [agile_utils][] gem
169
- - Fix the Guardfile and misc cleanup
170
-
171
- #### 0.1.2
172
-
173
- - Make use of [agile_utils] gem
174
- - Add TODOs.md
175
-
176
- #### 0.1.1
177
-
178
- - Make use of the [code_lister][] gem
179
-
180
- #### 0.1.0
181
-
182
- - Add link to the version badge to link to latest gem.
183
- - Implicitly set the default value for extension to `pdf,epub,mobi` if
184
- not explicitly set by the user at the command line.
185
-
186
- #### 0.0.9
187
-
188
- - Make sure the gemspec include the proper dependencies.
189
-
190
- #### 0.0.8
191
-
192
- - Use Thor instead of OptionParser for parsing of options
193
-
194
- #### 0.0.2 - 0.0.7
195
-
196
- - Improvement of code and fix a few bugs a long the way
197
-
198
- #### 0.0.1
199
-
200
- - Initial release
201
-
202
166
  ### Contributing
203
167
 
204
168
  1. Fork it
@@ -207,6 +171,3 @@ Rename multiple ebook files (pdf,epub,mobi)
207
171
  4. Make sure that you add the tests and ensure that all tests are passed
208
172
  5. Push to the branch (`git push origin my-new-feature`)
209
173
  6. Create new Pull Request
210
-
211
- [agile_utils]: https://rubygems.org/gems/agile_utils
212
- [code_lister]: https://rubygems.org/gems/code_lister
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new do |t|
5
5
  t.libs << 'lib/ebook_renamer'
@@ -7,7 +7,7 @@ Rake::TestTask.new do |t|
7
7
  t.verbose = true
8
8
  end
9
9
 
10
- task :default => :test
10
+ task default: :test
11
11
 
12
12
  task :pry do
13
13
  require 'pry'
@@ -12,13 +12,20 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Rename multiple ebook files (pdf, epub, mobi) based on existing metadata if available}
13
13
  spec.homepage = 'https://github.com/agilecreativity/ebook_renamer'
14
14
  spec.license = 'MIT'
15
- spec.files = `git ls-files`.split($/)
15
+ spec.files = Dir.glob('{bin,lib}/**/*') + %w(Gemfile
16
+ Rakefile
17
+ ebook_renamer.gemspec
18
+ README.md
19
+ CHANGELOGS.md
20
+ LICENSE
21
+ .rubocop.yml
22
+ .gitignore)
16
23
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
25
  spec.require_paths = ['lib']
19
- spec.add_runtime_dependency 'thor', '~> 0.18'
26
+ spec.add_runtime_dependency 'thor', '~> 0.19.1'
20
27
  spec.add_runtime_dependency 'agile_utils', '~> 0.0.9'
21
- spec.add_runtime_dependency 'code_lister', '~> 0.0.8'
28
+ spec.add_runtime_dependency 'code_lister', '~> 0.0.9'
22
29
  spec.add_development_dependency 'bundler', '~> 1.3'
23
30
  spec.add_development_dependency 'rake'
24
31
  spec.add_development_dependency 'awesome_print', '~> 1.2'
@@ -29,4 +36,5 @@ Gem::Specification.new do |spec|
29
36
  spec.add_development_dependency 'pry', '~> 0.9'
30
37
  spec.add_development_dependency 'gem-ctags', '~> 1.0'
31
38
  spec.add_development_dependency 'yard', '~> 0.8'
39
+ spec.add_development_dependency 'rubocop', '~> 0.20.1'
32
40
  end
@@ -1,38 +1,26 @@
1
1
  require 'agile_utils'
2
2
  require 'code_lister'
3
+ require 'fileutils'
3
4
  require_relative '../ebook_renamer'
4
-
5
5
  module EbookRenamer
6
6
  class CLI < Thor
7
- desc 'rename', 'Rename multiple ebook files (pdf,epub,mobi)'
8
-
7
+ desc 'rename', 'Rename multiple ebook files (pdf,epub,mobi) from a given directory'
9
8
  method_option *AgileUtils::Options::BASE_DIR
10
- method_option *AgileUtils::Options::EXTS
11
- method_option *AgileUtils::Options::NON_EXTS
12
- method_option *AgileUtils::Options::INC_WORDS
13
- method_option *AgileUtils::Options::EXC_WORDS
14
- method_option *AgileUtils::Options::IGNORE_CASE
15
9
  method_option *AgileUtils::Options::RECURSIVE
16
- method_option *AgileUtils::Options::VERSION
17
-
18
10
  method_option :sep_string,
19
- aliases: "-s",
20
- desc: "Separator string between words in filename",
21
- default: "."
22
-
11
+ aliases: '-s',
12
+ desc: 'Separator string between words in output filename',
13
+ default: '.'
23
14
  method_option :commit,
24
- aliases: "-c",
25
- desc: "Make change permanent",
15
+ aliases: '-c',
16
+ desc: 'Make change permanent',
26
17
  type: :boolean,
27
18
  default: false
19
+ method_option *AgileUtils::Options::VERSION
28
20
  def rename
29
21
  opts = options.symbolize_keys
30
-
31
- # Note: by default the 'code_lister' for exts: is [].
32
- # To make it more user friendly, we explicitly set the extension
33
- # to %w(pdf epub mobi) to avoid the need for explicit value by the user
34
- opts[:exts] = %w(pdf epub mobi) if opts.fetch(:exts, []).empty?
35
-
22
+ # Explicitly add the :exts options
23
+ opts[:exts] = %w(pdf epub mobi)
36
24
  if opts[:version]
37
25
  puts "You are using EbookRenamer version #{EbookRenamer::VERSION}"
38
26
  exit
@@ -40,29 +28,23 @@ module EbookRenamer
40
28
  execute(opts)
41
29
  end
42
30
 
43
- desc "usage", "Display help screen"
31
+ desc 'usage', 'Display help screen'
44
32
  def usage
45
33
  puts <<-EOS
46
34
  Usage:
47
- cli.rb rename [OPTIONS]
35
+ ebook_renamer rename
48
36
 
49
37
  Options:
50
- -b, [--base-dir=BASE_DIR] # Base directory
51
- # Default: /Users/agilecreativity/Dropbox/spikes/ebooks-renamer
52
- -e, [--exts=one two three] # List of extensions to search for
53
- -f, [--non-exts=one two three] # List of files without extension to search for
54
- -n, [--inc-words=one two three] # List of words to be included in the result if any
55
- -x, [--exc-words=one two three] # List of words to be excluded from the result if any
56
- -i, [--ignore-case], [--no-ignore-case] # Match case insensitively
57
- # Default: true
58
- -r, [--recursive], [--no-recursive] # Search for files recursively
59
- # Default: true
60
- -v, [--version], [--no-version] # Display version information
61
- -s, [--sep-string=SEP_STRING] # Separator string between words in filename
62
- # Default: .
63
- -c, [--commit], [--no-commit] # Make change permanent
64
-
65
- Rename multiple ebook files (pdf,epub,mobi)
38
+ -b, [--base-dir=BASE_DIR] # Base directory
39
+ # Default: . (current directory)
40
+ -r, [--recursive], [--no-recursive] # Search for files recursively
41
+ # Default: true
42
+ -s, [--sep-string=SEP_STRING] # Separator string between words in output filename
43
+ # Default: .
44
+ -c, [--commit], [--no-commit] # Make change permanent
45
+ -v, [--version], [--no-version] # Display version information
46
+
47
+ Rename multiple ebook files (pdf,epub,mobi) from a given directory
66
48
  EOS
67
49
  end
68
50
 
@@ -80,7 +62,7 @@ Rename multiple ebook files (pdf,epub,mobi)
80
62
  #
81
63
  # @param args [Hash<Symbol, Object>] options argument
82
64
  def execute(options = {})
83
- meta_binary = "ebook-meta"
65
+ meta_binary = 'ebook-meta'
84
66
 
85
67
  input_files = CodeLister.files(options)
86
68
 
@@ -90,17 +72,18 @@ Rename multiple ebook files (pdf,epub,mobi)
90
72
  end
91
73
 
92
74
  unless options[:commit]
93
- puts "Changes will not be applied without the --commit option."
75
+ puts 'Changes will not be applied without the --commit option.'
94
76
  end
95
77
 
96
- input_files.each do |file|
78
+ FileUtils.chdir(options[:base_dir])
79
+ input_files.each_with_index do |file, index|
97
80
  extension = File.extname(file)
98
81
  begin
99
82
  hash = meta_to_hash(meta(file, meta_binary))
100
- full_name = formatted_name(hash, sep_char: " by ")
83
+ full_name = formatted_name(hash, sep_char: ' by ')
101
84
  new_name = "#{File.dirname(file)}/#{sanitize_filename(full_name, options[:sep_string])}#{extension}"
102
- puts "[#{file}] -> [#{new_name}]"
103
- FileUtils.mv(file,new_name) if options[:commit] && file != new_name
85
+ puts "#{index + 1} of #{input_files.size}::[#{file}] -> [#{new_name}]"
86
+ FileUtils.mv(file, new_name) if options[:commit] && file != new_name
104
87
  rescue RuntimeError => e
105
88
  puts e.backtrace
106
89
  next
@@ -2,9 +2,7 @@ require 'open3'
2
2
  require 'fileutils'
3
3
  require 'shellwords'
4
4
  require_relative '../ebook_renamer'
5
-
6
5
  module EbookRenamer
7
-
8
6
  EbookMetaNotInstall = Class.new(StandardError)
9
7
 
10
8
  # Extract meta data from the input file using the ebook-meta tool
@@ -13,13 +11,13 @@ module EbookRenamer
13
11
  # @param [String] binary the executable for use to extract the metadata
14
12
  # @return [String] result of the output from running the command
15
13
  def meta(filename, binary = 'ebook-meta')
16
- raise EbookMetaNotInstall, "Need to install ebook-meta to use this gem" if AgileUtils::Helper.which(binary).nil?
14
+ fail EbookMetaNotInstall, 'Need to install ebook-meta to use this gem' if AgileUtils::Helper.which(binary).nil?
17
15
  command = [
18
16
  binary,
19
17
  Shellwords.escape(filename)
20
18
  ]
21
19
 
22
- stdout_str, stderr_str, status = Open3.capture3(command.join(" "))
20
+ stdout_str, stderr_str, status = Open3.capture3(command.join(' '))
23
21
  raise "Problem processing #{filename}" unless status.success?
24
22
  stdout_str
25
23
  end
@@ -57,7 +55,7 @@ module EbookRenamer
57
55
  #
58
56
  # @return [String] the new file name with special characters replaced or removed.
59
57
  def sanitize_filename(filename, sep_char = nil)
60
- dot = "."
58
+ dot = '.'
61
59
  # Note exclude the '.' (dot)
62
60
  filename.gsub!(/[^0-9A-Za-z\-_ ]/, dot)
63
61
  # replace multiple occurrences of a given char with a dot
@@ -77,7 +75,7 @@ module EbookRenamer
77
75
  # @param [Hash<Symbol,String>] fields list of fields that will be used to set the name
78
76
  def formatted_name(meta_hash = {}, fields = {})
79
77
  if hash.nil? || fields.nil?
80
- raise ArgumentError.new("Argument must not be nil")
78
+ fail ArgumentError.new('Argument must not be nil')
81
79
  end
82
80
 
83
81
  # The keys that we get from the 'mdls' or 'exiftool'
@@ -105,7 +103,7 @@ module EbookRenamer
105
103
  return result.join(sep_char)
106
104
  end
107
105
  # Note: if no title we choose to return empty value for result
108
- ""
106
+ ''
109
107
  end
110
108
 
111
109
  # Ensure that the values in hash are sanitized
@@ -115,7 +113,7 @@ module EbookRenamer
115
113
  # @see #sanitize_filename
116
114
  def sanitize_values(hash = {})
117
115
  hash.each do |key, value|
118
- hash[key] = sanitize_filename(value, " ")
116
+ hash[key] = sanitize_filename(value, ' ')
119
117
  end
120
118
  hash
121
119
  end
@@ -1,3 +1,3 @@
1
1
  module EbookRenamer
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  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
4
+ version: 0.1.5
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-29 00:00:00.000000000 Z
11
+ date: 2014-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.18'
19
+ version: 0.19.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.18'
26
+ version: 0.19.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: agile_utils
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.0.8
47
+ version: 0.0.9
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.0.8
54
+ version: 0.0.9
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0.8'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 0.20.1
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 0.20.1
195
209
  description: Bulk rename of ebook files (pdf, epub, mobi) based on embedded metadata
196
210
  email:
197
211
  - agilecreativity@gmail.com
@@ -201,15 +215,12 @@ extensions: []
201
215
  extra_rdoc_files: []
202
216
  files:
203
217
  - ".gitignore"
204
- - ".ruby-version"
205
- - ".travis.yml"
206
- - ".yardopts"
218
+ - ".rubocop.yml"
219
+ - CHANGELOGS.md
207
220
  - Gemfile
208
- - Guardfile
209
221
  - LICENSE
210
222
  - README.md
211
223
  - Rakefile
212
- - TODOs.md
213
224
  - bin/ebook_renamer
214
225
  - ebook_renamer.gemspec
215
226
  - lib/ebook_renamer.rb
@@ -217,12 +228,6 @@ files:
217
228
  - lib/ebook_renamer/logger.rb
218
229
  - lib/ebook_renamer/utils.rb
219
230
  - lib/ebook_renamer/version.rb
220
- - test/fixtures/ebooks/demo1.pdf
221
- - test/fixtures/ebooks/demo2.epub
222
- - test/fixtures/ebooks/subdir/demo1.pdf
223
- - test/fixtures/ebooks/subdir/demo2.epub
224
- - test/lib/ebook_renamer/test_utils.rb
225
- - test/test_helper.rb
226
231
  homepage: https://github.com/agilecreativity/ebook_renamer
227
232
  licenses:
228
233
  - MIT
@@ -248,11 +253,5 @@ signing_key:
248
253
  specification_version: 4
249
254
  summary: Rename multiple ebook files (pdf, epub, mobi) based on existing metadata
250
255
  if available
251
- test_files:
252
- - test/fixtures/ebooks/demo1.pdf
253
- - test/fixtures/ebooks/demo2.epub
254
- - test/fixtures/ebooks/subdir/demo1.pdf
255
- - test/fixtures/ebooks/subdir/demo2.epub
256
- - test/lib/ebook_renamer/test_utils.rb
257
- - test/test_helper.rb
256
+ test_files: []
258
257
  has_rdoc:
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.1.1
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 2.1.1
data/.yardopts DELETED
@@ -1,2 +0,0 @@
1
- # see: http://rubydoc.info/gems/yard/file/README.md
2
- --no-private --protected lib/**/*.rb - README.md LICENSE
data/Guardfile DELETED
@@ -1,13 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
- guard 'minitest' do
4
- # with Minitest::Unit
5
- watch(%r|^test/(.*)\/?test_(.*)\.rb|)
6
- watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
7
- watch(%r|^test/test_helper\.rb|) { "test" }
8
-
9
- # with Minitest::Spec
10
- # watch(%r|^spec/(.*)_spec\.rb|)
11
- # watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
- # watch(%r|^spec/spec_helper\.rb|) { "spec" }
13
- end
data/TODOs.md DELETED
@@ -1,3 +0,0 @@
1
- ### TODO List
2
- - Fix the issue with the '--sep-string' not working properly.
3
- - Add more tests
Binary file
Binary file
Binary file
Binary file
@@ -1,117 +0,0 @@
1
- require_relative '../../test_helper'
2
- describe EbookRenamer do
3
-
4
- include EbookRenamer
5
-
6
- before do
7
- @sample = meta("./test/fixtures/ebooks/demo1.pdf")
8
- end
9
-
10
- context "#meta" do
11
- it "raises error on invalid input" do
12
- ->{ meta("invalid-filename") }.must_raise RuntimeError
13
- end
14
-
15
- it "returns valid valid input" do
16
- @sample.wont_be_nil
17
- end
18
-
19
- end
20
-
21
- context "#meta_to_hash" do
22
- it 'returns empty hash' do
23
- meta_to_hash(nil).must_be_empty
24
- end
25
- it 'returns non-empty hash' do
26
- hash = meta_to_hash(@sample)
27
- hash.wont_be_empty
28
- end
29
-
30
- describe 'invalid format' do
31
- it 'return empty hash' do
32
- meta_to_hash('aa bb').must_equal({})
33
- end
34
- end
35
-
36
- describe 'valid format' do
37
- # extract list of 'key' : 'value' from the input
38
- let(:sample) {
39
- <<-END
40
- Aaaa : BBbb
41
- CcCc : DddD
42
- EeeE : FFFF:gggg
43
- hhhh : iiii:JJJJ:kkkk
44
- END
45
- }
46
-
47
- let(:result) { meta_to_hash(sample) }
48
-
49
- it "returns proper type for result" do
50
- result.must_be_instance_of Hash
51
- end
52
-
53
- it 'uses lowercase for result keys' do
54
- result.keys.must_equal ['aaaa','cccc','eeee','hhhh']
55
- end
56
-
57
- it 'retains original cases for result values' do
58
- result.values.must_equal ['BBbb','DddD','FFFF:gggg','iiii:JJJJ:kkkk']
59
- end
60
- end
61
- end
62
-
63
- context "#sanitize_filename" do
64
- it "must be defined" do
65
- must_respond_to :sanitize_filename
66
- end
67
-
68
- it "replaces multiple valid chars with one" do
69
- sanitize_filename('Valid- -fil3_name......___ ').must_equal('Valid.fil3.name.')
70
- end
71
-
72
- it "replaces multiple valid chars with one" do
73
- sanitize_filename('valid!!___filename').must_equal('valid.filename')
74
- end
75
-
76
- it "uses specify separator char correctly" do
77
- sanitize_filename('valid.file name','_').must_equal('valid_file_name')
78
- end
79
-
80
- it "replaces mutliple separator char with one" do
81
- sanitize_filename('input&!:.file name$only','-').must_equal('input-file-name-only')
82
- end
83
- it "handles the end char properly" do
84
- sanitize_filename('input&!:.file name$only!!&$','-').must_equal('input-file-name-only-')
85
- end
86
- end
87
-
88
- context '#formatted_name' do
89
- describe 'invalid parameters' do
90
- it 'raises exception on nil arguments' do
91
- -> { formatted_name({}, nil)}.must_raise ArgumentError
92
- end
93
- it 'returns nil on empty hash' do
94
- formatted_name({}, {}).must_be_empty
95
- end
96
- end
97
-
98
- describe 'valid parameters' do
99
- it 'returns result based on single key' do
100
- formatted_name({'title' => 'The Firm',
101
- 'author' => 'John Grisham',
102
- 'page count' => 399 },
103
- keys: ['title']).must_equal 'The Firm'
104
- end
105
-
106
- it 'returns result based for multiple keys' do
107
- formatted_name({'title' => 'The Firm',
108
- 'author' => 'John Grisham',
109
- 'page count' => '399' },
110
- sep_char: ':',
111
- keys: ['title',
112
- 'author',
113
- 'page count']).must_equal 'The Firm:John Grisham:399'
114
- end
115
- end
116
- end
117
- end
data/test/test_helper.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'minitest/pride'
3
- require 'minitest-spec-context'
4
- require 'awesome_print'
5
-
6
- require_relative '../lib/ebook_renamer'