Class: AdminModule::Command::Config::Add

Inherits:
Thor
  • Object
show all
Defined in:
lib/admin_module/command/config.rb

Instance Method Summary collapse

Instance Method Details

#credentials(envname, username, pass) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/admin_module/command/config.rb', line 41

def credentials(envname, username, pass)
  with_loaded_config do
    if AdminModule.configuration.base_urls.key? envname.to_sym
      unless AdminModule.configuration.credentials.key? envname.to_sym
        AdminModule.configuration.credentials[envname.to_sym] = [username, pass]
      else
        say "credentials already exist for environment '#{envname}'", :red
      end
    else
      say "environment '#{envname}' doesn't exist", :red
      say "create environment before adding credentials"
    end
  end
end

#env(envname, url) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/admin_module/command/config.rb', line 16

def env(envname, url)
  with_loaded_config do
    unless AdminModule.configuration.base_urls.key? envname.to_sym
      AdminModule.configuration.base_urls[envname.to_sym] = url
    else
      say "environment '#{envname}' already exists", :red
    end
  end
end

#xmlmap(xmlfile, gdlname) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/admin_module/command/config.rb', line 27

def xmlmap(xmlfile, gdlname)
  with_loaded_config do
    xmlfile = File.basename(xmlfile, '.xml')

    unless AdminModule.configuration.xmlmaps.key? xmlfile
      AdminModule.configuration.xmlmaps[xmlfile] = gdlname
    else
      say "a mapping already exists for '#{xmlfile}'", :red
      say "delete and re-add the mapping to change it"
    end
  end
end