file_sorter_tool 0.2.4 → 0.3.0
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/Rakefile +5 -16
- data/bin/file_sorter_tool +43 -8
- data/lib/file_sorter_tool.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2553f76d13ce6f0548a8cd578a5d7932efdf12c
|
4
|
+
data.tar.gz: efcb5dbae9efec279f9bc07e2db011c234a1ac76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5858ae9d51570b5fb095eb0565e7d6fd0ce7ad604c788f6bc4d9d49ed7c0211bfd47643acfff7221a91a064e46d1bd4f65247ab330fb54fa70764edc5fad5de
|
7
|
+
data.tar.gz: 617186bc8dcf7e4ce6c4647125942c25da8695213d20f9fab5179881108c941f1f1742a2d9e0bc1c0f3a054dc73c19d4160edf599e7e7a2b83b93ddad7c80cf7
|
data/Rakefile
CHANGED
@@ -1,23 +1,12 @@
|
|
1
1
|
require 'file_sorter_tool'
|
2
2
|
|
3
|
-
task default: 'sort:
|
3
|
+
# task default: 'sort:build'
|
4
4
|
|
5
5
|
namespace :sort do
|
6
6
|
|
7
|
-
desc '
|
8
|
-
task :
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
desc 'sort files'
|
13
|
-
task :do, [:path] do |t, args|
|
14
|
-
path = args[:path]
|
15
|
-
if path == nil || path.empty?
|
16
|
-
puts "path is empty!"
|
17
|
-
else
|
18
|
-
Dir.chdir(path)
|
19
|
-
FileSorterTool::process_dir path
|
20
|
-
end
|
21
|
-
end
|
7
|
+
# desc 'Build and reinstall gem'
|
8
|
+
# task :build do
|
9
|
+
# find . -name "file_sorter_tool-*" -delete
|
10
|
+
# end
|
22
11
|
|
23
12
|
end
|
data/bin/file_sorter_tool
CHANGED
@@ -1,13 +1,48 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'file_sorter_tool'
|
4
|
+
require 'optparse'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
Options = Struct.new(:dir)
|
7
|
+
|
8
|
+
class Parser
|
9
|
+
def self.parse options = ["-h"]
|
10
|
+
|
11
|
+
args = Options.new()
|
12
|
+
|
13
|
+
opt_parser = OptionParser.new do |opts|
|
14
|
+
opts.banner = "FileSorterTool v.#{FileSorterTool::VERSION}\n\nUsage: file_sorter_tool -p PATH\nexample: \'file_sorter_tool ~/Downloads\'\n\nOptions:\n"
|
15
|
+
|
16
|
+
opts.on("-h", "--help", "Prints this help") do
|
17
|
+
puts opts
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-p", "--path PATH", "Path to directory which need organize") do |path|
|
22
|
+
args.dir = path
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("-v","--version", "Show current version") do
|
26
|
+
puts "v.#{FileSorterTool::VERSION}"
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
opt_parser.parse! options
|
33
|
+
mandatory = [:dir]
|
34
|
+
missing = mandatory.select{ |param| args[param].nil? }
|
35
|
+
raise OptionParser::MissingArgument.new(missing.join(', ')) unless missing.empty?
|
36
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument, OptionParser::InvalidOption.superclass
|
37
|
+
puts $!.to_s
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
|
41
|
+
return args
|
42
|
+
end
|
13
43
|
end
|
44
|
+
|
45
|
+
options = Parser.parse ARGV.empty? ? %w[-h] : ARGV
|
46
|
+
path = options[:dir]
|
47
|
+
Dir.chdir(path)
|
48
|
+
FileSorterTool::process_dir path
|
data/lib/file_sorter_tool.rb
CHANGED