Class: Livetext::Handler::Import
- Includes:
- GlobalHelpers, Livetext::Helpers
- Defined in:
- lib/livetext/handler/import.rb
Overview
Handle a .import
Constant Summary
Constants included from Livetext::Helpers
Livetext::Helpers::Comment, Livetext::Helpers::DollarDot, Livetext::Helpers::DotCmd, Livetext::Helpers::ESCAPING, Livetext::Helpers::Sigil, Livetext::Helpers::Space, Livetext::Helpers::TTY
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ Import
constructor
Livetext::Handler::Import.
Methods included from GlobalHelpers
#check_disallowed, #check_file_exists, #cwd_root?, #grab_file, #search_upward
Methods included from Livetext::Helpers
#check_disallowed, #check_file_exists, #debug, #escape_html, #find_file, #friendly_error, #get_name_data, #grab_file, #graceful_error, #handle_dollar_dot, #handle_dotcmd, #handle_scomment, #include_file, #invoke_dotcmd, #onoff, #process_file, #process_line, #read_variables, rx, #search_upward, #set_variables, #setfile, #setfile!, #setvar, #showme
Constructor Details
#initialize(name) ⇒ Import
Livetext::Handler::Import
12 13 14 15 |
# File 'lib/livetext/handler/import.rb', line 12 def initialize(name) # Livetext::Handler::Import @name = name @file = find_file(name) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
10 11 12 |
# File 'lib/livetext/handler/import.rb', line 10 def file @file end |
Class Method Details
.get_mod_name ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/livetext/handler/import.rb', line 17 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 |
.get_module(filename, parent) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/livetext/handler/import.rb', line 28 def self.get_module(filename, parent) # TTY.puts "#{__method__}: filename = #{filename.inspect}" handler = self.new(filename) parent.graceful_error FileNotFound(filename) if handler.file.nil? @file = handler.file.sub(/.rb$/, "") require @file # + ".rb" modname = get_mod_name newmod = Object.const_get("::" + modname) newmod # return actual module end |