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
47 48 49 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 47 def self.config new.config end |
Instance Method Details
#config ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 74 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
70 71 72 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 70 def defaults DefaultDBConfig.config.clone end |
#wp_config ⇒ Object
51 52 53 54 55 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 51 def wp_config @wp_config ||= File.read( WordpressDirectory.default_path_for(:wp_config) ).encode('utf-8', invalid: :replace) end |
#wp_definition_regex(definition) ⇒ Object
66 67 68 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 66 def wp_definition_regex(definition) /['"]#{definition}['"],\s*["'](?<value>.*)['"]/ end |
#wp_definitions ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/wordmove/generators/movefile_adapter.rb', line 57 def wp_definitions { name: 'DB_NAME', user: 'DB_USER', password: 'DB_PASSWORD', host: 'DB_HOST' } end |