icwot 0.1 → 0.1.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -2
  3. data/bin/icwot +4 -4
  4. data/lib/icwot/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44ef186ed365a911a195d9f8ab987530fad72827
4
- data.tar.gz: e04f2e3b74c1f06825c296674a90269f4c9c2ef0
3
+ metadata.gz: de385402f1226360527fe24047fdcdfa43e07a73
4
+ data.tar.gz: adc408b40362093aa3e0f84dca6cf197d220b25f
5
5
  SHA512:
6
- metadata.gz: 181b4a37d46af2eaddfa2a3c01c1587cbec499da05fd7ce4891b386fb950993546206f35c6cf366201b006cb44633fa16d652b854ec59790b8bdacd8923cf79b
7
- data.tar.gz: 5c333aac859fe46fa61478411f5673abec035828e3a6565b6f09f61a786e2510aa73cf6dd1154e2d5d776734d3983109e31d0652e581534c32b2df94c739a716
6
+ metadata.gz: baaa83c802c66bae4cfd6f7c8634fe33f90612fa1b2d867d29aad973f9edc17b512562450b9d61b48dbec75d748fd910ed21f5ddc763924167db6823617a37ee
7
+ data.tar.gz: d464c39e9cab1905e59f923be7f5874a2960b264e014899530ffa34d67b4e22a57338cadb1ddb5a8eac8a626be3fc8441e31891d1cf675375df20f32db5a8b59
data/README.md CHANGED
@@ -20,9 +20,40 @@ Or install it yourself as:
20
20
 
21
21
  In a terminal run:
22
22
 
23
- $ icwot
23
+ $ icwot <HOST>
24
24
 
25
- It will start a [sinatra](http://www.sinatrarb.com) server on port 4567. Logging messages will be saved to : your-home-directory/log/icwot-msg.log
25
+ It will:
26
+
27
+ 1. Register to the specified host by ` POST ` method and sending in the body information(s).
28
+ Currently, the body information is the uri needed for the host to send informations to the client.
29
+ 2. Start a [sinatra](http://www.sinatrarb.com) server on default port 4567. Logging messages will be saved by default to :
30
+ your-home-directory/log/icwot-msg.log
31
+
32
+ By default, the header of the ` POST ` method will have these values:
33
+
34
+ content-type=application/json
35
+ accept=application/json
36
+
37
+ You can change it by specifying the ` -c your-content-type ` and ` -a your-accept ` in the command line call. Actaually, it can encode the body in two different maners:
38
+
39
+ * json, the body will typically be like this : ` {"uri": "your-ip-address:port-where-sinatra-is running"} `
40
+ * xml, the body will typically be like this:
41
+ ` <client xmlns=\"http://jaxb.xwot.first.ch.unifr.diuf\">
42
+ <uri>your-ip-address:port-where-sinatra-is running</uri>
43
+ </client> `
44
+ The xml is not as the best for the moment. We recommand to use json.
45
+
46
+ ### There are several options for the commande line:
47
+
48
+ icwot <host>
49
+ -h print help
50
+ -l the host is localhost
51
+ -c the content-type value for the header application/json by default
52
+ -a the accept value for the header text/plain by default
53
+ -p the port where to run the server
54
+ -t the protocol to use http:// by default
55
+ -l where to save the log. By default your-home-directory/log/icwot-{port}-msg.log
56
+ host is where to register for the service.
26
57
 
27
58
  ## Contributing
28
59
 
data/bin/icwot CHANGED
@@ -40,9 +40,10 @@ class Client
40
40
  {uri: uri}
41
41
  end
42
42
 
43
+ # inspired by http://stackoverflow.com/questions/11897269/get-own-ip-address
43
44
  def get_ip
44
45
  ip=Socket.ip_address_list.detect{|intf| intf.ipv4_private?}
45
- ip.ip_address if ip
46
+ ip ? ip.ip_address : '127.0.0.1'
46
47
  end
47
48
 
48
49
  def to_s
@@ -75,7 +76,7 @@ ARGV.each_with_index do |a, index|
75
76
  -a the accept value for the header text/plain by default
76
77
  -p the port where to run the server
77
78
  -t the protocol to use http:// by default
78
- -l where to save the log by default your-home-directory/log/icwot-{port}-msg.log
79
+ -l where to save the log. By default your-home-directory/log/icwot-{port}-msg.log
79
80
  host is where to register for the service.
80
81
  '
81
82
  exit 0
@@ -114,10 +115,9 @@ if is_port_open?('localhost', port)
114
115
  end
115
116
 
116
117
  client = Client.new
117
- client.uri = "http://#{client.get_ip.to_s}:#{port}/"
118
+ client.uri = "http://#{client.get_ip}:#{port}/"
118
119
  client.content_type = produces
119
120
 
120
-
121
121
  response = RestClient.post protocol+host, client.to_s, accept: accept, content_type: produces
122
122
 
123
123
  unless response.code == 200
data/lib/icwot/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Icwot
2
- VERSION = "0.1"
2
+ VERSION = '0.1.1'
3
3
  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.1'
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - leo