Class: PkgConfig
- Inherits:
-
Object
- Object
- PkgConfig
- Defined in:
- lib/autobuild/pkgconfig.rb
Overview
Access to information from pkg-config(1)
Defined Under Namespace
Classes: NotFound
Constant Summary collapse
- ACTIONS =
%w[cflags cflags-only-I cflags-only-other libs libs-only-L libs-only-l libs-only-other static].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The module name.
-
#version ⇒ Object
readonly
The module version.
Instance Method Summary collapse
-
#initialize(name) ⇒ PkgConfig
constructor
Create a PkgConfig object for the package
name
Raises PkgConfig::NotFound if the module does not exist. - #method_missing(varname, *args, &proc) ⇒ Object
- #respond_to_missing?(varname, _include_all) ⇒ Boolean
Constructor Details
#initialize(name) ⇒ PkgConfig
Create a PkgConfig object for the package name
Raises PkgConfig::NotFound if the module does not exist
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/autobuild/pkgconfig.rb', line 23 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(varname, *args, &proc) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/autobuild/pkgconfig.rb', line 46 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 |
Instance Attribute Details
#name ⇒ Object (readonly)
The module name
17 18 19 |
# File 'lib/autobuild/pkgconfig.rb', line 17 def name @name end |
#version ⇒ Object (readonly)
The module version
19 20 21 |
# File 'lib/autobuild/pkgconfig.rb', line 19 def version @version end |
Instance Method Details
#respond_to_missing?(varname, _include_all) ⇒ Boolean
42 43 44 |
# File 'lib/autobuild/pkgconfig.rb', line 42 def respond_to_missing?(varname, _include_all) varname =~ /^\w+$/ end |