Class: DbEntropy::Base
- Inherits:
-
Object
- Object
- DbEntropy::Base
- Defined in:
- lib/db-entropy/base.rb
Instance Attribute Summary collapse
-
#extra_environments ⇒ Object
Returns the value of attribute extra_environments.
Instance Method Summary collapse
- #generate_random_name(length = 10) ⇒ Object
- #generate_yaml(path) ⇒ Object
-
#initialize(extra_envs = ENV['EXTRA_ENVS']) ⇒ Base
constructor
A new instance of Base.
- #write_to_yaml(db_config, path) ⇒ Object
Constructor Details
#initialize(extra_envs = ENV['EXTRA_ENVS']) ⇒ Base
Returns a new instance of Base.
5 6 7 8 |
# File 'lib/db-entropy/base.rb', line 5 def initialize(extra_envs=ENV['EXTRA_ENVS']) extra_envs ||= '' @extra_environments = extra_envs.split(',').uniq.compact end |
Instance Attribute Details
#extra_environments ⇒ Object
Returns the value of attribute extra_environments.
3 4 5 |
# File 'lib/db-entropy/base.rb', line 3 def extra_environments @extra_environments end |
Instance Method Details
#generate_random_name(length = 10) ⇒ Object
10 11 12 |
# File 'lib/db-entropy/base.rb', line 10 def generate_random_name(length=10) rand(32**length).to_s(32) end |
#generate_yaml(path) ⇒ Object
14 15 16 17 |
# File 'lib/db-entropy/base.rb', line 14 def generate_yaml(path) config = generate_database_config write_to_yaml(config,path) end |
#write_to_yaml(db_config, path) ⇒ Object
19 20 21 |
# File 'lib/db-entropy/base.rb', line 19 def write_to_yaml(db_config,path) File.open(path, 'w+') { |out| YAML.dump(db_config, out) } end |