Sha256: 579d8a5ed8e565177f2cc0f089adaaf9359119aaa102eade68b85a4afd3a00f8
Contents?: true
Size: 934 Bytes
Versions: 3
Compression:
Stored size: 934 Bytes
Contents
require 'time' require 'pathname' module Ec2ssh class SshConfig HEADER = "### EC2SSH BEGIN ###" FOOTER = "### EC2SSH END ###" attr_reader :path def initialize(path=nil) @path = Pathname(path || "#{ENV['HOME']}/.ssh/config") end def append_mark! replace! "" open(@path, "a") do |f| f.puts wrap("") end end def mark_exist? config_src =~ /#{HEADER}\n.*#{FOOTER}\n/m end def replace!(str) save! config_src.gsub(/#{HEADER}\n.*#{FOOTER}\n/m, str) end def config_src @config_src ||= open(@path, "r") do |f| f.read end end def save!(str) open(@path, "w") do |f| f.puts str end end def wrap(text) return <<-END #{HEADER} # Generated by ec2ssh http://github.com/mirakui/ec2ssh # DO NOT edit this block! # Updated #{Time.now.iso8601} #{text} #{FOOTER} END end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ec2ssh-2.0.3 | lib/ec2ssh/ssh_config.rb |
ec2ssh-2.0.2 | lib/ec2ssh/ssh_config.rb |
ec2ssh-2.0.1 | lib/ec2ssh/ssh_config.rb |