Sha256: 5b964b2eac9777a75545b31b2fa6261590c08d050a1c295d1c060cecf3c7caad

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

require_relative '../helpers'
require_relative '../global_helpers'

class Livetext::Handler::Import
  include Livetext::Helpers
  include GlobalHelpers

  attr_reader :file

  def initialize(name)
    @name = name
    @file = find_file(name)
  end

  def self.get_mod_name
    file = File.new(@file + ".rb")
    str = nil
    file.each_line do |line| 
      str = line
      break if str =~ /^module /
    end
    junk, name, junk2 = str.split
    name
  end

  def self.get_module(filename)
    handler = self.new(filename)
    @file = handler.file.sub(/.rb$/, "")
    require @file   # + ".rb"
    modname = get_mod_name
# TTY.puts "modname = #{modname.inspect}"
    newmod = Object.const_get("::" + modname)
    newmod   # return actual module
  end

  private

  def cwd_root?
    File.dirname(File.expand_path(".")) == "/"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
livetext-0.9.23 lib/handler/import.rb