Class: Mxrb::Compiler::WidgetPackageExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/compiler/widget_package_extractor.rb

Overview

Expands project-owned pluggable widget packages into the web build tree. rubocop:disable Metrics

Instance Method Summary collapse

Constructor Details

#initialize(project_root, web_root) ⇒ WidgetPackageExtractor

Returns a new instance of WidgetPackageExtractor.



11
12
13
14
# File 'lib/mxrb/compiler/widget_package_extractor.rb', line 11

def initialize(project_root, web_root)
  @source = File.join(project_root, 'widgets')
  @destination = File.join(web_root, 'widgets')
end

Instance Method Details

#extractObject



16
17
18
19
20
21
# File 'lib/mxrb/compiler/widget_package_extractor.rb', line 16

def extract
  return 0 unless File.directory?(@source)

  FileUtils.mkdir_p(@destination)
  Dir.glob(File.join(@source, '*.mpk')).sort.sum { extract_package(_1) }
end