class AmsLayout::Generate

Public Instance Methods

all(path) click to toggle source
# File lib/ams_layout/cli/generate.rb, line 105
def all(path)
  env = AmsLayout.configuration.default_environment
  env = options[:env] if options[:env]
  user, pass = credentials env

  # Generate layout file
  client.login(user, pass)
  client.write_layout path, false
  client.logout

  # Generate layout class
  if options[:name]
    client.layout_class_name = options[:name]
  end

  client.write_layout_class path, path

  # Generate delegate class
  if options[:delegate]
    client.delegate_class_name = options[:delegate]
  end

  client.write_delegate_class path, path
end
cls(path, layout_path) click to toggle source
# File lib/ams_layout/cli/generate.rb, line 53
def cls(path, layout_path)
  if options[:name]
    client.layout_class_name = options[:name]
  end

  client.write_layout_class path, layout_path
end
delegate(path, layout_path) click to toggle source
# File lib/ams_layout/cli/generate.rb, line 78
def delegate(path, layout_path)
  if options[:delegate]
    client.delegate_class_name = options[:delegate]
  end

  client.write_delegate_class path, layout_path
end
layout(path) click to toggle source
# File lib/ams_layout/cli/generate.rb, line 26
def layout(path)
  env = AmsLayout.configuration.default_environment
  env = options[:env] if options[:env]
  user, pass = credentials env

  client.login(user, pass)
  client.write_layout path, false
  client.logout
end

Private Instance Methods

client() click to toggle source
# File lib/ams_layout/cli/generate.rb, line 132
def client
  AmsLayout.client
end
credentials(env) click to toggle source
# File lib/ams_layout/cli/generate.rb, line 136
def credentials env
  user, pass = AmsLayout.configuration.credentials[env]
  if user.nil? || pass.nil?
    user = ask "username for #{env} environment:"
    pass = ask "password:"
  end
  [user, pass]
end