autoreporter 0.0.20160509

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/autoreporter +23 -0
  3. data/lib/autoreporter.rb +46 -0
  4. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 05790eb3150b0ff34fda4ade95d2cc258410e3f6
4
+ data.tar.gz: aa7e56a50c9381d4b27775e9f6e74e8b6866407e
5
+ SHA512:
6
+ metadata.gz: 13d395d57ca45e068ebc4705ba8f88b630ac830057a95a0e3716ab456284f7cf16af928d6539adce5fd5a5a148e23d0e23023f2638daba5f7ed172bc9b263a68
7
+ data.tar.gz: 40bd26d003028ef08f7859cca3b8a1c40f545d479e3b3380fdec201e4d2e16bec4b9986a83052f0cef6cb17c98ecda11cf20feabdabc87ab14cf5312fbacb685
data/bin/autoreporter ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "trollop"
4
+ require_relative "../lib/autoreporter"
5
+
6
+ opts = Trollop::options do
7
+ opt :delay, "delay between autorefleshes", type: :integer, default: 60
8
+ opt :cmd, "Command to run", type: :string, multi: true
9
+ opt :verbose, "verbose mode", default: false
10
+ end
11
+
12
+ opts[:cmd] << ARGV.shelljoin unless ARGV.empty?
13
+
14
+ if opts[:cmd].empty?
15
+ STDERR.puts "You must specify at least one command to run"
16
+ exit 1
17
+ end
18
+
19
+ ar = Autoreporter.new
20
+ ar.commands = opts[:cmd]
21
+ ar.delay = opts[:delay]
22
+ ar.verbose = opts[:verbose]
23
+ ar.run!
@@ -0,0 +1,46 @@
1
+ require "open3"
2
+ require "shellwords"
3
+
4
+ class Autoreporter
5
+ attr_accessor :delay, :commands, :verbose
6
+
7
+ def initialize
8
+ @output = nil
9
+ @delay = 60
10
+ @verbose = false
11
+ @commands = []
12
+ end
13
+
14
+ def run_command(cmd)
15
+ output, status = Open3.capture2e(cmd)
16
+ output += "\n" if output != "" and output[-1] != "\n"
17
+ output = "Running: #{cmd}\n" + output if verbose
18
+ output
19
+ end
20
+
21
+ def run_commands!
22
+ @output = @commands.map{|cmd| run_command(cmd)}
23
+ end
24
+
25
+ def clear_terminal!
26
+ # system("clear") doesn't clear scrollback buffer on iTerm2, we need to do this:
27
+ puts "\e[H\e[J\e[3J"
28
+ end
29
+
30
+ def display_result!
31
+ clear_terminal!
32
+ puts @output
33
+ end
34
+
35
+ def wait_for_condition!
36
+ sleep @delay
37
+ end
38
+
39
+ def run!
40
+ while true
41
+ run_commands!
42
+ display_result!
43
+ wait_for_condition!
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autoreporter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.20160509
5
+ platform: ruby
6
+ authors:
7
+ - Tomasz Wegrzanowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: Tomasz.Wegrzanowski@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - bin/autoreporter
20
+ - lib/autoreporter.rb
21
+ homepage: https://github.com/taw/autoreporter
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.5
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Command line report runner
45
+ test_files: []
46
+ has_rdoc: