Sha256: 8351d2f852ba55fd1ee1da6fd5ae264b5a38ccc8868a3fed6bb9fe81006e59d9
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
# Access to information from pkg-config(1) class PkgConfig class NotFound < RuntimeError attr_reader :name def initialize(name) @name = name super() end def to_s "#{name} is not available to pkg-config" end end # The module name attr_reader :name # The module version attr_reader :version # Create a PkgConfig object for the package +name+ # Raises PkgConfig::NotFound if the module does not exist def initialize(name) unless system("pkg-config --exists #{name}") raise NotFound.new(name), "pkg-config package '#{name}' not found" end @name = name @version = `pkg-config --modversion #{name}`.chomp.strip @actions = Hash.new @variables = Hash.new end ACTIONS = %w[cflags cflags-only-I cflags-only-other libs libs-only-L libs-only-l libs-only-other static].freeze ACTIONS.each do |action| define_method(action.tr('-', '_')) do @actions[action] ||= `pkg-config --#{action} #{name}`.chomp.strip end end def respond_to_missing?(varname, _include_all) varname =~ /^\w+$/ end def method_missing(varname, *args, &proc) if args.empty? unless (value = @variables[varname]) value = `pkg-config --variable=#{varname} #{name}`.chomp.strip @variables[varname] = value end return value end super end end
Version data entries
5 entries across 5 versions & 1 rubygems