fulmar-shell 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fulmar/ringbuffer.rb +21 -0
- data/lib/fulmar/shell.rb +13 -7
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a5c5935f0dca1c526da10e27a446e8315656887
|
4
|
+
data.tar.gz: a1653c91906366b1a82d2fd266ee8624ef6b83c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c54888221419f5daa698e1be76bf333e2e367fdf3969962eaed6d7ded08a10c892eab63794917e24b86035c05d1b4902cf0091602f274dc1997410f5a35f44e
|
7
|
+
data.tar.gz: fb6d73959b1848cf386ce4ba6bdb820d4d0000a4664783e2921df907f4938ff39cecf0338608383a16d10b6d9db3d1c5b18e0857967d5160ee5e5688845a0e69
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fulmar
|
2
|
+
class RingBuffer < Array
|
3
|
+
attr_reader :max_size
|
4
|
+
|
5
|
+
def initialize(max_size, enum = nil)
|
6
|
+
@max_size = max_size
|
7
|
+
enum.each { |e| self << e } if enum
|
8
|
+
end
|
9
|
+
|
10
|
+
def <<(el)
|
11
|
+
if self.size < @max_size || @max_size.nil?
|
12
|
+
super
|
13
|
+
else
|
14
|
+
self.shift
|
15
|
+
self.push(el)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
alias :push :<<
|
20
|
+
end
|
21
|
+
end
|
data/lib/fulmar/shell.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
require 'open3'
|
2
|
+
require 'fulmar/ringbuffer'
|
2
3
|
|
3
4
|
# This shell is part of the fulmar deployment tools
|
4
5
|
# it can be used stand-alone, though
|
5
6
|
module Fulmar
|
6
7
|
# Implements simple access to shell commands
|
7
8
|
class Shell
|
8
|
-
VERSION = '1.
|
9
|
+
VERSION = '1.8.0'
|
9
10
|
|
10
11
|
attr_accessor :debug, :last_output, :last_error, :quiet, :strict, :interactive
|
11
12
|
attr_reader :path
|
12
13
|
|
14
|
+
DEFAULT_BUFFER_SIZE = 1000
|
15
|
+
|
13
16
|
DEFAULT_OPTIONS = {
|
14
17
|
login: false,
|
15
18
|
escape_bundler: false
|
@@ -19,8 +22,7 @@ module Fulmar
|
|
19
22
|
@host = host.nil? ? 'no_hostname_set' : host
|
20
23
|
@path = (path.nil? || path.empty?) ? '.' : path
|
21
24
|
@path = File.expand_path(@path) if local?
|
22
|
-
|
23
|
-
@last_error = []
|
25
|
+
reset_output
|
24
26
|
@debug = false
|
25
27
|
@quiet = true
|
26
28
|
@strict = false
|
@@ -34,7 +36,7 @@ module Fulmar
|
|
34
36
|
end
|
35
37
|
|
36
38
|
def run(command, options = DEFAULT_OPTIONS)
|
37
|
-
reset_output
|
39
|
+
reset_output(@last_output.max_size)
|
38
40
|
command = [command] if command.class == String
|
39
41
|
|
40
42
|
# is a custom path given?
|
@@ -70,11 +72,15 @@ module Fulmar
|
|
70
72
|
@path = local? ? File.expand_path(path) : path
|
71
73
|
end
|
72
74
|
|
75
|
+
def buffer_size(size)
|
76
|
+
reset_output(size)
|
77
|
+
end
|
78
|
+
|
73
79
|
protected
|
74
80
|
|
75
|
-
def reset_output
|
76
|
-
@last_output =
|
77
|
-
@last_error =
|
81
|
+
def reset_output(size = DEFAULT_BUFFER_SIZE)
|
82
|
+
@last_output = Fulmar::RingBuffer.new(size)
|
83
|
+
@last_error = Fulmar::RingBuffer.new(size)
|
78
84
|
end
|
79
85
|
|
80
86
|
def shell_command(login)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fulmar-shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerrit Visscher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- LICENSE.txt
|
53
53
|
- README.md
|
54
54
|
- fulmar-shell.gemspec
|
55
|
+
- lib/fulmar/ringbuffer.rb
|
55
56
|
- lib/fulmar/shell.rb
|
56
57
|
homepage: https://github.com/CORE4/fulmar-shell
|
57
58
|
licenses:
|
@@ -73,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
74
|
version: '0'
|
74
75
|
requirements: []
|
75
76
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
77
|
+
rubygems_version: 2.6.8
|
77
78
|
signing_key:
|
78
79
|
specification_version: 4
|
79
80
|
summary: Small service to run shell commands on a local or remote shell
|