Top Level Namespace
Defined Under Namespace
Modules: GitCommands, Lace, LaceArgvExtension
Classes: AbstractDownloadStrategy, AlreadyActiveError, CannotRemoveActivePackage, Diff, DownloadStrategyDetector, ErrorDuringExecution, FlavorArgumentRequired, FlavorError, GitDownloadStrategy, GitHubDownloadStrategy, GitUpdateStrategy, LocalFileStrategy, ManifestErbError, NonActiveFlavorError, OnlyGitReposCanBeUpdatedError, Package, PackageAlreadyInstalled, PackageFacts, PackageFactsNotFound, PackageFlavorDoesNotExist, PackageNotInstalled, PackagePresenter, PackageUtils, PackageValidator, Pathname, ResourceNotSpecified, Tty, UsageError, WouldOverwriteError
Constant Summary
collapse
- HELP =
"Example usage:\n Synopsis:\n lace <cmd> <pkg-uri/name> [<flavor>] [--name=<name>] [--version] [--no-hooks] [--force]\n\n lace ls\n\n lace fetch <pkg-uri>\n lace fetch <pkg-uri>\n\n lace setup <pkg-uri>\n lace setup <pkg-uri> <flavor>\n\n lace activate <pkg-name>\n lace activate <pkg-name> <flavor>\n\n lace deactivate <pkg-name>\n lace deactivate <pkg-name> <flavor>\n\n lace remove <pkg-name>\n lace update <pkg-name>\n\nTroubleshooting:\n lace help\n lace info <pkg-name>\n lace validate <local-directory>\n lace --version\n\nFor further help visit:\n https://github.com/kairichard/lace\n"
- INSPECT =
"Inspection of <%= package.name %>:\n active: <%= package.is_active? %>\n flavors: <%= package.flavors %>\n version: <%= package.version %>\n homepage: <%= package.homepage %>\n upgradeable: <%= package.upgradeable? %>\n manifest: <%= package.manifest %>\n"
- VALIDATE =
"Lace-Manifest Validation Report:\n<% validation.errors.each do |error| -%>\n <%= \"%-58s [ %s ]\" % [error[0] + ':', error[1]] %>\n<% unless error[2].nil? -%>\n<% error[2].each do |line| -%>\n <%= Tty.gray %><%= '# '+line.to_s %><%= Tty.reset %>\n<% end -%>\n<% end -%>\n<% end -%>\n"
- FlavorArgumentMsg =
"Sorry, this command needs a flavor argument you can choose from the following:\n- %s\n"
- COMMON_CONFIG_FOLDERS =
['config'].freeze
Instance Method Summary
collapse
Instance Method Details
#determine_os ⇒ Object
91
92
93
94
95
96
97
|
# File 'lib/lace/utils.rb', line 91
def determine_os
case RUBY_PLATFORM
when /darwin/ then :mac
when /linux/ then :linux
else raise InvalidOSError
end
end
|
#odie(error) ⇒ Object
86
87
88
89
|
# File 'lib/lace/utils.rb', line 86
def odie error
onoe error
exit 1
end
|
#ofail(error) ⇒ Object
81
82
83
84
|
# File 'lib/lace/utils.rb', line 81
def ofail error
onoe error
Lace.failed = true
end
|
#oh1(title) ⇒ Object
66
67
68
69
|
# File 'lib/lace/utils.rb', line 66
def oh1 title
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
puts "#{Tty.green}==>#{Tty.white} #{title}#{Tty.reset}"
end
|
#ohai(title, *sput) ⇒ Object
60
61
62
63
64
|
# File 'lib/lace/utils.rb', line 60
def ohai title, *sput
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
puts "#{Tty.blue}==>#{Tty.white} #{title}#{Tty.reset}"
puts sput unless sput.empty?
end
|
#onoe(error) ⇒ Object
75
76
77
78
79
|
# File 'lib/lace/utils.rb', line 75
def onoe error
lines = error.to_s.split("\n")
STDERR.puts "#{Tty.red}Error#{Tty.reset}: #{lines.shift}"
STDERR.puts lines unless lines.empty?
end
|
#opoo(warning) ⇒ Object
71
72
73
|
# File 'lib/lace/utils.rb', line 71
def opoo warning
STDERR.puts "#{Tty.red}Warning#{Tty.reset}: #{warning}"
end
|
#quiet_system(cmd, *args) ⇒ Object
122
123
124
125
126
127
128
129
|
# File 'lib/lace/utils.rb', line 122
def quiet_system cmd, *args
Lace.system(cmd, *args) do
$stdout.reopen('/dev/null')
$stderr.reopen('/dev/null')
end
end
|
#safe_system(cmd, *args) ⇒ Object
Kernel.system but with exceptions
114
115
116
117
118
119
|
# File 'lib/lace/utils.rb', line 114
def safe_system cmd, *args
unless Lace.system cmd, *args
args = args.map{ |arg| arg.to_s.gsub " ", "\\ " } * " "
raise ErrorDuringExecution, "Failure while executing: #{cmd} #{args}"
end
end
|
#traverse_directory(directory, package, &block) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/lace/package/utils.rb', line 86
def traverse_directory(directory, package, &block)
package_path = package.path
whitelisted_folders = package.facts.globbed_folder + COMMON_CONFIG_FOLDERS
Dir.foreach(directory) do |entry|
next if ['.', '..'].include?(entry)
entry_path = File.join(directory, entry)
if File.symlink?(entry_path) && File.readlink(entry_path).include?(package_path)
block.call(entry_path)
elsif File.directory?(entry_path) && whitelisted_folders.any? { |f| entry_path.include?(f) }
traverse_directory(entry_path, package, &block)
end
end
end
|