module Xezat
Constants
- CONFIG_FILE
- DATA_DIR
- REPOSITORY_DIR
- ROOT_DIR
- TEMPLATE_DIR
- VERSION
Attributes
logger[RW]
Public Instance Methods
config(filepath = nil)
click to toggle source
# File lib/xezat/config.rb, line 6 def config(filepath = nil) config = {} config['cygwin'] = { 'cygclassdir' => '/usr/share/cygport/cygclass' } config['xezat'] = { } config.merge!(YAML.load_file(filepath)) if filepath config end
packages(db_path = '/etc/setup/installed.db')
click to toggle source
# File lib/xezat/packages.rb, line 6 def packages(db_path = '/etc/setup/installed.db') Xezat.logger.debug(" Collect installed packages from #{db_path}") raise ArgumentError, "#{db_path} not found" unless File.exist?(db_path) packages = {} File.read(db_path).lines do |line| record = line.split(/\s+/) next unless record.size == 3 # /^hoge hoge-ver-rel.tar.bz2 0$/ packages[record[0].intern] = record[1].gsub(/\.tar\.bz2$/, '') end packages end
variables(cygport)
click to toggle source
# File lib/xezat/variables.rb, line 12 def variables(cygport) cygport_dir = File.dirname(File.absolute_path(cygport)) cache_file = File.expand_path(File.join(cygport_dir, "#{File.basename(cygport, '.cygport')}.#{Etc.uname[:machine]}.yml")) Xezat.logger.debug(' Extract variables') if File.exist?(cache_file) && File.ctime(cache_file) > File.ctime(cygport) Xezat.logger.debug(' Read cache for variables') return YAML.safe_load(File.open(cache_file), [Symbol]).each do |k, v| v.strip! if v.respond_to?(:strip) && k != :DESCRIPTION end end command = ['bash', File.expand_path(File.join(DATA_DIR, 'show_cygport_variable.sh')), cygport] result, error, status = Open3.capture3(command.join(' ')) raise CygportProcessError, error unless status.success? result.gsub!(/^.*\*\*\*.*$/, '') variables = YAML.safe_load(result, [Symbol]).each_value do |v| v.strip! if v.respond_to?(:strip) end variables[:DESCRIPTION].word_wrap!(79) File.atomic_write(cache_file) do |f| Xezat.logger.debug(' Write cache for variables') f.write(YAML.dump(variables)) end variables end