Module: Xezat
- Included in:
- Command::Announce, Command::Bump, Command::Doctor, Command::Init, Command::Port, Command::Validate, Debugger::Linguist, Debugger::Variable, Generator::Pkgconfig
- Defined in:
- lib/xezat.rb,
lib/xezat/main.rb,
lib/xezat/config.rb,
lib/xezat/version.rb,
lib/xezat/packages.rb,
lib/xezat/detectors.rb,
lib/xezat/variables.rb,
lib/xezat/cygclasses.rb,
lib/xezat/cygversion.rb,
lib/xezat/command/bump.rb,
lib/xezat/command/init.rb,
lib/xezat/command/port.rb,
lib/xezat/cygchangelog.rb,
lib/xezat/detector/waf.rb,
lib/xezat/command/debug.rb,
lib/xezat/detector/make.rb,
lib/xezat/detector/nasm.rb,
lib/xezat/command/doctor.rb,
lib/xezat/detector/cmake.rb,
lib/xezat/detector/meson.rb,
lib/xezat/detector/ninja.rb,
lib/xezat/detector/gnulib.rb,
lib/xezat/command/announce.rb,
lib/xezat/command/generate.rb,
lib/xezat/command/validate.rb,
lib/xezat/detector/halibut.rb,
lib/xezat/detector/libtool.rb,
lib/xezat/detector/roundup.rb,
lib/xezat/command/bump/file.rb,
lib/xezat/command/bump/tool.rb,
lib/xezat/debugger/linguist.rb,
lib/xezat/debugger/variable.rb,
lib/xezat/detector/asciidoc.rb,
lib/xezat/detector/autoconf.rb,
lib/xezat/detector/automake.rb,
lib/xezat/detector/boost.m4.rb,
lib/xezat/detector/python27.rb,
lib/xezat/detector/python36.rb,
lib/xezat/detector/python37.rb,
lib/xezat/detector/python38.rb,
lib/xezat/detector/python39.rb,
lib/xezat/detector/gengetopt.rb,
lib/xezat/generator/pkgconfig.rb,
lib/xezat/command/bump/src_uri.rb,
lib/xezat/command/bump/compiler.rb,
lib/xezat/command/bump/language.rb,
lib/xezat/command/bump/changelog.rb,
lib/xezat/ext/linguist/file_blob.rb,
lib/xezat/command/validate/config.rb,
lib/xezat/command/bump/cygport_dep.rb,
lib/xezat/command/validate/license.rb,
lib/xezat/detector/libQt5Core-devel.rb,
lib/xezat/command/validate/pkgconfig.rb,
lib/xezat/detector/python39-docutils.rb,
lib/xezat/command/bump/runtime_package.rb,
lib/xezat/detector/gobject-introspection.rb,
lib/xezat/command/bump/development_package.rb
Defined Under Namespace
Modules: Command, Debugger, Detector, Generator, Linguist
Classes: AutotoolsFileNotFoundError, Cygchangelog, CygclassConflictError, CygclassManager, CygportProcessError, Cygversion, DetectorManager, FilePermissionError, IllegalStateError, Main, NoPortDirectoryError, NoSuchCygclassError, NoSuchRepositoryError, ReadmeSyntaxError, UnoverwritableCygportError, UnregeneratableConfigurationError
Constant Summary
collapse
- ROOT_DIR =
File.expand_path(File.join(File.dirname(__FILE__), '..'))
- DATA_DIR =
File.expand_path(File.join(ROOT_DIR, 'share', 'xezat'))
- REPOSITORY_DIR =
File.expand_path(File.join(DATA_DIR, 'repository'))
- TEMPLATE_DIR =
File.expand_path(File.join(DATA_DIR, 'template'))
- CONFIG_FILE =
File.expand_path(File.join(Dir.home, '.xezat', 'config.yml'))
- VERSION =
'0.2.3'
Class Attribute Summary collapse
Instance Method Summary
collapse
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
13
14
15
|
# File 'lib/xezat.rb', line 13
def logger
@logger
end
|
Instance Method Details
#config(filepath = nil) ⇒ Object
6
7
8
9
10
11
12
13
14
15
|
# 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') ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# 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
packages[record[0].intern] = record[1].gsub(/\.tar\.bz2$/, '')
end
packages
end
|
#print_yaml(result) ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/xezat/variables.rb', line 51
def print_yaml(result)
lineno = 1
result.split($INPUT_RECORD_SEPARATOR).each do |line|
printf '%<lineno>5d | %<line>s%<ls>s', lineno: lineno, line: line, ls: $INPUT_RECORD_SEPARATOR
lineno += 1
end
end
|
#variables(cygport) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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/xezat/variables.rb', line 13
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, 'var2yaml.sh')), cygport]
result, error, status = Open3.capture3(command.join(' '))
raise CygportProcessError, error unless status.success?
result.gsub!(/^.*\*\*\*.*$/, '')
begin
variables = YAML.safe_load(result, [Symbol]).each_value do |v|
v.strip! if v.respond_to?(:strip)
end
rescue Psych::SyntaxError => e
print_yaml(result)
raise e
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
|