class AmsLayout::Client
Attributes
delegate_class_name[W]
layout_class_name[W]
Public Class Methods
new()
click to toggle source
# File lib/ams_layout/client.rb, line 20 def initialize # Make sure the configuration has been initialized. AmsLayout.configure end
Public Instance Methods
base_url()
click to toggle source
Return the base url for the current environment
# File lib/ams_layout/client.rb, line 62 def base_url return AmsLayout.configuration.base_urls[environment] end
credentials()
click to toggle source
Return the credentials for the current environment
# File lib/ams_layout/client.rb, line 55 def credentials return AmsLayout.configuration.credentials[environment] end
delegate_class_name()
click to toggle source
# File lib/ams_layout/client.rb, line 29 def delegate_class_name @delegate_class_name ||= AmsLayout.configuration.delegate_class_name end
environment()
click to toggle source
Return the current environment
# File lib/ams_layout/client.rb, line 47 def environment @env ||= AmsLayout.configuration.default_environment @env end
environment=(env)
click to toggle source
Set the current environment
# File lib/ams_layout/client.rb, line 36 def environment=(env) raise "Unknown environment [#{env}]" unless AmsLayout.configuration.credentials.key?(env) @env = env AmsLayout.configure do |config| config.default_environment = env end end
get_field_data()
click to toggle source
Retrieve field data from Loan Entry (Prequal) screen
# File lib/ams_layout/client.rb, line 99 def get_field_data prequal = PrequalDetail.new(browser, true) parser = Parser.new parser.parse prequal.html parser.layout end
layout_class_name()
click to toggle source
# File lib/ams_layout/client.rb, line 25 def layout_class_name @layout_class_name ||= AmsLayout.configuration.layout_class_name end
login(username, password, options = {})
click to toggle source
Login to the Admin Module
If we’re already logged in, do nothing unless the force
flag is true.
force
force a re-login if we’ve already logged in
# File lib/ams_layout/client.rb, line 73 def login(username, password, options = {}) force = options.fetch(:force) { false } logout login_page(force).login_as username, password end
logout()
click to toggle source
# File lib/ams_layout/client.rb, line 80 def logout login_page.logout @login_page = nil end
quit()
click to toggle source
Close the browser
# File lib/ams_layout/client.rb, line 88 def quit unless @browser.nil? logout @browser.close @browser = nil end end
write_alias_example(layout_file_path)
click to toggle source
# File lib/ams_layout/client.rb, line 113 def write_alias_example layout_file_path layout = YAML::load_file(layout_path(layout_file_path)) aliases = {} layout.each do |section_label, fields| fields.each do |fld| label = fld[:label] aliases[label] = [ "Alias1 #{label}", "Alias2 #{label}" ] end # fields end # layout File.write "#{layout_path(layout_file_path)}.aliases.example", YAML.dump(aliases) end
write_delegate_class(path, layout_file_path)
click to toggle source
# File lib/ams_layout/client.rb, line 144 def write_delegate_class path, layout_file_path assert_file_exists layout_path(layout_file_path) layout = YAML::load_file(layout_path(layout_file_path)) aliases = YAML::load_file("#{layout_path(layout_file_path)}.aliases") if File.exist?("#{layout_path(layout_file_path)}.aliases") writer = DelegateWriter.new writer.class_name = delegate_class_name writer.aliases = aliases unless aliases.nil? File.open(delegate_class_path(path), 'w') do |f| writer.write f, layout end end
write_layout(path, write_alias_example = false)
click to toggle source
# File lib/ams_layout/client.rb, line 106 def write_layout path, write_alias_example = false layout = get_field_data File.write layout_path(path), YAML.dump(layout) write_alias_example layout_path(path) if write_alias_example end
write_layout_class(path, layout_file_path)
click to toggle source
# File lib/ams_layout/client.rb, line 130 def write_layout_class path, layout_file_path assert_file_exists layout_path(layout_file_path) layout = YAML::load_file(layout_path(layout_file_path)) aliases = YAML::load_file("#{layout_path(layout_file_path)}.aliases") if File.exist?("#{layout_path(layout_file_path)}.aliases") writer = Writer.new writer.class_name = layout_class_name writer.aliases = aliases unless aliases.nil? File.open(layout_class_path(path), 'w') do |f| writer.write f, layout end end
Private Instance Methods
assert_file_exists(filename)
click to toggle source
# File lib/ams_layout/client.rb, line 186 def assert_file_exists filename fail "#{filename} does not exist" unless File.exist?(filename) end
delegate_class_path(path)
click to toggle source
# File lib/ams_layout/client.rb, line 172 def delegate_class_path path path = Pathname(path) filename = delegate_class_name.ams_layout_snakecase + '.rb' path = path + filename end
layout_class_path(path)
click to toggle source
# File lib/ams_layout/client.rb, line 166 def layout_class_path path path = Pathname(path) filename = layout_class_name.ams_layout_snakecase + '.rb' path = path + filename end
layout_path(path)
click to toggle source
# File lib/ams_layout/client.rb, line 160 def layout_path path path = Pathname(path) filename = 'layout.yml' path = path + filename end
login_page(force = false)
click to toggle source
# File lib/ams_layout/client.rb, line 178 def login_page force = false if force || @login_page.nil? @login_page = LoginPage.new(browser, true) end @login_page end