Class: Configuration
- Inherits:
-
Object
- Object
- Configuration
- Defined in:
- lib/apollo_commons_ruby/TemplatesHelper.rb
Instance Attribute Summary collapse
-
#apollo_config_base_url ⇒ Object
readonly
Returns the value of attribute apollo_config_base_url.
-
#base_folder_path ⇒ Object
readonly
Returns the value of attribute base_folder_path.
-
#env_data_file_path ⇒ Object
readonly
Returns the value of attribute env_data_file_path.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#get_template_group_details_url ⇒ Object
readonly
Returns the value of attribute get_template_group_details_url.
-
#get_templates_for_view_url ⇒ Object
readonly
Returns the value of attribute get_templates_for_view_url.
-
#post_insert_template_group_url ⇒ Object
readonly
Returns the value of attribute post_insert_template_group_url.
-
#post_insert_templates_url ⇒ Object
readonly
Returns the value of attribute post_insert_templates_url.
-
#post_update_template_group_url ⇒ Object
readonly
Returns the value of attribute post_update_template_group_url.
-
#post_update_templates_url ⇒ Object
readonly
Returns the value of attribute post_update_templates_url.
-
#post_upsert_template_mappings_url ⇒ Object
readonly
Returns the value of attribute post_upsert_template_mappings_url.
-
#resources_file_path ⇒ Object
readonly
Returns the value of attribute resources_file_path.
-
#templated_data_file_path ⇒ Object
readonly
Returns the value of attribute templated_data_file_path.
Instance Method Summary collapse
- #client_transfomer_file_path_for_template(template_group) ⇒ Object
- #data_template_file_path_for_template(template_group, lang, view_type, template_name) ⇒ Object
- #default_content_file_path_for_template(template_group, lang, view_type, template_name) ⇒ Object
- #env_file_path(tenant_id, project_id) ⇒ Object
- #get_stringified_value(str) ⇒ Object
-
#initialize(environment, base_path) ⇒ Configuration
constructor
A new instance of Configuration.
- #language_dir_path_for_template(template_group, language) ⇒ Object
- #language_file_path_for_template(language) ⇒ Object
- #presentation_file_path_for_template(template_group, lang, view_type, template_name) ⇒ Object
- #sample_data_file_path_for_template(template_group) ⇒ Object
- #setup(environment, tenantId, projectId) ⇒ Object
- #template_group_details_file_path_for_template(template_group) ⇒ Object
- #template_group_dir_path_for_template(template_group) ⇒ Object
- #template_name_dir_path_for_template(template_group, language, view_type, template_name) ⇒ Object
- #transfomer_file_path_for_template(template_group) ⇒ Object
- #view_type_dir_path_for_template(template_group, language, view_type) ⇒ Object
- #view_type_dir_path_for_template_with_version(template_group, language, view_type, version) ⇒ Object
Constructor Details
#initialize(environment, base_path) ⇒ Configuration
Returns a new instance of Configuration.
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 332 def initialize(environment, base_path) if file_exists?("./.apollo/#{environment}.json") conf_file = File.read(File.("./.apollo/#{environment}.json")) conf = JSON.parse conf_file if (conf["apolloConfigBaseUrl"] == nil) puts "Required configurations are missing" raise "Required configurations are missing" return nil end @environment = environment @base_folder_path = "./Templates" @templated_data_file_path = "./scripts/commonData/generatedTemplatedData.json" @env_data_file_path = "./environments/#{environment}.json" @apollo_config_base_url = conf["apolloConfigBaseUrl"] @resources_file_path = "./Resources" else puts base_path if base_path == nil conf_file = File.read(File.("/var/jenkins_home/template_config/config.json")); else conf_file = File.read(File.(base_path)); end conf = JSON.parse conf_file if (base_path == nil) conf = conf[environment.downcase] end if (conf["apolloConfigBaseUrl"] == nil) puts "Required configurations are missing" raise "Required configurations are missing" return nil end @environment = environment @base_folder_path = "./Templates" @templated_data_file_path = "./scripts/commonData/generatedTemplatedData.json" @env_data_file_path = conf["env_data_file_path"] @apollo_config_base_url = conf["apolloConfigBaseUrl"] @resources_file_path = "./Resources" @post_insert_templates_url = conf["omsBaseUrl"] + conf["postInsertTemplatesUrl"] @post_update_templates_url = conf["omsBaseUrl"] + conf["postUpdateTemplatesUrl"] @get_templates_for_view_url = conf["omsBaseUrl"] + conf["getTemplatesForViewUrl"] @post_upsert_template_mappings_url = conf["omsBaseUrl"] + conf["postUpsertTemplateMappingsUrl"] @get_template_group_details_url = conf["omsBaseUrl"] + conf["getTemplateGroupDetailsUrl"] @post_update_template_group_url = conf["omsBaseUrl"] + conf["postUpdateTemplateGroupUrl"] @post_insert_template_group_url = conf["omsBaseUrl"] + conf["postInsertTemplateGroupUrl"] end end |
Instance Attribute Details
#apollo_config_base_url ⇒ Object (readonly)
Returns the value of attribute apollo_config_base_url.
287 288 289 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 287 def apollo_config_base_url @apollo_config_base_url end |
#base_folder_path ⇒ Object (readonly)
Returns the value of attribute base_folder_path.
283 284 285 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 283 def base_folder_path @base_folder_path end |
#env_data_file_path ⇒ Object (readonly)
Returns the value of attribute env_data_file_path.
285 286 287 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 285 def env_data_file_path @env_data_file_path end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
282 283 284 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 282 def environment @environment end |
#get_template_group_details_url ⇒ Object (readonly)
Returns the value of attribute get_template_group_details_url.
292 293 294 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 292 def get_template_group_details_url @get_template_group_details_url end |
#get_templates_for_view_url ⇒ Object (readonly)
Returns the value of attribute get_templates_for_view_url.
290 291 292 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 290 def get_templates_for_view_url @get_templates_for_view_url end |
#post_insert_template_group_url ⇒ Object (readonly)
Returns the value of attribute post_insert_template_group_url.
294 295 296 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 294 def post_insert_template_group_url @post_insert_template_group_url end |
#post_insert_templates_url ⇒ Object (readonly)
Returns the value of attribute post_insert_templates_url.
288 289 290 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 288 def post_insert_templates_url @post_insert_templates_url end |
#post_update_template_group_url ⇒ Object (readonly)
Returns the value of attribute post_update_template_group_url.
293 294 295 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 293 def post_update_template_group_url @post_update_template_group_url end |
#post_update_templates_url ⇒ Object (readonly)
Returns the value of attribute post_update_templates_url.
289 290 291 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 289 def post_update_templates_url @post_update_templates_url end |
#post_upsert_template_mappings_url ⇒ Object (readonly)
Returns the value of attribute post_upsert_template_mappings_url.
291 292 293 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 291 def post_upsert_template_mappings_url @post_upsert_template_mappings_url end |
#resources_file_path ⇒ Object (readonly)
Returns the value of attribute resources_file_path.
286 287 288 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 286 def resources_file_path @resources_file_path end |
#templated_data_file_path ⇒ Object (readonly)
Returns the value of attribute templated_data_file_path.
284 285 286 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 284 def templated_data_file_path @templated_data_file_path end |
Instance Method Details
#client_transfomer_file_path_for_template(template_group) ⇒ Object
429 430 431 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 429 def client_transfomer_file_path_for_template(template_group) "#{@base_folder_path}/#{template_group}/clientTransformer.js" end |
#data_template_file_path_for_template(template_group, lang, view_type, template_name) ⇒ Object
393 394 395 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 393 def data_template_file_path_for_template(template_group, lang, view_type, template_name) "#{@base_folder_path}/#{template_group}/#{lang}/#{view_type}/#{template_name}/dataTemplate.json" end |
#default_content_file_path_for_template(template_group, lang, view_type, template_name) ⇒ Object
401 402 403 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 401 def default_content_file_path_for_template(template_group, lang, view_type, template_name) "#{@base_folder_path}/#{template_group}/#{lang}/#{view_type}/#{template_name}/defaultContent.json" end |
#env_file_path(tenant_id, project_id) ⇒ Object
445 446 447 448 449 450 451 452 453 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 445 def env_file_path(tenant_id, project_id) if file_exists?("./environments/#{@environment}.json") "./environments/#{@environment}.json" elsif file_exists?("./environments/#{@environment}/env_#{tenant_id}_#{project_id}.json") "./environments/#{@environment}/env_#{tenant_id}_#{project_id}.json" else "#{@env_data_file_path}" end end |
#get_stringified_value(str) ⇒ Object
387 388 389 390 391 392 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 387 def get_stringified_value(str) if str == nil return "" end return str end |
#language_dir_path_for_template(template_group, language) ⇒ Object
417 418 419 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 417 def language_dir_path_for_template(template_group, language) "#{@base_folder_path}/#{template_group}/#{language}" end |
#language_file_path_for_template(language) ⇒ Object
441 442 443 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 441 def language_file_path_for_template(language) "#{@resources_file_path}/#{language}.json" end |
#presentation_file_path_for_template(template_group, lang, view_type, template_name) ⇒ Object
397 398 399 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 397 def presentation_file_path_for_template(template_group, lang, view_type, template_name) "#{@base_folder_path}/#{template_group}/#{lang}/#{view_type}/#{template_name}/presentation.json" end |
#sample_data_file_path_for_template(template_group) ⇒ Object
425 426 427 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 425 def sample_data_file_path_for_template(template_group) "#{@base_folder_path}/#{template_group}/SampleData" end |
#setup(environment, tenantId, projectId) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 296 def setup(environment, tenantId, projectId) if file_exists?("./.apollo/#{environment}.json") environmentFile = File.read("./.apollo/#{environment}.json") envFile = "./environments/#{environment}.json" else if (environment == 'PreProd') environment = 'Preprod' end if (tenantId != nil && projectId != nil) envFile = "./environments/" + environment + "/env_" + tenantId + "_" + projectId + ".json" if(file_exists?(envFile)) environmentFile = File.read(envFile) end else envFile = "./environments/" + environment + "/env.json" if(file_exists?(envFile)) environmentFile = File.read(envFile) end end end conf = JSON.parse environmentFile if (conf["apolloConfigBaseUrl"] == nil) puts "Required configurations are missing" raise "Required configurations are missing" return nil end @base_folder_path = "./Templates" @templated_data_file_path = "./scripts/commonData/generatedTemplatedData.json" @environment = environment @resources_file_path = "./Resources" @env_data_file_path = envFile @apollo_config_base_url = conf["apolloConfigBaseUrl"] end |
#template_group_details_file_path_for_template(template_group) ⇒ Object
433 434 435 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 433 def template_group_details_file_path_for_template(template_group) "#{@base_folder_path}/#{template_group}/templateGroupDetails.json" end |
#template_group_dir_path_for_template(template_group) ⇒ Object
437 438 439 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 437 def template_group_dir_path_for_template(template_group) "#{@base_folder_path}/#{template_group}" end |
#template_name_dir_path_for_template(template_group, language, view_type, template_name) ⇒ Object
405 406 407 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 405 def template_name_dir_path_for_template(template_group, language, view_type, template_name) "#{@base_folder_path}/#{template_group}/#{language}/#{view_type}/#{template_name}" end |
#transfomer_file_path_for_template(template_group) ⇒ Object
421 422 423 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 421 def transfomer_file_path_for_template(template_group) "#{@base_folder_path}/#{template_group}/transformer.js" end |
#view_type_dir_path_for_template(template_group, language, view_type) ⇒ Object
409 410 411 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 409 def view_type_dir_path_for_template(template_group, language, view_type) "#{@base_folder_path}/#{template_group}/#{language}/#{view_type}" end |
#view_type_dir_path_for_template_with_version(template_group, language, view_type, version) ⇒ Object
413 414 415 |
# File 'lib/apollo_commons_ruby/TemplatesHelper.rb', line 413 def view_type_dir_path_for_template_with_version(template_group, language, view_type, version) "#{@base_folder_path}/#{template_group}/#{language}/#{view_type}/#{version}" end |