filename_cleaner 0.3.3 → 0.3.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: cb4e1811c30cbb8ad40689b572ff4d7a099b83db
4
- data.tar.gz: 1e5a886c58413e20778a95c66146cf53b480fc27
3
+ metadata.gz: b8af8655f9438095ba8da8fc47554d19fe5bf7a0
4
+ data.tar.gz: 257abb189fff5d6f9cf7628200379f5dff63667b
5
5
  SHA512:
6
- metadata.gz: ec9807e0e7e6e657054cd58e096ea07f40e39a17d4f724e07844eea203e568d972796b4770374a72be7d5d688906171491d299edebbb0b80f0cf5b434088512b
7
- data.tar.gz: c8f46961051f5be1e0b7842bf1bd4ee20ee1bb5f666b9b0a20ec920d4e60f0ffc7c1d579d84210e2cde7a5a6d091453e0e4d527bf520a919197e7fb3fd374007
6
+ metadata.gz: f33c78720e12463420e4894533ec4973b3a8dd098e4172eb1abc25b7eb37f3ad74c593af4bd9f0c5a831d494f4e10f8a0d7769da6928adb01cc3d01cca469a9f
7
+ data.tar.gz: ca80acd29f2bf4498cbde4e243bc60eb0c5a6fbddcc1448c38f2804225b9de68fe2625a3b07daea7f7a76d74d175ce7df6beec195b7c27db135ffa8bc2b4d215
data/CHANGELOG.md CHANGED
@@ -1,19 +1,28 @@
1
+ ### 0.3.4
2
+
3
+ * Code refactoring
4
+
1
5
  ### 0.3.3
6
+
2
7
  * Update gemspec not to use git for include of files
3
8
  * Rename 'CHANGELOGS.md' to 'CHANGELOG.md'
4
9
 
5
10
  ### 0.3.2
11
+
6
12
  * Add coveralls badges
7
13
 
8
14
  ### 0.3.1
15
+
9
16
  * Correct the sample usage in README.md
10
17
 
11
18
  ### 0.3.0
19
+
12
20
  * Cleanup and simplify the apis
13
21
  * Rename `--dry-run` to `--commit`
14
22
  * Remove the `--non-exts` options to only support file with extension
15
23
 
16
24
  ### 0.2.0
25
+
17
26
  * Cleanup the APIs
18
27
  * rename `sanitize_filename` to `sanitize_name_with_extension`
19
28
  * add `sanitize_name` for name that does not have any extension
@@ -21,20 +30,25 @@
21
30
  * Add core_ext/object/blank.rb
22
31
 
23
32
  ### 0.1.1
33
+
24
34
  * Remove the last char from the filename if it is not numbers or letters
25
35
 
26
36
  ### 0.1.0
37
+
27
38
  * First [Semantic Versioning][] version.
28
39
 
29
40
  ### 0.0.3
41
+
30
42
  * Remove the namespace and code refactoring
31
43
 
32
44
  ### 0.0.2
45
+
33
46
  * Update gem dependencies to the latest version
34
47
  * Update gemspec to reflect the actual feature of the gem
35
48
  * Update and cleanup README.md
36
49
 
37
50
  ### 0.0.1
51
+
38
52
  * Initial release
39
53
 
40
54
  [Semantic Versioning]: http://semver.org
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
  require_relative '../filename_cleaner'
5
5
  module FilenameCleaner
6
6
  class CLI < Thor
7
+ # rubocop:disable AmbiguousOperator, LineLength
7
8
  desc 'rename', 'Sanitize and rename file with special characters'
8
9
  method_option *AgileUtils::Options::BASE_DIR
9
10
  method_option *AgileUtils::Options::EXTS
@@ -12,12 +13,10 @@ module FilenameCleaner
12
13
  method_option *AgileUtils::Options::IGNORE_CASE
13
14
  method_option *AgileUtils::Options::RECURSIVE
14
15
  method_option *AgileUtils::Options::VERSION
15
-
16
16
  method_option :sep_char,
17
17
  aliases: '-s',
18
18
  desc: 'Separator char to use',
19
19
  default: '.'
20
-
21
20
  method_option :commit,
22
21
  type: :boolean,
23
22
  aliases: '-c',
@@ -56,7 +55,7 @@ Options:
56
55
  Sanitize and rename file with special characters
57
56
  EOS
58
57
  end
59
-
58
+ # rubocop:enable AmbiguousOperator, LineLength
60
59
  default_task :usage
61
60
 
62
61
  private
@@ -70,23 +69,27 @@ Sanitize and rename file with special characters
70
69
  puts "FYI: process : #{index + 1} of #{files.size}"
71
70
  dirname = File.dirname(File.expand_path(file))
72
71
  filename = File.basename(file)
73
- sanitized_name = FilenameCleaner::sanitize(filename, options[:sep_char], true)
72
+ sanitized_name = FilenameCleaner.sanitize(filename, options[:sep_char], true)
74
73
  old_name = File.expand_path(file)
75
74
  new_name = File.expand_path([dirname, sanitized_name].join(File::SEPARATOR))
76
- if new_name != old_name
77
- puts "FYI: old name: #{old_name}"
78
- puts "FYI: new name: #{new_name}"
79
- if options[:commit]
80
- FileUtils.mv old_name, new_name
81
- end
82
- else
83
- puts "FYI: same file #{old_name}"
84
- end
75
+ compare_and_rename(old_name, new_name, options[:commit])
85
76
  end
86
77
  unless options[:commit]
87
- puts 'No changes will take place as this is a dry run, to commit your change, please use --commit option'
78
+ puts '--------------------------------------------------------------'
79
+ puts 'This is a dry run, to commit your change, please use --commit option'
80
+ puts '--------------------------------------------------------------'
88
81
  end
89
82
  end
90
83
  end
84
+
85
+ def compare_and_rename(old_name, new_name, commit = optons[:commit])
86
+ if new_name != old_name
87
+ puts "FYI: old name: #{old_name}"
88
+ puts "FYI: new name: #{new_name}"
89
+ FileUtils.mv old_name, new_name if commit
90
+ else
91
+ puts "FYI: same file #{old_name}"
92
+ end
93
+ end
91
94
  end
92
95
  end
@@ -1,7 +1,6 @@
1
1
  module FilenameCleaner
2
2
  DOT = '.'
3
3
  class << self
4
-
5
4
  # Sanitize the any name with or without any extension
6
5
  #
7
6
  # @param [String] name the input string
@@ -1,3 +1,3 @@
1
1
  module FilenameCleaner
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filename_cleaner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.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-14 00:00:00.000000000 Z
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor