log-listener 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
data/lib/log-listener.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require "log-listener/version"
|
2
|
-
require "classes/start"
|
2
|
+
require "log-listener/classes/start"
|
3
3
|
require 'pry'
|
4
4
|
require 'net/ssh'
|
5
|
+
require 'log-listener/modules/action_module'
|
5
6
|
#require File.expand_path('log-listener/version', __FILE__)
|
6
7
|
#require File.expand_path('classes/start', __FILE__)
|
7
8
|
|
@@ -18,13 +18,11 @@ module LogListener
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def execute_this_command(actions)
|
21
|
-
|
22
21
|
Net::SSH.start("#{@host}", "#{@user}", :password => "#{password}") do |ssh|
|
23
22
|
go_to_path = ssh.exec!("cd #{PATH}")
|
24
23
|
do_this = ssh.exec!("#{actions}")
|
25
24
|
@result << do_this
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module LogListener
|
2
|
+
module ActionModule
|
3
|
+
FILE_NAME = "spec_default_log"
|
4
|
+
|
5
|
+
def self.delete_existing_files(name)
|
6
|
+
File.delete("#{name}") if File.exists?("#{name}")
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.save_to_archive(path=FILE_NAME,write_this)
|
10
|
+
delete_existing_files("#{path}.log")
|
11
|
+
log_file = File.new("#{path}.log", "w+")
|
12
|
+
log_file.write "****Start of Line********\n#{write_this.to_s}\n*********End of Line********"
|
13
|
+
log_file.close
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/log-listener/version.rb
CHANGED
@@ -15,10 +15,20 @@ describe LogListener do
|
|
15
15
|
|
16
16
|
it "Should be able to connect after a set up", :despegar_dev => true do
|
17
17
|
connection_test = LogListener::Start.new(LOGRC,USERLOGTEST,PASSWLOGTEST)
|
18
|
-
connection_test.execute_this_command("grep '
|
18
|
+
connection_test.execute_this_command("grep 'ZEQUE' #{PATH}/logPackagesSM/log")
|
19
19
|
connection_test.result.size < 1
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
it "Should be able to save results on an existing log file", :dev => true do
|
23
|
+
connection_test = LogListener::Start.new(LOGRC,USERLOGTEST,PASSWLOGTEST)
|
24
|
+
connection_test.execute_this_command("grep 'ZEQUE' #{PATH}/logPackages*/log")
|
25
|
+
LogListener::ActionModule.save_to_archive(connection_test.result[0])
|
26
|
+
end
|
27
|
+
|
28
|
+
it "Should be able to save results creating a new log file", :dev => true do
|
29
|
+
connection_test = LogListener::Start.new(LOGRC,USERLOGTEST,PASSWLOGTEST)
|
30
|
+
connection_test.execute_this_command("grep 'ERROR' #{PATH}/logPackages*/log")
|
31
|
+
LogListener::ActionModule.save_to_archive("new",connection_test.result[0])
|
32
|
+
end
|
23
33
|
|
24
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log-listener
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -37,8 +37,9 @@ files:
|
|
37
37
|
- Gemfile
|
38
38
|
- spec/unit_test_log_listener_spec.rb
|
39
39
|
- lib/log-listener.rb
|
40
|
-
- lib/
|
40
|
+
- lib/log-listener/modules/action_module.rb
|
41
41
|
- lib/log-listener/version.rb
|
42
|
+
- lib/log-listener/classes/start.rb
|
42
43
|
homepage: ''
|
43
44
|
licenses: []
|
44
45
|
post_install_message:
|