Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Genki Sugawara committed Oct 8, 2014
1 parent 8220c0f commit 80aba38
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lib/gratan/identifier/auto.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
class Gratan::Identifier::Auto
def initialize(output, options = {})
@output = output
@options = options

unless @options[:dry_run]
if output == '-'
@output = $stdout
else
@output = open(output, 'w')
@output = output
end
end

Expand All @@ -32,9 +33,21 @@ def mkpasswd(len = 8)
end

def puts_password(user, host, password)
if @output
@output.puts("#{user}@#{host},#{password}")
@output.flush
open_output do |f|
f.puts("#{user}@#{host},#{password}")
end
end

def open_output
return if @options[:dry_run]

if @output == '-'
yield($stdout)
$stdout.flush
else
open(@output, 'a') do |f|
yield(f)
end
end
end
end

0 comments on commit 80aba38

Please sign in to comment.