folders_renamer 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +23 -7
- data/folders_renamer.gemspec +1 -1
- data/lib/folders_renamer/cli.rb +12 -14
- data/lib/folders_renamer/folders_renamer.rb +10 -3
- data/lib/folders_renamer/version.rb +1 -1
- data/test/lib/folders_renamer/test_folders_renamer.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4435cbed167eafecf60d8397e12350a675a045f5
|
4
|
+
data.tar.gz: 49b62f2ffccd8ce6f4eab4664e2471ac952eb5d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f0567f370e6dc320ca482ef2121a965b7e2869c48f1bb29da9d3e9d1bbbe889dc714e54211bead4771d26d8149e81c4468a001925be5d0bbd6909fef139a2d4
|
7
|
+
data.tar.gz: 75fa20a55585c53dde5ea70561b3d5a6eca4874dc7aa3f8a827d9c22aa0f5eeb090510e9edd6080cd0476b5010a8b89947fa1e93f53ec25f987550d598d716ed
|
data/CHANGELOG.md
CHANGED
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
|
-
|
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
|
62
|
-
|
63
|
-
-s, --sep-string=SEP_STRING
|
64
|
-
|
65
|
-
-
|
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
|
data/folders_renamer.gemspec
CHANGED
@@ -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.
|
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"
|
data/lib/folders_renamer/cli.rb
CHANGED
@@ -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
|
-
|
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
|
36
|
-
|
37
|
-
-s, --sep-string=SEP_STRING
|
38
|
-
|
39
|
-
-
|
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(
|
8
|
-
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
|
@@ -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.
|
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-
|
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.
|
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.
|
40
|
+
version: '0.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: awesome_print
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|