Class: EnvironmentBuilder
- Inherits:
-
Object
- Object
- EnvironmentBuilder
- Defined in:
- lib/cadbury/helpers/environment_builder.rb
Instance Attribute Summary collapse
-
#configs ⇒ Object
Returns the value of attribute configs.
Instance Method Summary collapse
- #create_environment(name, silent: false) ⇒ Object
- #delete_environment(name) ⇒ Object
- #get_environment(name:) ⇒ Object
-
#initialize ⇒ EnvironmentBuilder
constructor
A new instance of EnvironmentBuilder.
- #list_environments ⇒ Object
Constructor Details
#initialize ⇒ EnvironmentBuilder
Returns a new instance of EnvironmentBuilder.
10 11 12 13 14 |
# File 'lib/cadbury/helpers/environment_builder.rb', line 10 def initialize @config_manager = ConfigManager.new @configs = {} @env = "dev" end |
Instance Attribute Details
#configs ⇒ Object
Returns the value of attribute configs.
8 9 10 |
# File 'lib/cadbury/helpers/environment_builder.rb', line 8 def configs @configs end |
Instance Method Details
#create_environment(name, silent: false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cadbury/helpers/environment_builder.rb', line 16 def create_environment(name, silent: false) unless silent puts "Hi, I am ApiBot!" print "You can have multiple environments of API requests and easily switch between them. " puts "To create an environment please follow the steps,\n" puts "Note: I have created some default values for easily getting started." puts "Press enter for using default value." end @configs = @config_manager.get_all if File.exist?(Global::ENV_FILE_PATH) set_environment name get_base_url get_auth_token_header_key get_auth_token_header_value save_config_as_json end |
#delete_environment(name) ⇒ Object
41 42 43 44 45 |
# File 'lib/cadbury/helpers/environment_builder.rb', line 41 def delete_environment(name) environments = @config_manager.get_all environments.delete(name) @config_manager.save environments end |
#get_environment(name:) ⇒ Object
37 38 39 |
# File 'lib/cadbury/helpers/environment_builder.rb', line 37 def get_environment(name:) @config_manager.get_by_env(env: name) end |
#list_environments ⇒ Object
33 34 35 |
# File 'lib/cadbury/helpers/environment_builder.rb', line 33 def list_environments @config_manager.get_all end |