Class Config::ConfigFile
In: lib/svengali/config.rb
Parent: Object

Methods

Included Modules

FileIO

Public Class methods

ssh_session => Net::SFTP::Session ConfigFile class doesn‘t manage passed sftp_session value

[Source]

# 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

Public Instance methods

[Source]

# File lib/svengali/config.rb, line 48
    def append_str(str)
      @config_file_contents += str
    end

remove columns which matched passed regular expression

[Source]

# File lib/svengali/config.rb, line 68
    def remove_col_by_regexp(regexp)
      not_inp()
    end

remove all columns which contains passed string

[Source]

# 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

[Source]

# 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

save modified content

[Source]

# File lib/svengali/config.rb, line 73
    def save
      write_contents_remote(@remote_filepath_str,@config_file_contents)
    end

[Validate]