Class: Basketcase
- Inherits:
-
Object
show all
- Includes:
- Utils
- Defined in:
- lib/basketcase.rb
Defined Under Namespace
Modules: Utils
Classes: AddCommand, AutoCheckinCommand, AutoCommand, AutoSyncCommand, AutoUncheckoutCommand, CheckinCommand, CheckoutCommand, Command, DiffCommand, DirectoryModificationCommand, ElementStatus, HelpCommand, LogCommand, LsCoCommand, LsCommand, MoveCommand, RemoveCommand, TargetList, UncheckoutCommand, UpdateCommand, UsageException, VersionTreeCommand
Constant Summary
collapse
- VERSION =
'1.1.0'
- DefaultListener =
Object responsible for nice fomatting of output
lambda do |element|
printf("%-7s %-15s %s\n", element.status,
element.base_version, element.path)
end
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
#mkpath
Class Attribute Details
.usage ⇒ Object
Returns the value of attribute usage.
969
970
971
|
# File 'lib/basketcase.rb', line 969
def usage
@usage
end
|
Class Method Details
.command(command_class, names) ⇒ Object
959
960
961
962
|
# File 'lib/basketcase.rb', line 959
def command(command_class, names)
names.each { |name| @registry[name] = command_class }
@usage << " % #{names.join(', ')}\n"
end
|
.command_class(name) ⇒ Object
964
965
966
967
|
# File 'lib/basketcase.rb', line 964
def command_class(name)
return name if Class === name
@registry[name] || raise(UsageException, "Unknown command: #{name}")
end
|
Instance Method Details
#do(*args) ⇒ Object
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
|
# File 'lib/basketcase.rb', line 1026
def do(*args)
@args = args
begin
sync_io
handle_global_options
raise UsageException, "no command specified" if @args.empty?
define_standard_ignore_patterns
run(*@args)
rescue UsageException => usage
$stderr.puts "ERROR: #{usage.message}"
$stderr.puts
$stderr.puts "try 'basketcase help' for usage info"
exit(1)
end
end
|
#handle_global_options ⇒ Object
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
|
# File 'lib/basketcase.rb', line 1012
def handle_global_options
while /^-/ === @args[0]
option = @args.shift
case option
when '--test', '-t'
@test_mode = true
when '--debug', '-d'
@debug_mode = true
else
raise UsageException, "Unrecognised global argument: #{option}"
end
end
end
|
#ignored?(path) ⇒ Boolean
45
46
47
48
49
50
51
|
# File 'lib/basketcase.rb', line 45
def ignored?(path)
path = Pathname(path).expand_path
require_ignore_patterns_for(path.parent)
@ignore_patterns.detect do |pattern|
File.fnmatch(pattern, path, File::FNM_PATHNAME | File::FNM_DOTMATCH)
end
end
|
#just_testing? ⇒ Boolean
27
28
29
|
# File 'lib/basketcase.rb', line 27
def just_testing?
@test_mode
end
|
#log_debug(msg) ⇒ Object
22
23
24
25
|
# File 'lib/basketcase.rb', line 22
def log_debug(msg)
return unless @debug_mode
$stderr.puts(msg)
end
|
#make_command(name) ⇒ Object
996
997
998
|
# File 'lib/basketcase.rb', line 996
def make_command(name)
Basketcase.command_class(name).new(self)
end
|
#run(name, *args, &block) ⇒ Object
1000
1001
1002
1003
1004
1005
|
# File 'lib/basketcase.rb', line 1000
def run(name, *args, &block)
command = make_command(name)
command.accept_args(args) if args
command.listener = block if block_given?
command.execute
end
|
#sync_io ⇒ Object
1007
1008
1009
1010
|
# File 'lib/basketcase.rb', line 1007
def sync_io
$stdout.sync = true
$stderr.sync = true
end
|
#usage ⇒ Object
992
993
994
|
# File 'lib/basketcase.rb', line 992
def usage
Basketcase.usage
end
|