icwot 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87d7b6e4a3a0b5d5f5310815f6d62dcbb8a7dc68
4
- data.tar.gz: 5e45269940885f14aa76296bad21d25bb1834ddb
3
+ metadata.gz: d23bec7c4b1456f3d7ff8498f33c0ee9dda51db2
4
+ data.tar.gz: 58e231a3bc652d93b47c27a9914e507758f88140
5
5
  SHA512:
6
- metadata.gz: 8dcc6a75b177ba34fc434cce1a795b9b323fca4131ae72d65ff2fc13138cc081ab6265d67d85e69750cc30e84b488583f6077be99fbcecf422c2ce173dd407aa
7
- data.tar.gz: d564062c6af2afd3f34256e7320b0cdc407cb5821dc886be51c19b84cf191a0ef66c5f562111ce9e7a25334103424787ed26fb99ffe4546484b909f3ca5b48cb
6
+ metadata.gz: 053c2b0d3dacb57e190d23a856ac2eca9368a6c7505ef3e4e98f52cd2e3ecf2cc24f14615ae8a8474be5346c2ae8d8a14837c164ff3d5a06caf4d267c8254797
7
+ data.tar.gz: d3cadbfa43dc070434bf20b18a6f2ccb201c13199b637cd415104b421d04e60cdd437fdf86e3286b508e42ca6c9726c1496b061fbba6e2d8aaaa1a5abd02328c
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/icwot CHANGED
@@ -1,14 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # A simple tool to run server on the client side
4
-
5
- require 'socket'
6
- require 'timeout'
7
- require 'rest-client'
8
- require 'json'
9
4
  require 'icwot'
10
5
  require 'icwot/client'
11
6
  require 'icwot/console'
7
+ require 'rest-client'
12
8
 
13
9
  console = Console.new
14
10
 
@@ -24,8 +20,17 @@ end
24
20
 
25
21
  client = Client.new(port: console.port, content_type: console.produces)
26
22
 
27
- RestClient.post console.url, client.to_s, console.header
23
+ begin
24
+ response = RestClient.post console.url, client.to_s, console.header
25
+ rescue RestClient::Exception => e
26
+ puts "Error #{e.response.code} while contacting the host. The url is: '#{console.url}'"
27
+ exit 0
28
+ rescue Errno::ECONNREFUSED => e
29
+ puts "Connection refused. The url is: '#{console.url}'"
30
+ exit 0
31
+ end
28
32
 
29
- #TODO handle exception from RestClient
33
+ #TODO handle the case when the response of the host is not correct
34
+ puts "The response server: '#{response}' with code #{response.code}"
30
35
 
31
36
  Icwot.run(console.port, console.log_path)
@@ -1,5 +1,7 @@
1
1
  require "icwot/version"
2
2
  require 'icwot/server_client'
3
+ require 'socket'
4
+ require 'timeout'
3
5
 
4
6
  module Icwot
5
7
  def self.run(port, log_path)
@@ -1,3 +1,6 @@
1
+ require 'socket'
2
+ require 'json'
3
+
1
4
  class Client
2
5
  attr_accessor :uri, :content_type, :port
3
6
 
@@ -27,7 +27,7 @@ class Console
27
27
  -a the accept value for the header text/plain by default
28
28
  -p the port where to run the server
29
29
  -t the protocol to use http:// by default
30
- -l where to save the log. By default your-home-directory/log/icwot-{port}-msg.log
30
+ -o where to save the log. By default your-home-directory/log/icwot-{port}-msg.log
31
31
  host is where to register for the service.
32
32
  '
33
33
  exit 0
@@ -43,7 +43,7 @@ class Console
43
43
  unless (temp = ARGV.delete_at(index + 1)).nil?
44
44
  @protocol = temp
45
45
  end
46
- when '-l'
46
+ when '-o'
47
47
  @log_path = ARGV.delete_at index + 1
48
48
  else
49
49
  @host += a
@@ -1,5 +1,5 @@
1
1
  module Icwot
2
2
  def self.version
3
- '0.2.0'
3
+ '0.2.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icwot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - leo
@@ -107,6 +107,7 @@ files:
107
107
  - Gemfile
108
108
  - LICENSE.txt
109
109
  - README.md
110
+ - Rakefile
110
111
  - bin/icwot
111
112
  - icwot.gemspec
112
113
  - lib/icwot.rb