Class: LazyPP::Package
Constant Summary collapse
- PackageDir =
[ File.('~/.config/cpptranny/pkg'), Dir.pwd]
Instance Attribute Summary collapse
-
#compile_opts ⇒ Object
readonly
Returns the value of attribute compile_opts.
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#linker ⇒ Object
readonly
Returns the value of attribute linker.
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #cpp0x? ⇒ Boolean
- #find_pkg(name) ⇒ Object
-
#initialize(name) ⇒ Package
constructor
A new instance of Package.
- #parse_sh(txt) ⇒ Object
Constructor Details
#initialize(name) ⇒ Package
Returns a new instance of Package.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/readable-cpp/package.rb', line 21 def initialize name if f = find_pkg( name) @name = name dat = YAML.load_file f @includes = dat['include'].nil? ? nil : Array.wrap(dat['include']) @linker = parse_sh(dat['linker'] || '') @compile_opts = parse_sh(dat['compile_opts'] || '') @flags = Array.wrap(dat['flags'] || nil).compact else abort "Could not find package #{name}. Searched in #{PackageDir.join', '}" end end |
Instance Attribute Details
#compile_opts ⇒ Object (readonly)
Returns the value of attribute compile_opts.
15 16 17 |
# File 'lib/readable-cpp/package.rb', line 15 def compile_opts @compile_opts end |
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
15 16 17 |
# File 'lib/readable-cpp/package.rb', line 15 def includes @includes end |
#linker ⇒ Object (readonly)
Returns the value of attribute linker.
15 16 17 |
# File 'lib/readable-cpp/package.rb', line 15 def linker @linker end |
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
15 16 17 |
# File 'lib/readable-cpp/package.rb', line 15 def name @name end |
Class Method Details
Instance Method Details
#cpp0x? ⇒ Boolean
42 |
# File 'lib/readable-cpp/package.rb', line 42 def cpp0x?() @flags.include?('c++0x') || @flags.include?('cpp0x') end |
#find_pkg(name) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/readable-cpp/package.rb', line 44 def find_pkg name n = name + '.yml' PackageDir.map(&File.margs(:join, n)). #PackageDir.map{ |d| File.join(d, n) }. detect(&File.method(:exists?)) end |
#parse_sh(txt) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/readable-cpp/package.rb', line 34 def parse_sh txt if txt.respond_to? :map then txt.map { |t| parse_sh t } elsif txt =~ /^`(.+)`/ then warn "Executing sh commands from package #{name}: `#$1`" %x{#$1}.chomp##.gsub(/-l\\?;(?<foo>[^\\;]+)\\?;/, '-l\k<foo>') ##<- temporary fix for pkg-config returning -L;/path/; else txt end end |