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.
-
#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.
-
#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.
131 132 133 |
# File 'lib/admin_module.rb', line 131 def initialize reset end |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
124 125 126 |
# File 'lib/admin_module.rb', line 124 def aliases @aliases end |
#base_urls ⇒ Object
Returns the value of attribute base_urls.
122 123 124 |
# File 'lib/admin_module.rb', line 122 def base_urls @base_urls end |
#browser_timeout ⇒ Object
Browser timeout in seconds. Default: 360 (6 mins).
128 129 130 |
# File 'lib/admin_module.rb', line 128 def browser_timeout @browser_timeout end |
#credentials ⇒ Object
Returns the value of attribute credentials.
121 122 123 |
# File 'lib/admin_module.rb', line 121 def credentials @credentials end |
#default_comment ⇒ Object
Returns the value of attribute default_comment.
120 121 122 |
# File 'lib/admin_module.rb', line 120 def default_comment @default_comment end |
#default_environment ⇒ Object
Returns the value of attribute default_environment.
119 120 121 |
# File 'lib/admin_module.rb', line 119 def default_environment @default_environment end |
#page_urls ⇒ Object
Returns the value of attribute page_urls.
125 126 127 |
# File 'lib/admin_module.rb', line 125 def page_urls @page_urls end |
#xmlmaps ⇒ Object
Returns the value of attribute xmlmaps.
123 124 125 |
# File 'lib/admin_module.rb', line 123 def xmlmaps @xmlmaps end |
Instance Method Details
#base_url ⇒ Object
188 189 190 |
# File 'lib/admin_module.rb', line 188 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.
183 184 185 186 |
# File 'lib/admin_module.rb', line 183 def current_env return @default_environment if @current_env.nil? @current_env end |
#current_env=(env) ⇒ Object
Set the current environment.
168 169 170 171 172 173 174 175 176 |
# File 'lib/admin_module.rb', line 168 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.
217 218 219 220 221 222 223 224 225 |
# File 'lib/admin_module.rb', line 217 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
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/admin_module.rb', line 135 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", } @browser_timeout = 360 end |
#url(page_class) ⇒ Object
192 193 194 195 196 |
# File 'lib/admin_module.rb', line 192 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
209 210 211 |
# File 'lib/admin_module.rb', line 209 def user_credentials @credentials[current_env] end |
#xmlmap(xmlfile) ⇒ Object
198 199 200 201 202 203 204 205 206 207 |
# File 'lib/admin_module.rb', line 198 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 |