Sha256: 6e8f2972ea67748d6f312b0d8601b8c3f4714231c288de756c6065516dcb49ce

Contents?: true

Size: 732 Bytes

Versions: 5

Compression:

Stored size: 732 Bytes

Contents

require_relative '../livetext'
require_relative '../helpers'
require_relative 'string'

make_exception(:NoEqualSign,     "Error: no equal sign found")

class Livetext::ParseMixin
  include Helpers

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

  def self.get_module(name)
    parse = self.new(name)
    modname, code = parse.read_mixin
    eval(code)   # Avoid in the future
    newmod = Object.const_get("::" + modname)
    # return actual module
    newmod
  end

  def read_mixin
    modname = @name.gsub("/","_").capitalize
    meths = grab_file(@file)
    [modname, "module ::#{modname}; #{meths}\nend"]
  end

  private

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


end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
livetext-0.9.22 lib/parser/mixin.rb
livetext-0.9.21 lib/parser/mixin.rb
livetext-0.9.20 lib/parser/mixin.rb
livetext-0.9.19 lib/parser/mixin.rb
livetext-0.9.17 lib/parser/mixin.rb