xrefresh-server 0.1.7 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.2.1
@@ -19,6 +19,7 @@ module XRefreshServer
19
19
  VERSION = File.read(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'VERSION'))
20
20
  AGENT = "OSX xrefresh-server"
21
21
  CONFIG_FILE = ".xrefresh-server.yml"
22
+ XREFRESH_MESSAGE_SEPARATOR = "---XREFRESH-MESSAGE---"
22
23
 
23
24
  def self.die(s)
24
25
  $stderr.puts s
@@ -21,7 +21,7 @@ module XRefreshServer
21
21
  def send(data)
22
22
  return if @dead
23
23
  begin
24
- @socket << data.to_json
24
+ @socket << data.to_json + XREFRESH_MESSAGE_SEPARATOR
25
25
  rescue
26
26
  OUT.puts "Client #{name} #{red("is dead")}"
27
27
  @dead = true
@@ -37,6 +37,15 @@ module XRefreshServer
37
37
  end
38
38
 
39
39
  def send_do_refresh(root, name, type, date, time, files)
40
+ # read all CSS files and add them into response
41
+ contents = {}
42
+ files.each do |item|
43
+ next unless item["path1"] =~ /\.css$/
44
+ path = File.join(root, item["path1"])
45
+ content = File.open(path).read
46
+ contents[item["path1"]] = content
47
+ end
48
+
40
49
  send({
41
50
  "command" => "DoRefresh",
42
51
  "root" => root,
@@ -44,7 +53,8 @@ module XRefreshServer
44
53
  "date" => date,
45
54
  "time" => time,
46
55
  "type" => type,
47
- "files" => files
56
+ "files" => files,
57
+ "contents" => contents
48
58
  })
49
59
  end
50
60
  end
@@ -19,25 +19,17 @@ module XRefreshServer
19
19
  @last_client_id += 1
20
20
  client = Client.new(@last_client_id, socket)
21
21
  @clients.add(client)
22
- buffer = ""
23
22
  loop do
24
- # accumulate incomming input in @buffer
25
23
  begin
26
- buffer += socket.gets
24
+ buffer = socket.gets(XREFRESH_MESSAGE_SEPARATOR)
27
25
  rescue
26
+ # socket breaks on client disconnection
28
27
  break
29
28
  end
30
-
31
- begin
32
- # try to parse buffer
33
- msg = JSON.parse buffer
34
- rescue
35
- # buffer may be incomplete due to packet fragmentation ...
36
- else
37
- # got whole message => process it
38
- buffer = ""
39
- process(client, msg)
40
- end
29
+ break unless buffer
30
+ message = buffer[0...-XREFRESH_MESSAGE_SEPARATOR.size]
31
+ json = JSON.parse(message)
32
+ process(client, json)
41
33
  end
42
34
  end
43
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xrefresh-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonin Hildebrand
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-26 00:00:00 +02:00
12
+ date: 2009-06-20 00:00:00 +02:00
13
13
  default_executable: xrefresh-server
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  requirements: []
74
74
 
75
75
  rubyforge_project: xrefresh-server
76
- rubygems_version: 1.3.3
76
+ rubygems_version: 1.3.4
77
77
  signing_key:
78
78
  specification_version: 3
79
79
  summary: XRefresh filesystem monitor for OSX