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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1fa025a53a5a243c1a09e6ccc7a16f52d0e1eca
4
- data.tar.gz: 1de351f532709ae3bcbbbfd66839bea21ddf38b8
3
+ metadata.gz: 1a5c5935f0dca1c526da10e27a446e8315656887
4
+ data.tar.gz: a1653c91906366b1a82d2fd266ee8624ef6b83c8
5
5
  SHA512:
6
- metadata.gz: f78b94683dac6ab31e4e42af9525f447c0568bd74f67bdb2bb47b3271b6d96d23087d9e0b3ffa67b94a0adae0b007074a9b38bad82f6f0e2a60fa96cff2badb5
7
- data.tar.gz: 0fd1a8e0734e32d4fe756ab28979615bd75d6e57974cdc43cf0cdd1e4fe6a31f73417bab0a7afa506b2701195b80f3ac8b330a095f17756ce735d6ff5e050703
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.7.0'
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
- @last_output = []
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.7.0
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: 2016-10-24 00:00:00.000000000 Z
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.5.1
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