Class: AdminModule::Configuration
- Inherits:
-
Object
- Object
- AdminModule::Configuration
- Defined in:
- lib/admin_module.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#ams_version ⇒ Object
Returns the value of attribute ams_version.
-
#base_urls ⇒ Object
Returns the value of attribute base_urls.
-
#browser_timeout ⇒ Object
Browser timeout in seconds.
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#default_comment ⇒ Object
Returns the value of attribute default_comment.
-
#default_environment ⇒ Object
Returns the value of attribute default_environment.
-
#download_dir ⇒ Object
Browser download directory.
-
#page_urls ⇒ Object
Returns the value of attribute page_urls.
-
#xmlmaps ⇒ Object
Returns the value of attribute xmlmaps.
Instance Method Summary collapse
- #base_url ⇒ Object
-
#current_env ⇒ Object
Return the current environment.
-
#current_env=(env) ⇒ Object
Set the current environment.
-
#encode_with(coder) ⇒ Object
Control which instance vars are emitted when dumped to YAML.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #reset ⇒ Object
- #url(page_class) ⇒ Object
- #user_credentials ⇒ Object
- #xmlmap(xmlfile) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
136 137 138 |
# File 'lib/admin_module.rb', line 136 def initialize reset end |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
125 126 127 |
# File 'lib/admin_module.rb', line 125 def aliases @aliases end |
#ams_version ⇒ Object
Returns the value of attribute ams_version.
127 128 129 |
# File 'lib/admin_module.rb', line 127 def ams_version @ams_version end |
#base_urls ⇒ Object
Returns the value of attribute base_urls.
123 124 125 |
# File 'lib/admin_module.rb', line 123 def base_urls @base_urls end |
#browser_timeout ⇒ Object
Browser timeout in seconds. Default: 360 (6 mins).
130 131 132 |
# File 'lib/admin_module.rb', line 130 def browser_timeout @browser_timeout end |
#credentials ⇒ Object
Returns the value of attribute credentials.
122 123 124 |
# File 'lib/admin_module.rb', line 122 def credentials @credentials end |
#default_comment ⇒ Object
Returns the value of attribute default_comment.
121 122 123 |
# File 'lib/admin_module.rb', line 121 def default_comment @default_comment end |
#default_environment ⇒ Object
Returns the value of attribute default_environment.
120 121 122 |
# File 'lib/admin_module.rb', line 120 def default_environment @default_environment end |
#download_dir ⇒ Object
Browser download directory. Default: none
133 134 135 |
# File 'lib/admin_module.rb', line 133 def download_dir @download_dir end |
#page_urls ⇒ Object
Returns the value of attribute page_urls.
126 127 128 |
# File 'lib/admin_module.rb', line 126 def page_urls @page_urls end |
#xmlmaps ⇒ Object
Returns the value of attribute xmlmaps.
124 125 126 |
# File 'lib/admin_module.rb', line 124 def xmlmaps @xmlmaps end |
Instance Method Details
#base_url ⇒ Object
197 198 199 |
# File 'lib/admin_module.rb', line 197 def base_url @base_urls[current_env] end |
#current_env ⇒ Object
Return the current environment. Will return the default environment if current environment is not set.
192 193 194 195 |
# File 'lib/admin_module.rb', line 192 def current_env return @default_environment if @current_env.nil? @current_env end |
#current_env=(env) ⇒ Object
Set the current environment.
177 178 179 180 181 182 183 184 185 |
# File 'lib/admin_module.rb', line 177 def current_env=(env) env = env.to_sym fail "Cannot set current_env to un-configured environment: #{env}" unless @base_urls.key? env # This value is NOT included when dumping to YAML. # See Configurtion#encode_with @current_env = env.to_sym end |
#encode_with(coder) ⇒ Object
Control which instance vars are emitted when dumped to YAML.
226 227 228 229 230 231 232 233 234 |
# File 'lib/admin_module.rb', line 226 def encode_with(coder) vars = instance_variables.map { |x| x.to_s } vars = vars - ["@current_env"] vars.each do |var| var_val = eval(var) coder[var.gsub('@', '')] = var_val end end |
#reset ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/admin_module.rb', line 140 def reset @default_environment = :dev @current_env = nil @default_comment = 'no comment' @credentials = {} #@credentials = { dev: [ ENV['HSBC_DEV_USER'], ENV['HSBC_DEV_PASSWORD'] ], # dev2: [ ENV['HSBC_DEV2_USER'], ENV['HSBC_DEV2_PASSWORD'] ], # sit: [ ENV['HSBC_SIT_USER'], ENV['HSBC_SIT_PASSWORD'] ], # uat: [ ENV['HSBC_UAT_USER'], ENV['HSBC_UAT_PASSWORD'] ] } @base_urls = { dev: "http://207.38.119.211/fap2Dev/Admin", dev2: "http://207.38.119.211/fap2Dev2/Admin", sit: "http://207.38.119.211/fap2SIT/Admin", uat: "http://207.38.119.211/fap2UAT/Admin" } @xmlmaps = {} @aliases = {} @page_urls = { 'ParametersPage' => "/admin/decision/parameters.aspx", 'ParameterPage' => "/admin/decision/parameter.aspx", } @ams_version = "4.4.0" @browser_timeout = 360 @download_dir = "" end |
#url(page_class) ⇒ Object
201 202 203 204 205 |
# File 'lib/admin_module.rb', line 201 def url page_class suffix = @page_urls[page_class.to_s.split('::').last] raise "Unkown page [#{page_class.to_s}]" if suffix.nil? base_url + suffix end |
#user_credentials ⇒ Object
218 219 220 |
# File 'lib/admin_module.rb', line 218 def user_credentials @credentials[current_env] end |
#xmlmap(xmlfile) ⇒ Object
207 208 209 210 211 212 213 214 215 216 |
# File 'lib/admin_module.rb', line 207 def xmlmap xmlfile gdlname = xmlmaps[File.basename(xmlfile, '.xml')] if gdlname.nil? errmsg = "No guideline has been mapped for #{File.basename(xmlfile)}" trymsg = "Have you configured your gdl mappings?" trymsg2= " Try: admin_module config add xmlmap <xmlfile> <gdlname>" fail("#{errmsg}\n\n#{trymsg}\n#{trymsg2}") if gdlname.nil? end gdlname end |