herd-rb 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: b4537287c3bae74a806660bd69cd226b067ef22a114ed396910bde8a0f1cf413
4
- data.tar.gz: 9c325eb90d09d6df3a44bc8b39ff1e80926c41da2113ff1baa04eb581903f84a
3
+ metadata.gz: 84702715cdf7b1c28fe203c5c88a0b0f7a3c0a77bf5bfb237c027a82585be7c0
4
+ data.tar.gz: d61aa1dcbe955f6ab0bd56c535612cf490891ed2589425af1ac23baf6e085636
5
5
  SHA512:
6
- metadata.gz: 802a7fbe1903f6eba0cf21d19b913fc6cb47d20b632abd7c7700197596feca4855b44d15758f9977c873cac0f224ee8a9631505971a03b6f1f6d4576e80e0e94
7
- data.tar.gz: eb7d5c9badbd8992d0f17ba3832cdf7953924eebd99f57229eb0c0d8ecb6ec0efe75b63b3ab5c4b59c1913dfd558de622ea6c435ebcf076e3f7f79b59aa330d0
6
+ metadata.gz: c2f6c111802762b7c5e642a1a8f073d9bad60c138f5d607870a4989154777aa2691997ca514ef440237d73b4112107a72dffe17b1c3221aab0d7663440be70bf
7
+ data.tar.gz: b65a40974cee1729989bfc9c65a95b937e101c71072daa2da4cf70475cd04ce8de65ab4483e1dfbf4301bcc27a4bcbe149a9c07119619190bde82f052c1eee1e
data/lib/herd/session.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Herd
4
4
  # Session for executing commands on the remote host
5
5
  class Session
6
- COMMANDS = %i[hostname].freeze
6
+ COMMANDS = %i[cat chmod echo hostname touch].freeze
7
7
 
8
8
  attr_reader :ssh
9
9
 
@@ -11,9 +11,19 @@ module Herd
11
11
  @ssh = ssh
12
12
  end
13
13
 
14
+ def authorized_keys
15
+ cat("~/.ssh/authorized_keys")&.chomp&.split("\n") || []
16
+ end
17
+
18
+ def add_authorized_key(key)
19
+ touch("~/.ssh/authorized_keys")
20
+ chmod("600 ~/.ssh/authorized_keys")
21
+ echo "'#{key}' >> ~/.ssh/authorized_keys"
22
+ end
23
+
14
24
  def method_missing(cmd, *args)
15
25
  command = cmd.to_s
16
- command += args.join(" ") if args
26
+ command = "#{command} #{args.join(" ")}" if args
17
27
 
18
28
  ssh.exec! command do |_, stream, data|
19
29
  raise ::Herd::CommandError, data if stream == :stderr
data/lib/herd/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Herd
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: herd-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Kotlyarov
@@ -65,7 +65,8 @@ dependencies:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
- description: Simple ruby DSL for fast host configuration. Supports Ubuntu and requires
68
+ description: |
69
+ Simple ruby DSL for fast host configuration. Supports Ubuntu and requires
69
70
  SSH server running on each targets host.
70
71
  email:
71
72
  - yury.kotlyarov@gmail.com