Module: Xezat

Included in:
Command::Bump, Command::Doctor, Command::Init, Command::Port, 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/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/generate.rb,
lib/xezat/detector/halibut.rb,
lib/xezat/detector/libtool.rb,
lib/xezat/detector/roundup.rb,
lib/xezat/debugger/linguist.rb,
lib/xezat/debugger/variable.rb,
lib/xezat/detector/autoconf.rb,
lib/xezat/detector/automake.rb,
lib/xezat/detector/boost.m4.rb,
lib/xezat/detector/gengetopt.rb,
lib/xezat/generator/pkgconfig.rb,
lib/xezat/ext/linguist/file_blob.rb,
lib/xezat/detector/python-docutils.rb,
lib/xezat/detector/libQt5Core-devel.rb,
lib/xezat/detector/gobject-introspection.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'))
INI_FILE =
File.expand_path(File.join(Dir.home, '.xezat'))
LOG =
Logger.new(STDOUT)
VERSION =
'0.1.0'.freeze

Instance Method Summary collapse

Instance Method Details

#config(filepath = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/xezat/config.rb', line 4

def config(filepath = nil)
  config = IniFile.new
  config['cygwin'] = {
      'cygclassdir' => '/usr/share/cygport/cygclass'
  }
  config['xezat'] = {
  }
  config.merge!(IniFile.load(filepath)) if filepath
  config
end

#packages(db_path = '/etc/setup/installed.db') ⇒ Object

Raises:

  • (ArgumentError)


2
3
4
5
6
7
8
9
10
11
# File 'lib/xezat/packages.rb', line 2

def packages(db_path = '/etc/setup/installed.db')
  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) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/xezat/variables.rb', line 11

def variables(cygport)
  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.load(result).each_value do |v|
    v.strip! if v.respond_to?(:strip)
  end
  variables[:DESCRIPTION].word_wrap!(79)
  variables
end