Class: Mumukit::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/mumukit/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Runner

Returns a new instance of Runner.



5
6
7
# File 'lib/mumukit/runner.rb', line 5

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/mumukit/runner.rb', line 3

def name
  @name
end

#runtimeObject (readonly)

Returns the value of attribute runtime.



3
4
5
# File 'lib/mumukit/runner.rb', line 3

def runtime
  @runtime
end

Class Method Details

.configure_defaults {|@default_config| ... } ⇒ Object

Yields:



66
67
68
69
# File 'lib/mumukit/runner.rb', line 66

def self.configure_defaults
  @default_config ||= OpenStruct.new
  yield @default_config
end

.default_configObject



62
63
64
# File 'lib/mumukit/runner.rb', line 62

def self.default_config
  @default_config
end

Instance Method Details

#configObject



24
25
26
# File 'lib/mumukit/runner.rb', line 24

def config
  @config or raise 'This runner has not being configured yet'
end

#configure {|@config| ... } ⇒ Object

Yields:



9
10
11
12
# File 'lib/mumukit/runner.rb', line 9

def configure
  @config ||= self.class.default_config.clone
  yield @config
end

#configure_runtime(config) ⇒ Object



20
21
22
# File 'lib/mumukit/runner.rb', line 20

def configure_runtime(config)
  @runtime = Mumukit::Runtime.new(config)
end

#directives_pipelineObject



32
33
34
# File 'lib/mumukit/runner.rb', line 32

def directives_pipeline
  @pipeline ||= new_directives_pipeline
end

#new_directives_pipelineObject



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mumukit/runner.rb', line 36

def new_directives_pipeline
  if config.preprocessor_enabled
    Mumukit::Directives::Pipeline.new(
        [new_sections_directive,
         new_interpolations_directive('test'),
         new_interpolations_directive('extra'),
         new_interpolations_directive('content'),
         new_flags_directive],
        config.comment_type)
  else
    Mumukit::Directives::NullPipeline
  end
end

#new_flags_directiveObject



58
59
60
# File 'lib/mumukit/runner.rb', line 58

def new_flags_directive
  Mumukit::Directives::Flags.new
end

#new_interpolations_directive(key) ⇒ Object



50
51
52
# File 'lib/mumukit/runner.rb', line 50

def new_interpolations_directive(key)
  Mumukit::Directives::Interpolations.new(key)
end

#new_sections_directiveObject



54
55
56
# File 'lib/mumukit/runner.rb', line 54

def new_sections_directive
  Mumukit::Directives::Sections.new nest_sections: Mumukit.config.multifile
end

#prefixObject



28
29
30
# File 'lib/mumukit/runner.rb', line 28

def prefix
  name.camelize
end

#reconfigure(&block) ⇒ Object



14
15
16
17
18
# File 'lib/mumukit/runner.rb', line 14

def reconfigure(&block)
  @config = nil
  @pipeline = nil
  configure &block
end