Class: AmsLayout::Config

Inherits:
Thor
  • Object
show all
Defined in:
lib/ams_layout/cli/config.rb

Defined Under Namespace

Classes: Add, Del, Show

Instance Method Summary collapse

Instance Method Details

#defenv(envname = nil) ⇒ Object



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/ams_layout/cli/config.rb', line 217

def defenv(envname=nil)
  if envname.nil?
    with_loaded_config do
      say "default environment: #{AmsLayout.configuration.default_environment}"
    end
    return
  end

  with_loaded_config(true) do
    if AmsLayout.configuration.base_urls.key? envname.to_sym
      AmsLayout.configuration.default_environment = envname.to_sym
    else
      say "argument error: environment '#{envname}' has not been configured"
    end
  end
end

#init(filedir = nil) ⇒ Object



173
174
175
176
177
178
179
180
181
182
# File 'lib/ams_layout/cli/config.rb', line 173

def init(filedir = nil)
  if filedir.nil?
    filedir = Pathname.pwd + AmsLayout::CONFIG_FILE_NAME
  else
    filedir = Pathname(filedir) + AmsLayout::CONFIG_FILE_NAME unless filedir.to_s.end_with?("/#{AmsLayout::CONFIG_FILE_NAME}")
  end

  outpath = AmsLayout.save_configuration filedir
  say("configuration written to #{outpath.to_s}", :green) unless options[:quiet]
end

#timeout(seconds = nil) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/ams_layout/cli/config.rb', line 194

def timeout(seconds=nil)
  if seconds.nil?
    with_loaded_config do
      say "browser timeout: #{AmsLayout.configuration.browser_timeout}"
    end
  else
    with_loaded_config(true) do
      AmsLayout.configuration.browser_timeout = Integer(seconds)
    end
  end
rescue ArgumentError => e
  say 'argument error: seconds must be an integer'
end