ebook_renamer 0.1.2 → 0.1.3

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: e424aaf924da59dd5d6b1d753190e5ca6620c843
4
- data.tar.gz: 493c6f7a8516d592b5eff936949d8275d0483e52
3
+ metadata.gz: f616cb073cb5cba2a5aa1e2d9e5e16342563d179
4
+ data.tar.gz: 2d01a060dee06089c5b058ade6304d51b4210d3b
5
5
  SHA512:
6
- metadata.gz: 598d4d1a58f1b5ba9e4e9d7bf7bd6d9d13a08fe715ec1a9eddfe5949b60423dc022ad81a6550300ea2456f2db80eef5edf92ec9e0d64dd1d35864a7addd88462
7
- data.tar.gz: 6adfee3ab04652a9f403424c7030fc63ff89f023325484816a610cd51e02677a088901949ad198b59d32a11fb6cb00aef1854e20c3a9d842b623753933d26d1e
6
+ metadata.gz: 30e22b60a59a775e446a29431f713579fc4824602447700df2307effd0c1fc4773c5f4e6bcfb795c2cdd01508357b1448080c8b730ad3d92c307ff39bd0ff1ae
7
+ data.tar.gz: bb48fe0ef334828a29c36e0f2701f49dfe17e4988529ca07ecc0c24a29e210ded2e222384255f4c5a3911053d56e6160a0f5539ebd31b455e7e33c40447200d1
data/README.md CHANGED
@@ -154,28 +154,41 @@ Rename multiple ebook files (pdf,epub,mobi)
154
154
 
155
155
  ### Changelog
156
156
 
157
+ #### 0.1.3
158
+
159
+ - Make sanitize_filename work properly with `--sep-string` option
160
+ - Use symbolize_keys from [agile_utils][] gem
161
+ - Fix the Guardfile and misc cleanup
162
+
157
163
  #### 0.1.2
164
+
158
165
  - Make use of [agile_utils] gem
159
166
  - Add TODOs.md
160
167
 
161
168
  #### 0.1.1
169
+
162
170
  - Make use of the [code_lister][] gem
163
171
 
164
172
  #### 0.1.0
173
+
165
174
  - Add link to the version badge to link to latest gem.
166
175
  - Implicitly set the default value for extension to `pdf,epub,mobi` if
167
176
  not explicitly set by the user at the command line.
168
177
 
169
178
  #### 0.0.9
179
+
170
180
  - Make sure the gemspec include the proper dependencies.
171
181
 
172
182
  #### 0.0.8
183
+
173
184
  - Use Thor instead of OptionParser for parsing of options
174
185
 
175
186
  #### 0.0.2 - 0.0.7
187
+
176
188
  - Improvement of code and fix a few bugs a long the way
177
189
 
178
190
  #### 0.0.1
191
+
179
192
  - Initial release
180
193
 
181
194
  ### Contributing
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
  spec.add_runtime_dependency 'thor', '~> 0.18'
20
+ spec.add_runtime_dependency 'agile_utils', '~> 0.0.7'
20
21
  spec.add_runtime_dependency 'code_lister', '~> 0.0.7'
21
22
  spec.add_development_dependency 'bundler', '~> 1.3'
22
23
  spec.add_development_dependency 'rake'
@@ -1,8 +1,7 @@
1
1
  require 'thor'
2
2
  require 'code_lister'
3
3
  require 'agile_utils'
4
- require_relative 'ebook_renamer/core_ext/hash'
5
4
  require_relative 'ebook_renamer/version'
6
5
  require_relative 'ebook_renamer/logger'
7
- require_relative 'ebook_renamer/helper'
6
+ require_relative 'ebook_renamer/utils'
8
7
  require_relative 'ebook_renamer/cli'
@@ -1,3 +1,4 @@
1
+ require 'agile_utils'
1
2
  require 'code_lister'
2
3
  require_relative '../ebook_renamer'
3
4
 
@@ -2,9 +2,9 @@ require 'logger'
2
2
  module EbookRenamer
3
3
  class << self
4
4
  attr_writer :logger
5
- # @return [Logger] the Logger for the project
6
- def logger
7
- @logger ||= Logger.new STDOUT
8
- end
5
+ # @return [Logger] the Logger for the project
6
+ def logger
7
+ @logger ||= Logger.new STDOUT
8
+ end
9
9
  end
10
10
  end
@@ -58,10 +58,8 @@ module EbookRenamer
58
58
  # @return [String] the new file name with special characters replaced or removed.
59
59
  def sanitize_filename(filename, sep_char = nil)
60
60
  dot = "."
61
-
62
61
  # Note exclude the '.' (dot)
63
62
  filename.gsub!(/[^0-9A-Za-z\-_ ]/, dot)
64
-
65
63
  # replace multiple occurrences of a given char with a dot
66
64
  ['-', '_', ' '].each do |c|
67
65
  filename.gsub!(/#{Regexp.quote(c)}+/, dot)
@@ -69,16 +67,7 @@ module EbookRenamer
69
67
 
70
68
  # replace multiple occurrence of dot with one dot
71
69
  filename.gsub!(/#{Regexp.quote(dot)}+/, dot)
72
-
73
- if sep_char
74
- # File.basename("demo.txt", ".*") #=> "demo"
75
- name_only = File.basename(filename, ".*")
76
- # File.extname("demo.txt") #=> ".txt"
77
- ext_only = File.extname(filename)
78
- name_only.gsub!(/#{Regexp.quote(dot)}+/, sep_char)
79
- return "#{name_only}#{ext_only}"
80
- end
81
-
70
+ return filename.gsub!(/#{Regexp.quote(dot)}+/, sep_char) if sep_char
82
71
  filename.strip
83
72
  end
84
73
 
@@ -1,3 +1,3 @@
1
1
  module EbookRenamer
2
- VERSION = "0.1.2"
2
+ VERSION = '0.1.3'
3
3
  end
@@ -66,15 +66,22 @@ describe EbookRenamer do
66
66
  end
67
67
 
68
68
  it "replaces multiple valid chars with one" do
69
- sanitize_filename('Valid- -fil3_name......___ .txt').must_equal('Valid.fil3.name.txt')
69
+ sanitize_filename('Valid- -fil3_name......___ ').must_equal('Valid.fil3.name.')
70
70
  end
71
71
 
72
72
  it "replaces multiple valid chars with one" do
73
- sanitize_filename('valid filename_.txt').must_equal('valid.filename.txt')
73
+ sanitize_filename('valid!!___filename').must_equal('valid.filename')
74
74
  end
75
75
 
76
- it "uses sepc_char correctly" do
77
- sanitize_filename('valid.file name.txt','_').must_equal('valid_file_name.txt')
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-')
78
85
  end
79
86
  end
80
87
 
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.2
4
+ version: 0.1.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-25 00:00:00.000000000 Z
11
+ date: 2014-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: agile_utils
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.7
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.7
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: code_lister
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -200,15 +214,14 @@ files:
200
214
  - ebook_renamer.gemspec
201
215
  - lib/ebook_renamer.rb
202
216
  - lib/ebook_renamer/cli.rb
203
- - lib/ebook_renamer/core_ext/hash.rb
204
- - lib/ebook_renamer/helper.rb
205
217
  - lib/ebook_renamer/logger.rb
218
+ - lib/ebook_renamer/utils.rb
206
219
  - lib/ebook_renamer/version.rb
207
220
  - test/fixtures/ebooks/demo1.pdf
208
221
  - test/fixtures/ebooks/demo2.epub
209
222
  - test/fixtures/ebooks/subdir/demo1.pdf
210
223
  - test/fixtures/ebooks/subdir/demo2.epub
211
- - test/lib/ebook_renamer/helper_test.rb
224
+ - test/lib/ebook_renamer/test_utils.rb
212
225
  - test/test_helper.rb
213
226
  homepage: https://github.com/agilecreativity/ebook_renamer
214
227
  licenses:
@@ -240,6 +253,6 @@ test_files:
240
253
  - test/fixtures/ebooks/demo2.epub
241
254
  - test/fixtures/ebooks/subdir/demo1.pdf
242
255
  - test/fixtures/ebooks/subdir/demo2.epub
243
- - test/lib/ebook_renamer/helper_test.rb
256
+ - test/lib/ebook_renamer/test_utils.rb
244
257
  - test/test_helper.rb
245
258
  has_rdoc:
@@ -1,56 +0,0 @@
1
- class Hash
2
-
3
- # File activesupport/lib/active_support/core_ext/hash/keys.rb
4
- #
5
- # hash = { name: 'Rob', age: '28' }
6
- # hash.transform_keys{ |key| key.to_s.upcase }
7
- # => { "NAME" => "Rob", "AGE" => "28" }
8
- def transform_keys
9
- result = {}
10
- each_key do |key|
11
- result[yield(key)] = self[key]
12
- end
13
- result
14
- end
15
-
16
- def transform_keys!(&block)
17
- keys.each do |key|
18
- value = delete(key)
19
- self[yield(key)] = value.is_a?(Hash) ? value.transform_keys!(&block) : value
20
- end
21
- self
22
- end
23
-
24
- # hash = { 'name' => 'Rob', 'age' => '28' }
25
- # hash.symbolize_keys
26
- # => { name: "Rob", age: "28" }
27
- def symbolize_keys
28
- transform_keys{ |key| key.to_sym rescue key }
29
- end
30
-
31
- # File activesupport/lib/active_support/core_ext/hash/keys.rb, line 135
32
- def symbolize_keys!
33
- transform_keys!{ |key| key.to_sym rescue key }
34
- end
35
-
36
- # Merges the caller into +other_hash+. For example,
37
- #
38
- # options = options.reverse_merge(size: 25, velocity: 10)
39
- #
40
- # is equivalent to
41
- #
42
- # options = { size: 25, velocity: 10 }.merge(options)
43
- #
44
- # This is particularly useful for initializing an options hash
45
- # with default values.
46
- def reverse_merge(other_hash)
47
- other_hash.merge(self)
48
- end
49
-
50
- # Destructive +reverse_merge+.
51
- def reverse_merge!(other_hash)
52
- # right wins if there is no left
53
- merge!(other_hash) { |key,left,right| left }
54
- end
55
-
56
- end