-
-
Save anonymous/b7b18d54f6b39a755317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
require 'csv' | |
FileUtils.cd('/data/bluekiwi/bkweb/application/config/') | |
configs = {} | |
Dir.glob('configuration_*').each do |filename| | |
configs[filename]= Hash.new | |
File.foreach(filename) do |line| | |
if line.include? 'uid' | |
next unless line.match(/(?=uid).*?[\'\"].*?[\'\"](.*?)[\'\"]/) | |
field, value = line.split("=",2); | |
configs[filename][:uid]= value | |
end | |
if line.include? 'url' | |
next unless line.match(/(?=url).*?[\'\"].*?[\'\"](.*?)[\'\"]/) | |
field, value = line.split("=",2); | |
configs[filename][:url]= value | |
end | |
if line.include? 'dbname' | |
next unless line.match(/(?=dbname).*?[\'\"].*?[\'\"](.*?)[\'\"]/) | |
field, value = line.split("=",2); | |
configs[filename][:dbname]= value | |
end | |
CSV.open("/tmp/data.csv", "wb", Options = {col_sep: "\t", quote_char: "\0"}) {|csv| configs.to_a.each {|input| csv << input }} | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configuration_emakina.mydomain.net.php {:uid=>" 'grouperefl';", :url=>" 'https://emakina.mydomaine.net';", :dbname=>"'grouperefl';"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment