Class: Wordmove::Generators::WordpressDBConfig
- Inherits:
-
Object
- Object
- Wordmove::Generators::WordpressDBConfig
- Defined in:
- lib/wordmove/generators/movefile_adapter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #defaults ⇒ Object
- #wp_config ⇒ Object
- #wp_definition_regex(definition) ⇒ Object
- #wp_definitions ⇒ Object
Class Method Details
.config ⇒ Object
50 51 52 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 50 def self.config new.config end |
Instance Method Details
#config ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 75 def config wp_definitions.each_with_object(defaults) do |(key, definition), result| wp_config.match(wp_definition_regex(definition)) do |match| result[key] = match[:value] end end end |
#defaults ⇒ Object
71 72 73 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 71 def defaults DefaultDBConfig.config.clone end |
#wp_config ⇒ Object
54 55 56 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 54 def wp_config @wp_config ||= File.open(WordpressDirectory.default_path_for(:wp_config)).read end |
#wp_definition_regex(definition) ⇒ Object
67 68 69 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 67 def wp_definition_regex(definition) /['"]#{definition}['"],\s*["'](?<value>.*)['"]/ end |
#wp_definitions ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 58 def wp_definitions { name: 'DB_NAME', user: 'DB_USER', password: 'DB_PASSWORD', host: 'DB_HOST' } end |