folders_renamer 0.1.1 → 0.1.2

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: 16f39f91fc475ebea67ebf29ae7f09854c6aeb30
4
- data.tar.gz: f8fee7f1217c9087c3bdc557ef658addd610e313
3
+ metadata.gz: 4435cbed167eafecf60d8397e12350a675a045f5
4
+ data.tar.gz: 49b62f2ffccd8ce6f4eab4664e2471ac952eb5d8
5
5
  SHA512:
6
- metadata.gz: 0265a40fedbfce56cf2f7b01c256eb2ade4ea613565e07dea3a4f4a94f630e39aa35ec67a04c8209986e26fc627827b466078b07aaf68209374c30fee8ad85c1
7
- data.tar.gz: 7aea3f338fefc303d2fb242c42658a0b4aa001eb9bd6f71ce42aad4299f91fbe36f681f19a2f30f42cbd65b428df5094c8e67f6b613646838f2e9319d5266aec
6
+ metadata.gz: 6f0567f370e6dc320ca482ef2121a965b7e2869c48f1bb29da9d3e9d1bbbe889dc714e54211bead4771d26d8149e81c4468a001925be5d0bbd6909fef139a2d4
7
+ data.tar.gz: 75fa20a55585c53dde5ea70561b3d5a6eca4874dc7aa3f8a827d9c22aa0f5eeb090510e9edd6080cd0476b5010a8b89947fa1e93f53ec25f987550d598d716ed
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## Changelogs
2
2
 
3
+ ### 0.1.2
4
+ * Update `filename_cleaner` to 0.3
5
+ * Add `--commit` options to allow the dry-run
6
+
3
7
  ### 0.1.1
4
8
  * Fix the link in README.md
5
9
 
data/README.md CHANGED
@@ -14,14 +14,16 @@ Rename/cleanup folder names using the simple rules. For optimal result you may l
14
14
  also like to try my [filename_cleaner][] gem which clean/rename the bad file names.
15
15
 
16
16
  Features
17
- ========
17
+ --------
18
18
 
19
19
  - Rename directory recursively from any starting location
20
20
  - Replace unwanted characters with value of your choice using `--sep-string` option (default to . (dot))
21
21
  - Following the [Semantic Versioning][] for release schedule
22
22
  - Quickly rename bad folder names to good folder names with one command.
23
23
 
24
- e.g. turn these directories (if your OS allow you to have these names)
24
+ TL;DR
25
+ -----
26
+ Turn these directories (if your OS allow you to have these names)
25
27
 
26
28
  ```
27
29
  some_folder/
@@ -41,6 +43,18 @@ some_folder/
41
43
  ├── aa_aa
42
44
     └── bb_bb
43
45
      └── cc_cc
46
+
47
+ ```
48
+ using command like:
49
+
50
+ ```sh
51
+ cd ~/path/to/some_folder/
52
+
53
+ # Perform the dry-run to see what will be changed (no changes)
54
+ folders_renamer rename --sep-string _
55
+
56
+ # Commit your changes
57
+ folders_renamer rename --sep-string _ --commit
44
58
  ```
45
59
 
46
60
  ### Installation
@@ -58,14 +72,16 @@ Usage:
58
72
  folders_renamer rename -b, --base-dir=BASE_DIR -s, --sep-string=SEP_STRING
59
73
 
60
74
  Options:
61
- -b, --base-dir=BASE_DIR # Starting directory
62
- # Default: . (current directory)
63
- -s, --sep-string=SEP_STRING # Separtor string to use
64
- # Default: .
65
- -v, [--version=VERSION] # Display version number
75
+ -b, --base-dir=BASE_DIR # Starting directory
76
+ # Default: . (current directory)
77
+ -s, --sep-string=SEP_STRING # Separtor string to use
78
+ # Default: .
79
+ -c, [--commit], [--no-commit] # Commit your changes (defalt --no-commit)
80
+ -v, [--version=VERSION] # Display version number
66
81
 
67
82
  Cleanup and rename folders
68
83
  ```
84
+
69
85
  ### Contributing
70
86
 
71
87
  1. Fork it
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.test_files = Dir.glob("{test}/**/*")
25
25
  spec.require_paths = ["lib"]
26
26
  spec.add_runtime_dependency "thor", "~> 0.19"
27
- spec.add_runtime_dependency "filename_cleaner", "~> 0.2"
27
+ spec.add_runtime_dependency "filename_cleaner", "~> 0.3"
28
28
  spec.add_development_dependency "awesome_print", "~> 1.2"
29
29
  spec.add_development_dependency "bundler", "~> 1.5"
30
30
  spec.add_development_dependency "gem-ctags", "~> 1.0"
@@ -12,6 +12,11 @@ module FoldersRenamer
12
12
  desc: "Separtor string to use",
13
13
  default: ".",
14
14
  required: true
15
+ method_option :commit,
16
+ type: :boolean,
17
+ aliases: '-c',
18
+ desc: 'Commit your changes',
19
+ default: false
15
20
  method_option "version",
16
21
  aliases: "-v",
17
22
  desc: "Display version number"
@@ -22,7 +27,7 @@ module FoldersRenamer
22
27
  exit
23
28
  end
24
29
  puts "Your options #{opts}"
25
- process(opts)
30
+ FoldersRenamer.rename(opts)
26
31
  end
27
32
 
28
33
  desc "usage", "Display help screen"
@@ -32,23 +37,16 @@ Usage:
32
37
  folders_renamer rename -b, --base-dir=BASE_DIR -s, --sep-string=SEP_STRING
33
38
 
34
39
  Options:
35
- -b, --base-dir=BASE_DIR # Starting directory
36
- # Default: . (current directory)
37
- -s, --sep-string=SEP_STRING # Separtor string to use
38
- # Default: .
39
- -v, [--version=VERSION] # Display version number
40
+ -b, --base-dir=BASE_DIR # Starting directory
41
+ # Default: . (current directory)
42
+ -s, --sep-string=SEP_STRING # Separtor string to use
43
+ # Default: .
44
+ -c, [--commit], [--no-commit] # Commit your changes
45
+ -v, [--version=VERSION] # Display version number
40
46
 
41
47
  Cleanup and rename folders
42
48
  EOS
43
49
  end
44
-
45
50
  default_task :usage
46
-
47
- private
48
-
49
- def process(opts = {})
50
- puts "FYI: your options #{opts}"
51
- FoldersRenamer.rename(opts[:base_dir], opts[:sep_string])
52
- end
53
51
  end
54
52
  end
@@ -4,8 +4,10 @@ require "filename_cleaner"
4
4
  module FoldersRenamer
5
5
  CustomError = Class.new(StandardError)
6
6
  class << self
7
- def rename(base_dir = Dir.pwd, sep_string = ".")
8
- base_dir = File.expand_path(base_dir)
7
+ def rename(options)
8
+ base_dir = File.expand_path(options[:base_dir])
9
+ sep_string = options[:sep_string]
10
+ commit = options[:commit]
9
11
 
10
12
  unless File.directory?(base_dir) && File.readable?(base_dir)
11
13
  fail "#{base_dir} is not a valid directory or not readable!"
@@ -17,10 +19,15 @@ module FoldersRenamer
17
19
  unless new_path == path
18
20
  puts "FYI: rename from: #{path}"
19
21
  puts "FYI: rename to : #{new_path}"
20
- path.rename(new_path)
22
+ path.rename(new_path) if commit
21
23
  end
22
24
  end
23
25
  end
26
+ unless commit
27
+ puts "---------------------------------------------------------------------"
28
+ puts "This is the dry run only, use --commit to make your changes permanent"
29
+ puts "---------------------------------------------------------------------"
30
+ end
24
31
  end
25
32
 
26
33
  private
@@ -1,3 +1,3 @@
1
1
  module FoldersRenamer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -11,7 +11,7 @@ describe FoldersRenamer do
11
11
  context "#rename" do
12
12
  it "works with default separator string" do
13
13
  FileUtils.cd @base_dir
14
- FoldersRenamer.rename(@base_dir, ".")
14
+ FoldersRenamer.rename(base_dir: @base_dir, sep_string: ".", commit: true)
15
15
  filesystem do
16
16
  dir "base" do
17
17
  dir "aa.01" do
@@ -22,7 +22,7 @@ describe FoldersRenamer do
22
22
  end
23
23
  it "works with non-default separator string" do
24
24
  FileUtils.cd @base_dir
25
- FoldersRenamer.rename(@base_dir, "_")
25
+ FoldersRenamer.rename(base_dir: @base_dir, sep_string: "_", commit: true)
26
26
  filesystem do
27
27
  dir "base" do
28
28
  dir "aa_01" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: folders_renamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.2'
33
+ version: '0.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.2'
40
+ version: '0.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: awesome_print
43
43
  requirement: !ruby/object:Gem::Requirement