Class: Magica::PackageConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/magica/package_config.rb

Overview

:nodoc:

Constant Summary collapse

LIBRARY_PATH_RULE =
/-L([^\s]+)/
LIBRARY_RULE =
/-l([^\s]+)/
LIBRARY_FLAG_RULE =
/-[^lL][^\s]+/
INCLUDE_RULE =
/-I([^\s]+)/
DEFINE_RULE =
/-D([^\s]+)/
FLAG_RULE =
/-[^ID][^\s]+/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ PackageConfig

Returns a new instance of PackageConfig.



23
24
25
26
27
28
29
30
31
# File 'lib/magica/package_config.rb', line 23

def initialize(name)
  raise "Cannot found library #{name}" unless package_exist?(name)
  @name = name

  @package_libraries = `pkg-config --libs #{@name}`.strip
  @package_cflags = `pkg-config --cflags #{@name}`.strip

  @version = `pkg-config --modversion #{@name}`.strip
end

Instance Attribute Details

#definesObject (readonly)

Returns the value of attribute defines.



20
21
22
# File 'lib/magica/package_config.rb', line 20

def defines
  @defines
end

#flagsObject (readonly)

Returns the value of attribute flags.



20
21
22
# File 'lib/magica/package_config.rb', line 20

def flags
  @flags
end

#include_pathsObject (readonly)

Returns the value of attribute include_paths.



20
21
22
# File 'lib/magica/package_config.rb', line 20

def include_paths
  @include_paths
end

#librariesObject (readonly)

Returns the value of attribute libraries.



20
21
22
# File 'lib/magica/package_config.rb', line 20

def libraries
  @libraries
end

#library_flagsObject (readonly)

Returns the value of attribute library_flags.



20
21
22
# File 'lib/magica/package_config.rb', line 20

def library_flags
  @library_flags
end

#library_pathsObject (readonly)

Returns the value of attribute library_paths.



20
21
22
# File 'lib/magica/package_config.rb', line 20

def library_paths
  @library_paths
end

#versionObject (readonly)

Returns the value of attribute version.



20
21
22
# File 'lib/magica/package_config.rb', line 20

def version
  @version
end

Class Method Details

.[](name) ⇒ Object



5
6
7
8
9
10
# File 'lib/magica/package_config.rb', line 5

def [](name)
  @packages ||= {}
  config = @packages[name.to_s]
  config = @packages[name.to_s] = PackageConfig.new(name) if config.nil?
  config
end

Instance Method Details

#package_exist?(name) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/magica/package_config.rb', line 33

def package_exist?(name)
  system "pkg-config --exists #{name}"
end