Class: Options
- Inherits:
-
Object
- Object
- Options
- Defined in:
- ext/options.rb
Instance Method Summary collapse
- #cmake_options ⇒ Object
- #extra_options ⇒ Object
- #help ⇒ Object
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #missing_options ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
2 3 4 5 6 7 8 |
# File 'ext/options.rb', line 2 def initialize @options = {} @pending_options = [] @ignored_options = [] configure end |
Instance Method Details
#cmake_options ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'ext/options.rb', line 30 def return @cmake_options if @cmake_options output = nil Dir.chdir __dir__ do output = `cmake -S sources -B build -L` end started = false @cmake_options = output.lines.filter_map {|line| if line.chomp == "-- Cache values" started = true next end next unless started option, value = line.chomp.split("=", 2) name, type = option.split(":", 2) [name, type, value] } end |
#extra_options ⇒ Object
55 56 57 58 |
# File 'ext/options.rb', line 55 def @options.keys + @pending_options + @ignored_options - .collect {|name, type, value| name} end |
#help ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'ext/options.rb', line 10 def help @options .collect_concat {|name, (type, value)| option = option_name(name) if type == :bool ["--enable-#{option}", "--disable-#{option}"] else "--#{option}=#{type.upcase}" end } .join($/) end |
#missing_options ⇒ Object
50 51 52 53 |
# File 'ext/options.rb', line 50 def .collect {|name, type, value| name} - @options.keys - @pending_options - @ignored_options end |
#to_s ⇒ Object
23 24 25 26 27 28 |
# File 'ext/options.rb', line 23 def to_s @options .reject {|name, (type, value)| value.nil?} .collect {|name, (type, value)| "-D #{name}=#{value == true ? "ON" : value == false ? "OFF" : value.shellescape}"} .join(" ") end |