Class: Watirmark::Loader
Overview
This can be used for files that are page classes or flows. Autoloading them will not actually ‘require’ the file until a class in that file is used. Note that this does not apply to modules so it’s most useful for the page accessors and any files in admin, user, etc.
Instance Method Summary collapse
- #autoload_files(directory) ⇒ Object (also: #autoload_file)
- #base_directory(arg = nil) ⇒ Object
-
#load_files(directory) ⇒ Object
product not used.
- #module(arg = nil) ⇒ Object
- #product(arg = nil) ⇒ Object
Instance Method Details
#autoload_files(directory) ⇒ Object Also known as: autoload_file
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/watirmark/loader.rb', line 15 def autoload_files(directory) mod = "Watirmark::#{product}" each_file_in directory do |file| libpath = library_path(file) IO.readlines(file).each do |line| _autoload_(mod, $1, libpath) if line =~ /^\s*class\s+([^<]\S+)[\s<]/ _autoload_(mod, $1, libpath) if line =~ /^\s+([A-Z]\S+)\s+=\s+[A-Z]\S+/ end end end |
#base_directory(arg = nil) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/watirmark/loader.rb', line 42 def base_directory arg=nil if arg @base_directory = arg elsif @base_directory @base_directory else raise "base_directory not set" end end |
#load_files(directory) ⇒ Object
product not used
36 37 38 39 40 |
# File 'lib/watirmark/loader.rb', line 36 def load_files(directory) # product not used each_file_in directory do | file | require library_path(file) end end |
#module(arg = nil) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/watirmark/loader.rb', line 62 def module arg=nil if arg @module = arg elseif end end |
#product(arg = nil) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/watirmark/loader.rb', line 52 def product arg=nil if arg @product = arg elsif @product @product else raise "product not set" end end |