ebooks_renamer 0.1.3 → 0.1.4

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: c8023c3193436aa238e7a4767ec89ba04ca62bc9
4
- data.tar.gz: e8e0ffbdba67983f7e88827f4f02485031ecae32
3
+ metadata.gz: dcfe69c874481fe5d47d0b09b97899fb97bbe3a0
4
+ data.tar.gz: 104930f2174f8ae0c68be45e6afcb6cd57a182b0
5
5
  SHA512:
6
- metadata.gz: ff7cb3e93207aaaedd3925dc95da8985d7acad85129f4ab03424ed2b2560becec4f03dbebf4269478d732bc62b86ebd8ef6539658207e085255b21a91d2a4476
7
- data.tar.gz: efd7361232b1b888766efdd515968a123f31eccfe9005b49139650cbb1f3ed053c44aca7c7f0aef151183e01bb6a66584112b20e035e2a2244f32d28140d57cf
6
+ metadata.gz: 5b762829046bc8baca50428bb463a0e64c517f1ce33bfb006869a9516a27e3d6996724925fda2416a5e0bf8e655f0d8bf644d84274d01ad045bef15095eadac1
7
+ data.tar.gz: 3764692ae672455ff62d75cfab9f1404e8dab0a75d1f41665660be6a9acc7ec80cdadc07c42f56d5c4161214f1314cbec690075a26811fd0b4aaffa05fb058c5
data/.rubocop.yml CHANGED
@@ -1,3 +1,95 @@
1
- # This is the configuration used to check the rubocop source code.
1
+ AllCops:
2
+ Include:
3
+ - Gemfile
4
+ - Rakefile
5
+ - bin/*
6
+ - ebooks_cleaner.gemspec
7
+ - lib/**/*.rb
8
+ - test/**/*.rb
9
+ # Avoid long parameter lists
10
+ ParameterLists:
11
+ Max: 5
12
+ CountKeywordArgs: true
2
13
 
3
- inherit_from: rubocop-todo.yml
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
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in valid_filename.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -60,7 +60,7 @@ Or install it yourself as:
60
60
 
61
61
  ```
62
62
  Usage:
63
- ebooks_renamer rename
63
+ ebooks_renamer
64
64
 
65
65
  Options:
66
66
  -b, [--base-dir=BASE_DIR] # Base directory
@@ -90,11 +90,11 @@ rbenv local 2.1.2 # or any version after 1.9+
90
90
  gem install ebooks_renamer
91
91
 
92
92
  # run the command without making any changes
93
- ebooks_renamer rename --base-dir . --recursive
93
+ ebooks_renamer --base-dir . --recursive
94
94
 
95
95
  # If you are happy with what will be changed then you can make your change permanent
96
96
 
97
- ebooks_renamer rename --base-dir . --recursive --commit
97
+ ebooks_renamer --base-dir . --recursive --commit
98
98
 
99
99
  # To change the default separator string `sep_string` (default to '.' - dot string)
100
100
  # e.g. this will use the '_' (underscore) to separate each word in the output
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
- project_name = 'ebooks_renamer'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ project_name = "ebooks_renamer"
4
4
 
5
5
  Rake::TestTask.new do |t|
6
6
  t.libs << "lib/#{project_name}"
@@ -10,20 +10,20 @@ end
10
10
 
11
11
  task default: [:test, :rubocop]
12
12
  task :pry do
13
- require 'pry'
14
- require 'awesome_print'
15
- require_relative 'lib/ebook_meta'
13
+ require "pry"
14
+ require "awesome_print"
15
+ require_relative "lib/ebook_meta"
16
16
  include EbooksRenamer
17
17
  ARGV.clear
18
18
  Pry.start
19
19
  end
20
20
 
21
- require 'rubocop/rake_task'
22
- desc 'Run RuboCop on the lib directory'
21
+ require "rubocop/rake_task"
22
+ desc "Run RuboCop on the lib directory"
23
23
  Rubocop::RakeTask.new(:rubocop) do |task|
24
- task.patterns = ['lib/**/*.rb']
24
+ task.patterns = ["lib/**/*.rb"]
25
25
  # only show the files with failures
26
- task.formatters = ['files']
26
+ task.formatters = ["files"]
27
27
  # don't abort rake on failure
28
28
  task.fail_on_error = false
29
29
  end
data/bin/ebooks_renamer CHANGED
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative '../lib/ebooks_renamer'
2
+ require_relative "../lib/ebooks_renamer"
3
3
  include EbooksRenamer
4
- EbooksRenamer::CLI.start(ARGV)
4
+ if ARGV.empty?
5
+ EbooksRenamer::CLI.start(%w[usage])
6
+ else
7
+ EbooksRenamer::CLI.start(%w[rename].concat(ARGV))
8
+ end
@@ -17,8 +17,7 @@ Gem::Specification.new do |spec|
17
17
  README.md
18
18
  LICENSE
19
19
  .rubocop.yml
20
- .gitignore
21
- rubocop-todo.yml)
20
+ .gitignore)
22
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
23
  spec.require_paths = ['lib']
@@ -1,7 +1,7 @@
1
- require_relative 'ebooks_renamer/version'
2
- require_relative 'ebooks_renamer/logger'
3
- require_relative 'ebooks_renamer/cli'
4
- require_relative 'ebooks_renamer/core_ext/hash/keys'
5
- require_relative 'ebooks_renamer/core_ext/object/blank'
6
- require_relative 'ebooks_renamer/ebooks_renamer'
1
+ require_relative "ebooks_renamer/version"
2
+ require_relative "ebooks_renamer/logger"
3
+ require_relative "ebooks_renamer/cli"
4
+ require_relative "ebooks_renamer/core_ext/hash/keys"
5
+ require_relative "ebooks_renamer/core_ext/object/blank"
6
+ require_relative "ebooks_renamer/ebooks_renamer"
7
7
  include EbooksRenamer
@@ -1,24 +1,21 @@
1
- require 'thor'
2
- require 'agile_utils'
3
- require_relative 'ebooks_renamer'
1
+ require "thor"
2
+ require "agile_utils"
3
+ require_relative "ebooks_renamer"
4
4
  module EbooksRenamer
5
5
  class CLI < Thor
6
- desc 'rename', 'Rename ebooks based on given criteria'
6
+ desc "rename", "Rename ebooks based on given criteria"
7
7
  method_option *AgileUtils::Options::BASE_DIR
8
8
  method_option *AgileUtils::Options::RECURSIVE
9
9
  method_option *AgileUtils::Options::VERSION
10
-
11
10
  method_option :sep_string,
12
- aliases: '-s',
13
- desc: 'Separator string between words in filename',
14
- default: '.'
15
-
11
+ aliases: "-s",
12
+ desc: "Separator string between words in filename",
13
+ default: "."
16
14
  method_option :commit,
17
- aliases: '-c',
18
- desc: 'Make change permanent',
15
+ aliases: "-c",
16
+ desc: "Make change permanent",
19
17
  type: :boolean,
20
18
  default: false
21
-
22
19
  def rename
23
20
  opts = options.symbolize_keys
24
21
  if opts[:version]
@@ -26,17 +23,17 @@ module EbooksRenamer
26
23
  exit
27
24
  end
28
25
  # Add the default supported extensions
29
- opts.merge!(exts: %w(pdf epub mobi))
26
+ opts.merge!(exts: %w[pdf epub mobi])
30
27
  puts "Your options #{opts}"
31
28
  EbooksRenamer.rename(opts)
32
29
  end
33
30
 
34
- desc 'usage', 'Display help screen'
31
+ desc "usage", "Display help screen"
35
32
  def usage
36
33
  puts <<-EOS
37
34
 
38
35
  Usage:
39
- ebooks_renamer rename
36
+ ebooks_renamer
40
37
 
41
38
  Options:
42
39
  -b, [--base-dir=BASE_DIR] # Base directory
@@ -1,5 +1,4 @@
1
1
  class Hash
2
-
3
2
  # File activesupport/lib/active_support/core_ext/hash/keys.rb
4
3
  #
5
4
  # hash = { name: 'Rob', age: '28' }
@@ -1,13 +1,13 @@
1
- require 'mobi'
2
- require 'epubinfo'
3
- require 'pdf-reader'
4
- require 'ostruct'
5
- require 'fileutils'
6
- require 'filename_cleaner'
7
- require 'code_lister'
8
- require_relative 'pdf_parser'
9
- require_relative 'epub_parser'
10
- require_relative 'mobi_parser'
1
+ require "mobi"
2
+ require "epubinfo"
3
+ require "pdf-reader"
4
+ require "ostruct"
5
+ require "fileutils"
6
+ require "filename_cleaner"
7
+ require "code_lister"
8
+ require_relative "pdf_parser"
9
+ require_relative "epub_parser"
10
+ require_relative "mobi_parser"
11
11
  module EbooksRenamer
12
12
  CustomError = Class.new(StandardError)
13
13
  class << self
@@ -25,20 +25,20 @@ module EbooksRenamer
25
25
  else
26
26
  puts "#{index + 1} of #{files.length}: Result : '#{old_name}' is identical so no action taken."
27
27
  end
28
- rescue Exception => e
28
+ rescue => e
29
29
  puts "Skip file '#{file}'"
30
30
  puts "Due to the unexpected error: #{e.message}"
31
31
  next
32
32
  end
33
33
  end
34
34
  unless options[:commit]
35
- puts '------------------------------------------------------------------'
36
- puts 'This is a dry run only, to actually rename please specify --commit'
37
- puts '------------------------------------------------------------------'
35
+ puts "------------------------------------------------------------------"
36
+ puts "This is a dry run only, to actually rename please specify --commit"
37
+ puts "------------------------------------------------------------------"
38
38
  end
39
39
  end
40
40
 
41
- private
41
+ private
42
42
 
43
43
  def formatted_name(file, sep_string)
44
44
  meta = parse(file)
@@ -53,7 +53,7 @@ module EbooksRenamer
53
53
  File::SEPARATOR,
54
54
  FilenameCleaner.sanitize(name, sep_string, false),
55
55
  File.extname(file),
56
- ].join('')
56
+ ].join("")
57
57
  else
58
58
  # return the full path of the original file
59
59
  File.expand_path(file)
@@ -73,11 +73,11 @@ module EbooksRenamer
73
73
 
74
74
  def parse(filename)
75
75
  case File.extname(filename)
76
- when '.epub'
76
+ when ".epub"
77
77
  Parser.new(EpubParser.parse(filename)).parser
78
- when '.pdf'
78
+ when ".pdf"
79
79
  Parser.new(PdfParser.parse(filename)).parser
80
- when '.mobi'
80
+ when ".mobi"
81
81
  Parser.new(MobiParser.parse(filename)).parser
82
82
  else
83
83
  fail "File type #{File.extname(file)} is not supported"
@@ -1,4 +1,4 @@
1
- require 'logger'
1
+ require "logger"
2
2
  module EbooksRenamer
3
3
  class << self
4
4
  attr_writer :logger
@@ -1,9 +1,9 @@
1
- require 'pry'
1
+ require "pry"
2
2
  module EbooksRenamer
3
3
  class PdfParser
4
4
  class << self
5
5
  def parse(filename)
6
- File.open(filename, 'rb') do |io|
6
+ File.open(filename, "rb") do |io|
7
7
  reader = PDF::Reader.new(io)
8
8
  if reader && reader.info && reader.info[:Title].present?
9
9
  OpenStruct.new title: reader.info[:Title],
@@ -11,7 +11,7 @@ module EbooksRenamer
11
11
  pages: reader.page_count
12
12
  end
13
13
  end
14
- rescue Exception => e
14
+ rescue => e
15
15
  # Note: we skip the file that we can't process
16
16
  # and allow the process to continue
17
17
  puts "Skip file '#{filename}'"
@@ -1,3 +1,3 @@
1
1
  module EbooksRenamer
2
- VERSION = '0.1.3'
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebooks_renamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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-15 00:00:00.000000000 Z
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -275,7 +275,6 @@ files:
275
275
  - lib/ebooks_renamer/mobi_parser.rb
276
276
  - lib/ebooks_renamer/pdf_parser.rb
277
277
  - lib/ebooks_renamer/version.rb
278
- - rubocop-todo.yml
279
278
  homepage: https://github.com/agilecreativity/ebooks_renamer
280
279
  licenses:
281
280
  - MIT
data/rubocop-todo.yml DELETED
@@ -1,92 +0,0 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-04-23 16:41:01 +1000 using RuboCop version 0.19.1.
3
- # The point is for the user to remove these configuration records
4
- # one by one as the offenses are removed from the code base.
5
- # Note that changes in the inspected code, or installation of new
6
- # versions of RuboCop, may require this file to be generated again.
7
-
8
- # Offense count: 2
9
- # Cop supports --auto-correct.
10
- DeprecatedClassMethods:
11
- Enabled: false
12
-
13
- # Offense count: 9
14
- Documentation:
15
- Enabled: false
16
-
17
- # Offense count: 6
18
- # Cop supports --auto-correct.
19
- EmptyLinesAroundBody:
20
- Enabled: false
21
-
22
- # Offense count: 1
23
- Eval:
24
- Enabled: false
25
-
26
- # Offense count: 2
27
- # Configuration parameters: Exclude.
28
- FileName:
29
- Enabled: false
30
-
31
- # Offense count: 1
32
- # Cop supports --auto-correct.
33
- IndentationConsistency:
34
- Enabled: true
35
-
36
- # Offense count: 2
37
- # Cop supports --auto-correct.
38
- LeadingCommentSpace:
39
- Enabled: false
40
-
41
- # Offense count: 5
42
- LineLength:
43
- Max: 89
44
-
45
- # Offense count: 1
46
- # Configuration parameters: CountComments.
47
- MethodLength:
48
- Max: 12
49
-
50
- # Offense count: 2
51
- # Configuration parameters: NamePrefixBlacklist.
52
- PredicateName:
53
- Enabled: false
54
-
55
- # Offense count: 1
56
- RedundantBegin:
57
- Enabled: true
58
-
59
- # Offense count: 1
60
- RescueException:
61
- Enabled: false
62
-
63
- # Offense count: 2
64
- RescueModifier:
65
- Enabled: false
66
-
67
- # Offense count: 2
68
- # Cop supports --auto-correct.
69
- SpaceAfterComma:
70
- Enabled: true
71
-
72
- # Offense count: 2
73
- # Cop supports --auto-correct.
74
- # Configuration parameters: EnforcedStyle, SupportedStyles.
75
- SpaceBeforeBlockBraces:
76
- Enabled: true
77
-
78
- # Offense count: 1
79
- # Cop supports --auto-correct.
80
- # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
81
- SpaceInsideBlockBraces:
82
- Enabled: true
83
-
84
- # Offense count: 16
85
- # Cop supports --auto-correct.
86
- # Configuration parameters: EnforcedStyle, SupportedStyles.
87
- StringLiterals:
88
- Enabled: true
89
-
90
- # Offense count: 2
91
- UselessAssignment:
92
- Enabled: true