gratan 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8fbce6d1fcddfb3722b441b11bc6b500089c991
4
- data.tar.gz: 05692f2918f98a56bed99a21e8c671d35ea256dc
3
+ metadata.gz: 437c36176e46ac6592882686c864bd6e76dccd48
4
+ data.tar.gz: d7fb16d23fe5cc5974527f7ba7800032f23da02d
5
5
  SHA512:
6
- metadata.gz: 1032b20e24aa7b4b7013c59030c1ccab35b5cc85797c72d12638b3b6adf0d03af4255f1dc8b86715347d1151efd98212daa3cf95f248277b8b4774ccc29998ac
7
- data.tar.gz: 45e14af6d95c94753faf7c976e42176cb4ede9ff948d35383ad1edbedf8c6d718c28b085e5ef3f079846531a86218d5edeb6d4ebfeeb51bef37654027fcd0886
6
+ metadata.gz: 4782fa7623292e29ce8c0d191768f14c0ecc8ded99901ca9320c617311a8a38f1c23578f856afda39ebf4d09f78657b487fff6ff238b1c2957e1f74f28fedc35
7
+ data.tar.gz: 2465ae129f83796bc2c4ebfc08e8d6efecdb278c1a625549f081d0f0a11513820260d9cfef680517751cc210566a4ff768c79ea977da5dab1a92d9a74926a3b1
@@ -1,12 +1,13 @@
1
1
  class Gratan::Identifier::Auto
2
2
  def initialize(output, options = {})
3
+ @output = output
3
4
  @options = options
4
5
 
5
6
  unless @options[:dry_run]
6
7
  if output == '-'
7
8
  @output = $stdout
8
9
  else
9
- @output = open(output, 'w')
10
+ @output = output
10
11
  end
11
12
  end
12
13
 
@@ -32,9 +33,21 @@ class Gratan::Identifier::Auto
32
33
  end
33
34
 
34
35
  def puts_password(user, host, password)
35
- if @output
36
- @output.puts("#{user}@#{host},#{password}")
37
- @output.flush
36
+ open_output do |f|
37
+ f.puts("#{user}@#{host},#{password}")
38
+ end
39
+ end
40
+
41
+ def open_output
42
+ return if @options[:dry_run]
43
+
44
+ if @output == '-'
45
+ yield($stdout)
46
+ $stdout.flush
47
+ else
48
+ open(@output, 'a') do |f|
49
+ yield(f)
50
+ end
38
51
  end
39
52
  end
40
53
  end
@@ -1,3 +1,3 @@
1
1
  module Gratan
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gratan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara