cap-ssh-key-man 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cap-ssh-key-man}
8
- s.version = "1.2.1"
8
+ s.version = "1.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael He"]
@@ -1,12 +1,14 @@
1
1
  module CapSshKeyMan
2
2
  class PublicKeyCombiner
3
- def self.combine_developer_public_keys
4
- authorized_keys_path = File.join ".", "tmp", "authorized_keys"
5
- public_key_path = File.join(".", "config", "developer_public_keys")
3
+ AUTHORIZED_KEYS_PATH = File.join ".", "tmp", "authorized_keys"
4
+ PUBLIC_KEY_PATH = File.join(".", "config", "developer_public_keys")
5
+ OMNI_RSA_KEY_PATH = File.expand_path(File.join "~", ".ssh", "id_rsa.pub")
6
+ OMNI_DSA_KEY_PATH = File.expand_path(File.join "~", ".ssh", "id_dsa.pub")
6
7
 
7
- File.open authorized_keys_path, "w" do |f|
8
+ def self.combine_developer_public_keys
9
+ File.open AUTHORIZED_KEYS_PATH, "w" do |f|
8
10
  f.write File.read(get_current_user_public_key_path) if get_current_user_public_key_path
9
- files = Dir[File.join(public_key_path, '*')]
11
+ files = Dir[File.join(PUBLIC_KEY_PATH, '*')]
10
12
  raise "Can't find any public keys in #{public_key_path} dir." if files.size == 0
11
13
  files.each do |file|
12
14
  f.write File.read(file)
@@ -15,12 +17,9 @@ module CapSshKeyMan
15
17
  end
16
18
 
17
19
  def self.get_current_user_public_key_path
18
- omni_rsa_key_path = File.expand_path(File.join "~", ".ssh", "id_rsa.pub")
19
- omni_dsa_key_path = File.expand_path(File.join "~", ".ssh", "id_dsa.pub")
20
-
21
20
  current_user_key_path = nil
22
- current_user_key_path = omni_rsa_key_path if File.exist?(omni_rsa_key_path)
23
- current_user_key_path = omni_dsa_key_path if File.exist?(omni_dsa_key_path)
21
+ current_user_key_path = OMNI_RSA_KEY_PATH if File.exist?(OMNI_RSA_KEY_PATH)
22
+ current_user_key_path = OMNI_DSA_KEY_PATH if File.exist?(OMNI_DSA_KEY_PATH)
24
23
  current_user_key_path
25
24
  end
26
25
  end
@@ -3,15 +3,9 @@ Capistrano::Configuration.instance(true).load do
3
3
  namespace :sshkey do
4
4
  desc "Sync keys to servers"
5
5
  task :deploy do
6
- puts "Creating authorized_keys file ..."
7
6
  CapSshKeyMan::PublicKeyCombiner.combine_developer_public_keys
8
-
9
- puts "Deploying authorized_keys ..."
10
- tmp_authorized_keys_path = File.join(".", "tmp", "authorized_keys")
11
- put File.read(tmp_authorized_keys_path), File.join("/home/#{user}", ".ssh", "authorized_keys")
12
-
13
- # delete temp file after use it.
14
- FileUtils.rm tmp_authorized_keys_path
7
+ put File.read(CapSshKeyMan::PublicKeyCombiner::AUTHORIZED_KEYS_PATH), File.join("/home/#{user}", ".ssh", "authorized_keys")
8
+ FileUtils.rm CapSshKeyMan::PublicKeyCombiner::AUTHORIZED_KEYS_PATH # delete temp file after use it.
15
9
  end
16
10
  end
17
11
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cap-ssh-key-man
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael He