fileman 0.1.21817 → 0.1.30646
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +22 -22
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +49 -49
- data/Rakefile +8 -8
- data/fileman.gemspec +38 -38
- data/lib/fileman.rb +3 -3
- data/lib/fileman/rename.rb +13 -14
- data/lib/fileman/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: febf89801ec699944102973dcad88b0fa961a31c
|
4
|
+
data.tar.gz: 32d397a79ee25dd9794480af74a84bf7faec60ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b323254d9bb0b9f00ed6310ee43fc58598d6cd89eb8b82e7db143477c886d986df47d72da8834902ad3152fdbab651030718afb285d049704ae4540a89124e39
|
7
|
+
data.tar.gz: df382817c7b46163957c1876ee8d8aabc1a578bdf780567d0c88afe504de031cba5a01d7648c667aa2c6b717e80416cc7b5bdfafce335b84bd77fb5d682c5e20
|
data/.gitignore
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in fileman.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in fileman.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2014 ndao
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2014 ndao
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
# Fileman
|
2
|
-
|
3
|
-
Fileman was originally designed to solve the Windows delete issue when a folder contains files whose path is greater than 260 characters. Over time, it got extended to support other features like renaming files following patterns. Though it was originally developed to solve a specific Windows limitation, Fileman can obviously be used on any other platform supporting ruby.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'fileman'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install fileman
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
### Overview
|
21
|
-
Once installed, Fileman is immediately available in the terminal through the 'fileman' or 'fm' command. For more details, simply type:
|
22
|
-
```sh
|
23
|
-
fm
|
24
|
-
```
|
25
|
-
### Examples
|
26
|
-
#### Delete a folder
|
27
|
-
```sh
|
28
|
-
fm rm your_folder
|
29
|
-
```
|
30
|
-
#### Rename a folder as well as all its subfolders
|
31
|
-
```sh
|
32
|
-
fm rn "your_folder" "new_name"
|
33
|
-
```
|
34
|
-
#### Rename a folder as well as all its subfolders, including files
|
35
|
-
```sh
|
36
|
-
fm rn "your_folder" "new_name" -i
|
37
|
-
```
|
38
|
-
#### Rename a folder as well as all its subfolders, including files (files extension are removed)
|
39
|
-
```sh
|
40
|
-
fm rn "your_folder" "new_name" -ie
|
41
|
-
```
|
42
|
-
|
43
|
-
## Contributing
|
44
|
-
|
45
|
-
1. Fork it ( https://github.com/[my-github-username]/fileman/fork )
|
46
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
-
5. Create a new Pull Request
|
1
|
+
# Fileman
|
2
|
+
|
3
|
+
Fileman was originally designed to solve the Windows delete issue when a folder contains files whose path is greater than 260 characters. Over time, it got extended to support other features like renaming files following patterns. Though it was originally developed to solve a specific Windows limitation, Fileman can obviously be used on any other platform supporting ruby.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fileman'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fileman
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
### Overview
|
21
|
+
Once installed, Fileman is immediately available in the terminal through the 'fileman' or 'fm' command. For more details, simply type:
|
22
|
+
```sh
|
23
|
+
fm
|
24
|
+
```
|
25
|
+
### Examples
|
26
|
+
#### Delete a folder
|
27
|
+
```sh
|
28
|
+
fm rm your_folder
|
29
|
+
```
|
30
|
+
#### Rename a folder as well as all its subfolders
|
31
|
+
```sh
|
32
|
+
fm rn "your_folder" "new_name"
|
33
|
+
```
|
34
|
+
#### Rename a folder as well as all its subfolders, including files
|
35
|
+
```sh
|
36
|
+
fm rn "your_folder" "new_name" -i
|
37
|
+
```
|
38
|
+
#### Rename a folder as well as all its subfolders, including files (files extension are removed)
|
39
|
+
```sh
|
40
|
+
fm rn "your_folder" "new_name" -ie
|
41
|
+
```
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( https://github.com/[my-github-username]/fileman/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create a new Pull Request
|
data/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require 'rake/testtask'
|
3
|
-
|
4
|
-
Rake::TestTask.new do |t|
|
5
|
-
t.libs << "lib"
|
6
|
-
t.libs << "test"
|
7
|
-
t.test_files = FileList['test/**/*test.rb']
|
8
|
-
t.verbose = true
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs << "lib"
|
6
|
+
t.libs << "test"
|
7
|
+
t.test_files = FileList['test/**/*test.rb']
|
8
|
+
t.verbose = true
|
9
9
|
end
|
data/fileman.gemspec
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
version = "0.1.%s" % ((Time.now.utc - Time.utc(2014, 7, 8))/60).round
|
5
|
-
version_file_path = File.join(lib, "fileman", "version.rb")
|
6
|
-
updated_content = nil
|
7
|
-
|
8
|
-
# update content
|
9
|
-
File.open(version_file_path, "rb") do |f|
|
10
|
-
content = f.read
|
11
|
-
updated_content = content.gsub(/(?<=").*?(?=")/, "%s" % version)
|
12
|
-
end
|
13
|
-
|
14
|
-
# overwrite version.rb with new content
|
15
|
-
File.open(version_file_path, "w") do |f|
|
16
|
-
f.write(updated_content)
|
17
|
-
end
|
18
|
-
|
19
|
-
Gem::Specification.new do |spec|
|
20
|
-
spec.name = "fileman"
|
21
|
-
spec.version = version
|
22
|
-
spec.authors = ["nicolasdao"]
|
23
|
-
spec.email = ["nicolas.dao@gmail.com"]
|
24
|
-
spec.summary = %q{Files and directories management in windows with super powers}
|
25
|
-
spec.description = %q{Enhance files and directories management in windows(e.g. deleting files and folders whose path is longer than 260 charatcers)}
|
26
|
-
spec.homepage = "https://github.com/nicolasdao/fileman"
|
27
|
-
spec.license = "MIT"
|
28
|
-
|
29
|
-
spec.files = `git ls-files -z`.split("\x0")
|
30
|
-
spec.executables = ['fileman', 'fm']
|
31
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
32
|
-
spec.require_paths = ["lib"]
|
33
|
-
|
34
|
-
spec.add_development_dependency "bundler", "~> 1.6"
|
35
|
-
spec.add_development_dependency "rake"
|
36
|
-
spec.add_development_dependency "turn", "~> 0.9"
|
37
|
-
spec.add_runtime_dependency "colorize", "~> 0.7"
|
38
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
version = "0.1.%s" % ((Time.now.utc - Time.utc(2014, 7, 8))/60).round
|
5
|
+
version_file_path = File.join(lib, "fileman", "version.rb")
|
6
|
+
updated_content = nil
|
7
|
+
|
8
|
+
# update content
|
9
|
+
File.open(version_file_path, "rb") do |f|
|
10
|
+
content = f.read
|
11
|
+
updated_content = content.gsub(/(?<=").*?(?=")/, "%s" % version)
|
12
|
+
end
|
13
|
+
|
14
|
+
# overwrite version.rb with new content
|
15
|
+
File.open(version_file_path, "w") do |f|
|
16
|
+
f.write(updated_content)
|
17
|
+
end
|
18
|
+
|
19
|
+
Gem::Specification.new do |spec|
|
20
|
+
spec.name = "fileman"
|
21
|
+
spec.version = version
|
22
|
+
spec.authors = ["nicolasdao"]
|
23
|
+
spec.email = ["nicolas.dao@gmail.com"]
|
24
|
+
spec.summary = %q{Files and directories management in windows with super powers}
|
25
|
+
spec.description = %q{Enhance files and directories management in windows(e.g. deleting files and folders whose path is longer than 260 charatcers)}
|
26
|
+
spec.homepage = "https://github.com/nicolasdao/fileman"
|
27
|
+
spec.license = "MIT"
|
28
|
+
|
29
|
+
spec.files = `git ls-files -z`.split("\x0")
|
30
|
+
spec.executables = ['fileman', 'fm']
|
31
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
35
|
+
spec.add_development_dependency "rake"
|
36
|
+
spec.add_development_dependency "turn", "~> 0.9"
|
37
|
+
spec.add_runtime_dependency "colorize", "~> 0.7"
|
38
|
+
end
|
data/lib/fileman.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require "fileman/version"
|
2
|
-
require "fileman/rename"
|
3
|
-
require "fileman/delete"
|
1
|
+
require "fileman/version"
|
2
|
+
require "fileman/rename"
|
3
|
+
require "fileman/delete"
|
data/lib/fileman/rename.rb
CHANGED
@@ -14,43 +14,42 @@ module Fileman
|
|
14
14
|
# 2 subfolder 'subf_a' and 'subf_b', then the new names will respectively
|
15
15
|
# be 'a1' and 'a2')
|
16
16
|
# +options+ Optional parameters defined as follow:
|
17
|
-
# +:include_files+ If true, all files will also be renamed. Extensions will be removed
|
17
|
+
# +:include_files+ If true, all files will also be renamed. Extensions will be removed.
|
18
|
+
# Default is false
|
18
19
|
# +:ignore_ext+ If true, and if 'include_files' is also true, then file's extensions
|
19
|
-
# are ignored
|
20
|
+
# are ignored. Default is false
|
20
21
|
#
|
21
22
|
# Returns the new name of the root folder
|
22
23
|
def rename_r(folder_path, new_name, options={})
|
23
24
|
include_files = !options[:include_files].nil? && options[:include_files]
|
25
|
+
ignore_ext = !options[:ignore_ext].nil? && options[:ignore_ext]
|
24
26
|
increment_name = lambda { |inc| inc == 0 ? new_name : "#{new_name}#{inc}" }
|
25
27
|
|
26
|
-
rename_item = lambda { |f
|
28
|
+
rename_item = lambda { |f|
|
27
29
|
parent_folder = File.expand_path("../", f)
|
28
|
-
file_ext =
|
30
|
+
file_ext = ignore_ext ? '' : File.extname(f)
|
29
31
|
counter = 0
|
30
|
-
while
|
32
|
+
while File.exists?(File.join(parent_folder, "#{increment_name.call(counter)}#{file_ext}")) do
|
31
33
|
counter+=1
|
32
34
|
end
|
33
35
|
final_name = increment_name.call(counter)
|
34
|
-
final_name = "#{final_name}#{file_ext}" unless
|
36
|
+
final_name = "#{final_name}#{file_ext}" unless ignore_ext
|
35
37
|
FileUtils.mv f, File.join(parent_folder, final_name)
|
36
38
|
final_name
|
37
39
|
}
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
final_new_name = new_name
|
43
|
-
all_items = Dir["#{folder_path}/**/*"]
|
41
|
+
final_root_folder_new_name = new_name
|
42
|
+
all_items = Dir.glob("#{folder_path}/**/*", File::FNM_DOTMATCH) - %w[. ..]
|
44
43
|
items_per_folder = all_items.group_by { |x| File.expand_path('../',x)}
|
45
44
|
|
46
45
|
sorted_items = items_per_folder.map { |k,v| v.sort_by{|y| y}.reverse }.flatten.reverse
|
47
46
|
(sorted_items << folder_path).each { |f|
|
48
47
|
if File.directory?(f)
|
49
|
-
|
48
|
+
final_root_folder_new_name = rename_item.call(f)
|
50
49
|
elsif include_files && File.file?(f)
|
51
|
-
rename_item.call(f
|
50
|
+
rename_item.call(f)
|
52
51
|
end
|
53
52
|
}
|
54
|
-
return
|
53
|
+
return final_root_folder_new_name
|
55
54
|
end
|
56
55
|
end
|
data/lib/fileman/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fileman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.30646
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nicolasdao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|