Class: Melon::Commands::Check
- Inherits:
-
Base
- Object
- Base
- Melon::Commands::Check
show all
- Defined in:
- lib/melon/commands/check.rb
Instance Attribute Summary
Attributes inherited from Base
#args, #description, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
command_name, #initialize, #parse_options!, #parser, #usagebanner, #verify_args
Methods included from Helpers
#blockquote, #error, #expand_dir, #format_command, #recursively_expand, #resolve_symlinks, #wrap_text
Class Method Details
.description ⇒ Object
7
8
9
|
# File 'lib/melon/commands/check.rb', line 7
def self.description
"Determine whether or not a copy of a file resides in the database"
end
|
Instance Method Details
#helptext ⇒ Object
11
12
13
14
15
16
|
# File 'lib/melon/commands/check.rb', line 11
def helptext
"If the file's hash matches a hash in the database, nothing is\nprinted. Otherwise, the full path to the file is printed.\n"
end
|
#parser_options(parser) ⇒ Object
22
23
24
25
|
# File 'lib/melon/commands/check.rb', line 22
def parser_options(parser)
CommonOptions.recursive(parser, options)
CommonOptions.preserve_symlinks(parser, options)
end
|
#run ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/melon/commands/check.rb', line 27
def run
parse_options!
if options.recursive
self.args = recursively_expand(args)
end
options.database.transaction do
args.each do |arg|
filename = File.expand_path(arg)
filename = resolve_symlinks(filename) unless options.preserve_symlinks
if File.directory?(filename)
error "argument is a directory: #{arg}"
end
hash = Hasher.digest(filename)
unless options.database[:by_hash][hash]
puts filename
end
end
end
end
|
#usageargs ⇒ Object
18
19
20
|
# File 'lib/melon/commands/check.rb', line 18
def usageargs
"FILE [FILE [FILE ...]]"
end
|