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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30b624d087dbd9093471d6c137f367fa258931bf
4
- data.tar.gz: 240cdc22fe50d86087c8cae2d2ed5f8ee5501453
3
+ metadata.gz: a2553f76d13ce6f0548a8cd578a5d7932efdf12c
4
+ data.tar.gz: efcb5dbae9efec279f9bc07e2db011c234a1ac76
5
5
  SHA512:
6
- metadata.gz: 81e439fa6dec5c358d0c6ab8eaab9c41d15fa1be7e6d455527a7324306095e0d69fef742410b78406d2788ce837106902340f7e04d24bfea77b85b952e897736
7
- data.tar.gz: d32350a1d8fb9f66cb5b2279f5b1d9aefd5b397963bac4e05c415c3d34af43dbb9136fdd975d9a1d7541a4ca41528b66cd233c2539e755c08e0cbcc795a15649
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:help'
3
+ # task default: 'sort:build'
4
4
 
5
5
  namespace :sort do
6
6
 
7
- desc 'help'
8
- task :help do
9
- puts "v. #{FileSorterTool::VERSION}.\nFiles in current directory sorter.\nTool makes directory for each file extenfion and move files into this directories."
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
- path = ARGV[0]
6
- if path == nil || path.empty?
7
- puts "v. #{FileSorterTool::VERSION}.\nTool makes directory for each file extenfion and move files into this directories."
8
- puts "file_sorter_tool [PATH]"
9
- puts "example:\nfile_sorter_tool ~/Downloads"
10
- else
11
- Dir.chdir(path)
12
- FileSorterTool::process_dir path
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
@@ -1,7 +1,7 @@
1
1
  require_relative 'file_sorter_tool/file_sorter.rb'
2
2
 
3
3
  module FileSorterTool
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
 
6
6
  def self.version
7
7
  version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_sorter_tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Torlopov