pbind 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pbind/command/serv.rb +18 -16
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d28ab25efd022a0182268eb102046401ddb3800
4
- data.tar.gz: 112719797adf95c13e034efd3bd70eab5f511983
3
+ metadata.gz: 188a8efa18d88d36de925fe34667cd6274a872b0
4
+ data.tar.gz: c389977bfa6c78eb268743e545d5bf816d5f799b
5
5
  SHA512:
6
- metadata.gz: 0d6ea7d843182955111dbab91c1fc64427ee05c49a10109669a4d81543e80dd69b2537f9d372e4a9a902cefe5431a8b5aec9811687d187b47f0d65ead3ee567a
7
- data.tar.gz: fd041cc082b10871b081adf1d09d96fe6d1195d9690c4c6c53e54f372a05699b72b2d3a05afc2034a1750d1bd36958405546a4d47fb5fa4d9e7a2e141305cf4f
6
+ metadata.gz: 288d8e612006eb685cd64803fbe732899480d983b5742e4df4bad4c32d4b654c53b3c225e2d266e24e6bb433bf3a284c89a68bf431303829de125673cdfc664c
7
+ data.tar.gz: e9a1c3c49dd2f403bbc8363c1928ca75ba857c09a0837e3edf0736d80430d11ec05ac9c0122b1efe42944b2f66a64053fe628cfc646d31f133c45c106e0f9115
@@ -62,34 +62,36 @@ module Pbind
62
62
 
63
63
  addr = server.addr
64
64
  addr.shift
65
- puts "server is on #{addr.join(':')}"
65
+ puts "#{'Pbind server is on'.bold} #{local_ip.underline}"
66
66
 
67
67
  loop do
68
68
  Thread.start(server.accept) do |client|
69
69
  @clients.push client
70
70
  loop do
71
- line = client.readpartial(1024)
72
- if line != nil and line.end_with?('.json')
73
- send_json(@clients, line)
71
+ req = client.readpartial(1024)
72
+ if req != nil
73
+ handle_request(client, req)
74
74
  end
75
75
  end
76
76
  client.close
77
77
  end
78
78
  end
79
+ end
79
80
 
80
- # loop do
81
- # client = server.accept # Wait for a client to connect
82
- # @client = client
83
-
84
- # line = client.readpartial(1024)
85
- # puts "get #{line}"
86
- # if line != nil and line.end_with?('.json')
87
- # puts "send #{line}"
88
- # send_json(client, line)
89
- # end
81
+ def handle_request(client, req)
82
+ if req.start_with?('[C]')
83
+ puts "client #{req[3..-1].green} connected"
84
+ elsif req.end_with?('.json')
85
+ send_json([client], req)
86
+ end
87
+ end
90
88
 
91
- # client.close
92
- # end
89
+ def local_ip
90
+ addr_infos = Socket.ip_address_list
91
+ local_addr_info = addr_infos.select { |info|
92
+ info.ipv4? and info.ip_address != '127.0.0.1'
93
+ }
94
+ local_addr_info[0].ip_address
93
95
  end
94
96
 
95
97
  def listen_file_changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Galen Lin
@@ -113,8 +113,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.6.8
116
+ rubygems_version: 2.6.6
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Pbind xcodeproj helper
120
120
  test_files: []
121
+ has_rdoc: