class Isomorfeus::AssetManager::RubyImport

Attributes

module_name[R]

Public Class Methods

new(ruby_module) click to toggle source
# File lib/isomorfeus/asset_manager/ruby_import.rb, line 6
def initialize(ruby_module)
  @ruby_module = ruby_module.end_with?('.rb') ? ruby_module : ruby_module + '.rb'
  @module_name = @ruby_module[0..-4]
  @import_name = @module_name.tr('/', '_')
end

Public Instance Methods

resolved_path() click to toggle source
# File lib/isomorfeus/asset_manager/ruby_import.rb, line 12
def resolved_path
  @resolved_path ||= resolve_path
end
to_s() click to toggle source
# File lib/isomorfeus/asset_manager/ruby_import.rb, line 16
def to_s
  "import(\"./#{@module_name}.js\");\n"
end

Private Instance Methods

resolve_path() click to toggle source
# File lib/isomorfeus/asset_manager/ruby_import.rb, line 22
def resolve_path
  split_ruby_path = @ruby_module.split('/')
  Opal.paths.each do |path|
    file = File.expand_path(File.join(*path.split('/').concat(split_ruby_path)))
    return file if File.exist?(file)
  end
  STDERR.puts "#{self.class.name}: unable to resolve ruby module #{@module_name}"
  nil
end