Class | Config::ConfigFile |
In: |
lib/svengali/config.rb
|
Parent: | Object |
ssh_session => Net::SFTP::Session ConfigFile class doesn‘t manage passed sftp_session value
# File lib/svengali/config.rb, line 22 def initialize(remote_path_str,sftp_session) @sftp_session = sftp_session @remote_filepath_str = remote_path_str if is_exist(remote_path_str) # config_file = @sftp_session.open!(remote_path_str) @config_file_contents = get_contents_remote(@remote_filepath_str) else @config_file_contents = "" end end
remove columns which matched passed regular expression
# File lib/svengali/config.rb, line 68 def remove_col_by_regexp(regexp) not_inp() end
remove all columns which contains passed string
# File lib/svengali/config.rb, line 53 def remove_col_by_str(str) orig_contents_io = StringIO.new(@config_file_contents) removed_contents_io = StringIO.new() orig_contents_io.each_line { |line| unless line.index(str) removed_contents_io.puts(line) end } orig_contents_io.close() removed_contents_io.close() @config_file_contents = removed_contents_io.string end
replace columns which has specified content
# File lib/svengali/config.rb, line 36 def replace_col(original_col_str,replaced_col_str) orig_contents_io = StringIO.new(@config_file_contents) replaced_contents_io = StringIO.new() orig_contents_io.each_line { |line| replaced_contents_io.puts(line.gsub(original_col_str,replaced_col_str)) } orig_contents_io.close() replaced_contents_io.close() @config_file_contents = replaced_contents_io.string end