teuton-client 0.0.1 → 0.0.3

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
  SHA256:
3
- metadata.gz: 21750819d071e673a4ce182aba3968375be1718b00aa0987042ee24016f27b05
4
- data.tar.gz: ee58b2cb7a24abe1d1222760ff49a0dd1fc4d2a9fb7b4f029c2de450359fc479
3
+ metadata.gz: a203d38e3c901593af699ca06643e6ca7e538b86806bdcff4c37038c1c4028c9
4
+ data.tar.gz: 4e2e689e75d667cb93fa196f9bb26aa23d0cd1f731f175224653e297463c833f
5
5
  SHA512:
6
- metadata.gz: d37e0b3665d2f19792ee71ba98b915885ef40cf2eff2e0710d0528491c94f1b9b6d7eda8008e4134b9ecf2e4325da175d706d087364ca5e709a75198d036dfd0
7
- data.tar.gz: 4b941922118c6d5141f2d0a6009a6653e5ebcf64015245db086cd0f540874859bffb726ebdcd5aae3635070c227c441a1c5759eba26aac22243f68d1845677b3
6
+ metadata.gz: 865955fe009912dc5d54a5032565400f13294af53b34e5f2109fb6d54969318219be9abe3f2d7450eca90a70ec1fc6dc6f557784ce01e6df0ca7c915e18893a9
7
+ data.tar.gz: e58c0d2613a10879703c0f943b5b28cebc5ff3e2c5ec7eb05c82b5309e03c0e201c35b8771a9f988f9eef9f5981bb71872aa8974b6693d971234a366c6f0ddf7
@@ -1,5 +1,7 @@
1
+ ##
2
+ # This module contains global application CONSTANTS.
1
3
  module Application
2
4
  NAME = 'teuton-client'
3
- VERSION = '0.0.1'
5
+ VERSION = '0.0.3'
4
6
  CONFIGFILE = 'teuton-client.yaml'
5
7
  end
@@ -1,8 +1,19 @@
1
1
  require 'yaml'
2
2
  require_relative 'application'
3
3
 
4
+ ##
5
+ # Methods that read config params
4
6
  module InputLoader
5
- def self.read_input_args(input)
7
+ ##
8
+ # Read input arguments and return config params.
9
+ # Arguments:
10
+ # * YAML file => Read file.yaml as config file
11
+ # * Empty
12
+ # * Exist default config file => Read config file
13
+ # * Dosn't exist config file => Set defaults IP, PORT values
14
+ # @param input [Array] Input ARGVS
15
+ # @return [String, Integer] Server IP and Server PORT
16
+ def self.read_configuration(input)
6
17
  if input.size.zero? && File.exists?(Application::CONFIGFILE)
7
18
  param = read_yaml(Application::CONFIGFILE)
8
19
  return param[:server][:ip], param[:server][:port]
@@ -12,6 +23,10 @@ module InputLoader
12
23
  return ip, port
13
24
  end
14
25
 
26
+ ##
27
+ # Read YAML configuration file.
28
+ # @param filepath [String] Path to YAML config file.
29
+ # @return [Hash] YAML file content.
15
30
  def self.read_yaml(filepath)
16
31
  unless File.exists? filepath
17
32
  puts "teuton-client => " +
data/lib/teuton-client.rb CHANGED
@@ -4,58 +4,79 @@ require 'socket'
4
4
  require_relative 'teuton-client/input_loader'
5
5
  require_relative 'teuton-client/application'
6
6
 
7
+ ##
8
+ # This module main methods to run Teuton Client
7
9
  module TeutonClient
8
-
9
- def self.run(args)
10
- hostname, port = InputLoader.read_input_args(args)
11
- connect_to_server(hostname, port)
12
- exit 0
13
- end
14
-
15
- def self.connect_to_server(hostname='localhost', port='6174')
16
- puts Rainbow("teuton-client => Waiting... " +
17
- "#{hostname}:#{port} (teuton-server)").bright
18
- begin
19
- s = TCPSocket.open(hostname, port)
20
- rescue
21
- puts Rainbow("teuton-client => " +
22
- "ERROR teuton-server not found!" +
23
- " [#{hostname}:#{port}]").bright.red
24
- exit 1
10
+ class << self
11
+ ##
12
+ # Run Teuton Client
13
+ # @param args [Array] Input arguments
14
+ # @return [Exit status]
15
+ def run(args)
16
+ hostname, port = InputLoader.read_configuration(args)
17
+ connect_to_server(hostname, port)
18
+ exit 0
25
19
  end
26
- while line = s.gets # Read lines from the socket
27
- puts " => #{line.chop}"
20
+
21
+ ##
22
+ # Show TeutonClient help.
23
+ # @return [Exit status]
24
+ def show_help
25
+ puts "Usage:"
26
+ puts " teuton-client [help|version] [IP PORT]"
27
+ puts "Params:"
28
+ puts " help , Show this help"
29
+ puts " init , Create \'#{Application::CONFIGFILE}\' config file"
30
+ puts " IP PORT , Teuton server IP and/or PORT"
31
+ puts " version , Show current version"
32
+ exit 0
28
33
  end
29
- s.close # Close the socket when done
30
- end
31
34
 
32
- def self.show_help
33
- puts "Usage:"
34
- puts " teuton-client [help|version] [IP [PORT]]"
35
- puts "Params:"
36
- puts " help , Show this help"
37
- puts " init , Create \'#{Application::CONFIGFILE}\' config file"
38
- puts " IP PORT , Teuton server IP and/or PORT"
39
- puts " version , Show current version"
40
- exit 0
41
- end
35
+ ##
36
+ # Show TeutonClient version
37
+ # @return [Exit status]
38
+ def show_version
39
+ puts "teuton-client => " +
40
+ Rainbow("version #{Application::VERSION}").cyan
41
+ exit 0
42
+ end
42
43
 
43
- def self.show_version
44
- puts "teuton-client => " +
45
- Rainbow("version #{Application::VERSION}").cyan
46
- exit 0
47
- end
44
+ ##
45
+ # Create default configuration file 'teuton-client.yaml'.
46
+ # @return [Exit status]
47
+ def init
48
+ src = File.join(File.dirname(__FILE__), 'teuton-client', 'files',
49
+ Application::CONFIGFILE)
50
+ dest = File.join(Application::CONFIGFILE)
51
+ if File.exists? dest
52
+ puts "teuton-client => " + Rainbow("File \'#{dest}\' exists!").red
53
+ exit 1
54
+ end
55
+ FileUtils.cp(src, dest)
56
+ puts "teuton-client => " + Rainbow("Init \'#{dest}\' done!").yellow
57
+ exit 0
58
+ end
48
59
 
49
- def self.init
50
- src = File.join(File.dirname(__FILE__), 'teuton-client', 'files',
51
- Application::CONFIGFILE)
52
- dest = File.join(Application::CONFIGFILE)
53
- if File.exists? dest
54
- puts "teuton-client => " + Rainbow("File \'#{dest}\' exists!").red
55
- exit 1
60
+ private
61
+ ##
62
+ # Connect client to server and display server response.
63
+ # @param hostname [String] Server hostname or IP
64
+ # @param port [Integer] Server listening port
65
+ def connect_to_server(hostname='localhost', port=16000)
66
+ puts Rainbow("teuton-client => Waiting... " +
67
+ "#{hostname}:#{port} (teuton-server)").bright
68
+ begin
69
+ s = TCPSocket.open(hostname, port)
70
+ rescue
71
+ puts Rainbow("teuton-client => " +
72
+ "ERROR teuton-server not found!" +
73
+ " [#{hostname}:#{port}]").bright.red
74
+ exit 1
75
+ end
76
+ while line = s.gets # Read lines from the socket
77
+ puts " => #{line.chop}"
78
+ end
79
+ s.close # Close the socket when done
56
80
  end
57
- FileUtils.cp(src, dest)
58
- puts "teuton-client => " + Rainbow("Init \'#{dest}\' done!").yellow
59
- exit 0
60
81
  end
61
82
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teuton-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
@@ -38,7 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.11'
41
- description: TeutonClient send evaluation requests to TeutonServer
41
+ description: |2
42
+ TeutonClient send evaluation requests to TeutonServer.
43
+
44
+ Teuton Software is an infrastructure test application,
45
+ that is installed into host called T-NODE. T-NODE user monitorize
46
+ remote S-NODE users machines using Teuton.
47
+
48
+ When a S-NODE user wants to be tested, must wait until T-NODE user
49
+ launch manually Teuton test units. Or start TeutonServer and attend
50
+ request automatically.
51
+
52
+ Teuton client is used for S-NODE users, to send request to TeutonServer
53
+ (T-NODE host). This way, S-NODE host is evaluated by the server at any time
54
+ without T-NODE user intervention.
42
55
  email: teuton.software@protonmail.com
43
56
  executables:
44
57
  - teuton-client
@@ -48,7 +61,6 @@ files:
48
61
  - bin/teuton-client
49
62
  - lib/teuton-client.rb
50
63
  - lib/teuton-client/application.rb
51
- - lib/teuton-client/files/teuton-client.yaml
52
64
  - lib/teuton-client/input_loader.rb
53
65
  homepage: https://github.com/dvarrui/teuton-client
54
66
  licenses:
@@ -1,4 +0,0 @@
1
- ---
2
- :server:
3
- :ip: 127.0.0.1
4
- :port: 16001