Class: Mwc::CompileOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/mwc/compile_options.rb

Overview

The compile options

Constant Summary collapse

EXTRA_JS_TYPE =

:nodoc:

{
  library_js: '--js-library',
  pre_js: '--pre-js',
  post_js: '--post-js'
}.freeze
OPTIONS =
%i[shell source_map extra].freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CompileOptions

:nodoc:



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mwc/compile_options.rb', line 18

def initialize(options = {})
  @options = []

  options.each do |name, value|
    handler = "add_#{name}"
    send(handler, value) if respond_to?(handler)
  end

  OPTIONS.each { |name| send("setup_#{name}") }
  output(options[:format])
end

Instance Method Details

#setup_extraObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Setup extra options

Since:

  • 0.2.0



54
55
56
57
58
59
60
# File 'lib/mwc/compile_options.rb', line 54

def setup_extra
  return unless Mwc.project.options.any?

  Mwc.project.options.each do |option|
    @options.push option
  end
end

#setup_shellObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Setup shell file

Since:

  • 0.2.0



34
35
36
37
38
# File 'lib/mwc/compile_options.rb', line 34

def setup_shell
  return if Mwc.project.shell.nil?

  @options.push "--shell-file #{Mwc.project.shell}"
end

#setup_source_mapObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Setup source map

Since:

  • 0.2.0



44
45
46
47
48
# File 'lib/mwc/compile_options.rb', line 44

def setup_source_map
  return unless Mwc.project.source_map

  @options.push '-g4 --source-map-base /'
end

#to_sString

Convert options to string

Returns:

  • (String)

    the options



65
66
67
# File 'lib/mwc/compile_options.rb', line 65

def to_s
  @options.join(' ')
end