Class: Most::Core

Inherits:
Object show all
Defined in:
lib/most/core.rb

Defined Under Namespace

Classes: UnregisteredExtensionError

Instance Method Summary collapse

Constructor Details

#initializeCore

Returns a new instance of Core.



29
30
31
32
33
34
35
36
37
38
# File 'lib/most/core.rb', line 29

def initialize()
  @environment = SERVICES[:environment]
  @options     = @environment.options

  @strategies  = register_strategies()

  @last_eval_result = nil

  load_objects()
end

Instance Method Details

#runObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/most/core.rb', line 40

def run()
  result = nil

  submission = @options[:submission]
  
  paths = form_paths(submission)
  extension = File.extname(submission)

  proc = @strategies[extension]
  unless proc.nil?
    result = proc.call(paths)
  else
    exception = UnregisteredExtensionError.new("#{extension} is not registered")
    @environment.log_error(exception, "Only 'rb' or 'yml' extensions are allowed")
  end

  result
end