xrefresh-server 0.1.0 → 0.1.6
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.
- data/VERSION +1 -0
- data/bin/xrefresh-server +9 -22
- data/lib/xrefresh-server.rb +24 -7
- data/lib/xrefresh-server/client.rb +52 -0
- data/lib/{monitor.rb → xrefresh-server/monitor.rb} +16 -16
- data/lib/{server.rb → xrefresh-server/server.rb} +16 -15
- data/{License.txt → license.txt} +3 -3
- data/readme.md +5 -0
- metadata +42 -52
- data/History.txt +0 -4
- data/Manifest.txt +0 -26
- data/PostInstall.txt +0 -6
- data/README.txt +0 -48
- data/Rakefile +0 -4
- data/config/hoe.rb +0 -73
- data/config/requirements.rb +0 -15
- data/lib/client.rb +0 -34
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -82
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/website/index.html +0 -141
- data/website/index.txt +0 -83
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.html.erb +0 -48
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.6
|
data/bin/xrefresh-server
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# This script watches modifications on the given directories, using the new # FSEvents API in Leopard.
|
4
4
|
# Depends on rubycocoa!
|
@@ -7,38 +7,27 @@
|
|
7
7
|
# Based on code by Dave Dribin
|
8
8
|
# http://www.dribin.org/dave/blog/archives/2008/01/04/fswatch/
|
9
9
|
|
10
|
+
require "rubygems"
|
10
11
|
require 'set'
|
11
12
|
require 'optparse'
|
12
13
|
require 'ostruct'
|
13
14
|
require "yaml"
|
14
|
-
|
15
|
-
require 'xrefresh-server'
|
16
|
-
rescue LoadError
|
17
|
-
require '../lib/xrefresh-server.rb'
|
18
|
-
end
|
19
|
-
begin
|
20
|
-
require 'json'
|
21
|
-
rescue LoadError
|
22
|
-
die 'You must "sudo gem install json" to get xrefresh monitor running'
|
23
|
-
end
|
15
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'xrefresh-server.rb') # this form is important for local development
|
24
16
|
|
25
17
|
module XRefreshServer
|
26
18
|
|
27
19
|
################################################################################
|
28
20
|
# command-line parsing
|
29
21
|
|
30
|
-
|
31
|
-
|
32
|
-
$VERSION = XRefreshServer::VERSION
|
33
|
-
$AGENT = "OSX xrefresh-server"
|
34
|
-
CONFIG_FILE = ".xrefresh-server.yml"
|
22
|
+
COMMAND = File.basename($0)
|
23
|
+
USAGE = "Usage: #{COMMAND} [OPTIONS]"
|
35
24
|
|
36
25
|
options = OpenStruct.new
|
37
26
|
options.output = "-"
|
38
27
|
options.config = nil
|
39
28
|
|
40
29
|
opts = OptionParser.new do |o|
|
41
|
-
o.banner =
|
30
|
+
o.banner = USAGE
|
42
31
|
o.separator ""
|
43
32
|
o.separator "Specific options:"
|
44
33
|
|
@@ -62,7 +51,7 @@ module XRefreshServer
|
|
62
51
|
end
|
63
52
|
|
64
53
|
o.on_tail("-v", "--version", "Show version") do
|
65
|
-
puts
|
54
|
+
puts XRefreshServer::VERSION
|
66
55
|
exit
|
67
56
|
end
|
68
57
|
end
|
@@ -75,9 +64,9 @@ module XRefreshServer
|
|
75
64
|
|
76
65
|
# initialize output handle
|
77
66
|
if options.output == "-"
|
78
|
-
|
67
|
+
OUT = $stdout.clone
|
79
68
|
else
|
80
|
-
|
69
|
+
OUT = File.open(options.output, "w")
|
81
70
|
end
|
82
71
|
|
83
72
|
################################################################################
|
@@ -125,7 +114,6 @@ module XRefreshServer
|
|
125
114
|
|
126
115
|
################################################################################
|
127
116
|
# run server
|
128
|
-
$out.puts "Starting server on #{CONFIG["host"]}:#{CONFIG["port"]} (max #{CONFIG["max_connections"]} clients)"
|
129
117
|
server = Server.new(CONFIG["port"], CONFIG["host"], CONFIG["max_connections"], $stderr, CONFIG["audit"], CONFIG["debug"])
|
130
118
|
server.start
|
131
119
|
|
@@ -140,5 +128,4 @@ module XRefreshServer
|
|
140
128
|
################################################################################
|
141
129
|
# leave in peace
|
142
130
|
$out.flush
|
143
|
-
exit(0)
|
144
131
|
end
|
data/lib/xrefresh-server.rb
CHANGED
@@ -1,8 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'json'
|
2
|
+
begin
|
3
|
+
require 'term/ansicolor'
|
4
|
+
include Term::ANSIColor
|
5
|
+
rescue LoadError
|
6
|
+
raise 'Run "sudo gem install term-ansicolor"'
|
7
|
+
end
|
8
|
+
# http://kpumuk.info/ruby-on-rails/colorizing-console-ruby-script-output/
|
9
|
+
if PLATFORM =~ /win32/ then
|
10
|
+
begin
|
11
|
+
require 'win32console'
|
12
|
+
include Win32::Console::ANSI
|
13
|
+
rescue LoadError
|
14
|
+
raise 'Run "sudo gem install win32console" to use terminal colors on Windows'
|
15
|
+
end
|
16
|
+
end
|
3
17
|
|
4
18
|
module XRefreshServer
|
5
|
-
VERSION =
|
19
|
+
VERSION = File.read(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'VERSION'))
|
20
|
+
AGENT = "OSX xrefresh-server"
|
21
|
+
CONFIG_FILE = ".xrefresh-server.yml"
|
6
22
|
|
7
23
|
def self.die(s)
|
8
24
|
$stderr.puts s
|
@@ -27,7 +43,7 @@ paths:
|
|
27
43
|
dir_include:
|
28
44
|
dir_exclude: ^#{File.expand_path('~')}/Library|/\\.(svn|framework|app|pbproj|pbxproj|xcode(proj)?|bundle)/
|
29
45
|
file_include:
|
30
|
-
file_exclude: ^(CVS|SCCS|vssver.?.scc|\\.(cvsignore|svn|DS_Store)|_svn|Thumbs\\.db)$|~$|^(\\.(?!htaccess)[^/]*|\\.(tmproj|o|pyc)|svn-commit(\\.[2-9])?\\.tmp)$ # merged TextMate and Netbeans patterns
|
46
|
+
file_exclude: ^(CVS|SCCS|vssver.?.scc|\\.(cvsignore|git|svn|DS_Store)|_svn|Thumbs\\.db)$|~$|^(\\.(?!htaccess)[^/]*|\\.(tmproj|o|pyc)|svn-commit(\\.[2-9])?\\.tmp)$ # merged TextMate and Netbeans patterns
|
31
47
|
|
32
48
|
# xpert settings
|
33
49
|
host: #{GServer::DEFAULT_HOST}
|
@@ -43,6 +59,7 @@ CONFIG
|
|
43
59
|
|
44
60
|
end
|
45
61
|
|
46
|
-
|
47
|
-
require 'server.rb'
|
48
|
-
require '
|
62
|
+
LIB_DIR = File.expand_path(File.dirname(__FILE__))
|
63
|
+
require File.join(LIB_DIR, 'xrefresh-server/client.rb')
|
64
|
+
require File.join(LIB_DIR, 'xrefresh-server/server.rb')
|
65
|
+
require File.join(LIB_DIR, 'xrefresh-server/monitor.rb')
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module XRefreshServer
|
4
|
+
|
5
|
+
# client representation on server side
|
6
|
+
class Client
|
7
|
+
attr_accessor :id, :dead, :type, :agent
|
8
|
+
|
9
|
+
def initialize(id, socket)
|
10
|
+
@id = id
|
11
|
+
@socket = socket
|
12
|
+
@dead = false
|
13
|
+
@type = '?'
|
14
|
+
@agent = '?'
|
15
|
+
end
|
16
|
+
|
17
|
+
def name
|
18
|
+
green("#{@type}(#{@id})")
|
19
|
+
end
|
20
|
+
|
21
|
+
def send(data)
|
22
|
+
return if @dead
|
23
|
+
begin
|
24
|
+
@socket << data.to_json
|
25
|
+
rescue
|
26
|
+
OUT.puts "Client #{name} #{red("is dead")}"
|
27
|
+
@dead = true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def send_about(version, agent)
|
32
|
+
send({
|
33
|
+
"command" => "AboutMe",
|
34
|
+
"version" => version,
|
35
|
+
"agent" => agent
|
36
|
+
})
|
37
|
+
end
|
38
|
+
|
39
|
+
def send_do_refresh(root, name, type, date, time, files)
|
40
|
+
send({
|
41
|
+
"command" => "DoRefresh",
|
42
|
+
"root" => root,
|
43
|
+
"name" => name,
|
44
|
+
"date" => date,
|
45
|
+
"time" => time,
|
46
|
+
"type" => type,
|
47
|
+
"files" => files
|
48
|
+
})
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -20,13 +20,13 @@ module XRefreshServer
|
|
20
20
|
root = FSEventStreamCopyPathsBeingWatched(stream).first
|
21
21
|
paths.regard_as('*')
|
22
22
|
numEvents.times do |n|
|
23
|
-
|
23
|
+
OUT.puts "Event: #{paths[n]}" if @config["debug"]
|
24
24
|
@modified_dirs.add({:root=>root, :dir=>paths[n]})
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
@config["paths"].each do |path|
|
29
|
-
|
29
|
+
OUT.puts " monitoring #{yellow(path)}"
|
30
30
|
# need to create new stream for every supplied path
|
31
31
|
# because we want to report registered sources of the changes
|
32
32
|
stream = FSEventStreamCreate(
|
@@ -54,14 +54,14 @@ module XRefreshServer
|
|
54
54
|
# blocking call
|
55
55
|
def run_loop(start_time)
|
56
56
|
|
57
|
-
activities = {"changed" => '*', "deleted" => '-', "created" => '+', "renamed" => '>'}
|
57
|
+
activities = {"changed" => blue('*'), "deleted" => red('-'), "created" => green('+'), "renamed" => magenta('>')}
|
58
58
|
|
59
59
|
# main loop
|
60
|
-
|
60
|
+
OUT.puts "Waiting for file system events ..."
|
61
61
|
not_first_time = false
|
62
62
|
loop do
|
63
63
|
if @server.stopped?
|
64
|
-
|
64
|
+
OUT.puts "Server stopped"
|
65
65
|
break
|
66
66
|
end
|
67
67
|
@streams.each do |stream|
|
@@ -74,23 +74,23 @@ module XRefreshServer
|
|
74
74
|
dir = dir_info[:dir]
|
75
75
|
root = dir_info[:root]
|
76
76
|
unless dir=~@config["dir_include"]
|
77
|
-
|
77
|
+
OUT.puts "debug: #{dir} rejected because dir_include" if @config["debug"]
|
78
78
|
next
|
79
79
|
end
|
80
80
|
if dir=~@config["dir_exclude"]
|
81
|
-
|
81
|
+
OUT.puts "debug: #{dir} rejected because dir_exclude" if @config["debug"]
|
82
82
|
next
|
83
83
|
end
|
84
84
|
|
85
85
|
if File.exists?(dir)
|
86
|
-
|
86
|
+
OUT.puts "debug: checking dir #{dir}" if @config["debug"]
|
87
87
|
Dir.foreach(dir) do |file|
|
88
88
|
unless file=~@config["file_include"]
|
89
|
-
|
89
|
+
OUT.puts "debug: #{file} rejected because file_include" if @config["debug"]
|
90
90
|
next
|
91
91
|
end
|
92
92
|
if file=~@config["file_exclude"]
|
93
|
-
|
93
|
+
OUT.puts "debug: #{file} rejected because file_exclude" if @config["debug"]
|
94
94
|
next
|
95
95
|
end
|
96
96
|
|
@@ -98,17 +98,17 @@ module XRefreshServer
|
|
98
98
|
next if File.directory?(full_path)
|
99
99
|
begin
|
100
100
|
stat = File.stat(full_path)
|
101
|
-
|
101
|
+
OUT.puts "debug: stat #{full_path}" if @config["debug"]
|
102
102
|
rescue
|
103
103
|
# file may not exist
|
104
|
-
|
104
|
+
OUT.puts "debug: stat failed #{full_path}" if @config["debug"]
|
105
105
|
next # keep silence
|
106
106
|
end
|
107
107
|
current_time = stat.mtime.to_i
|
108
108
|
original_time = @paths_info[full_path] || start_time
|
109
109
|
|
110
110
|
if (current_time > original_time)
|
111
|
-
|
111
|
+
OUT.puts "debug: reported #{full_path}" if @config["debug"]
|
112
112
|
relative_path = full_path[root.size+1..-1]
|
113
113
|
buckets[root]||=[]
|
114
114
|
buckets[root]<< {
|
@@ -129,7 +129,7 @@ module XRefreshServer
|
|
129
129
|
}
|
130
130
|
end
|
131
131
|
rescue
|
132
|
-
|
132
|
+
OUT.puts "debug: exception! #{dir}" if @config["debug"]
|
133
133
|
raise if @config["debug"]
|
134
134
|
next #keep silence
|
135
135
|
end
|
@@ -140,9 +140,9 @@ module XRefreshServer
|
|
140
140
|
|
141
141
|
if buckets.size
|
142
142
|
buckets.each do |root, files|
|
143
|
-
|
143
|
+
OUT.puts " activity in #{yellow(root)}:"
|
144
144
|
files.each do |file|
|
145
|
-
|
145
|
+
OUT.puts " #{activities[file["action"]]} #{blue(file["path1"])}"
|
146
146
|
end
|
147
147
|
date = nil
|
148
148
|
time = nil
|
@@ -5,12 +5,13 @@ module XRefreshServer
|
|
5
5
|
|
6
6
|
# server
|
7
7
|
class Server < GServer
|
8
|
-
|
8
|
+
attr_accessor :clients
|
9
9
|
|
10
|
-
def initialize(*args)
|
11
|
-
super
|
10
|
+
def initialize(port, host, max_connections, *args)
|
11
|
+
super
|
12
12
|
@clients = Set.new
|
13
13
|
@last_client_id = 0
|
14
|
+
OUT.puts "#{green('Started server')} on #{blue("#{host}:#{port}")} (max #{max_connections} clients)"
|
14
15
|
end
|
15
16
|
|
16
17
|
def serve(socket)
|
@@ -41,19 +42,19 @@ module XRefreshServer
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def process(client, msg)
|
44
|
-
# see windows implementation in src/winmonitor/Server.cs#ProcessMessage
|
45
|
+
# see windows implementation in http://github.com/darwin/xrefresh/tree/master/src/winmonitor/Server.cs#ProcessMessage
|
45
46
|
case msg["command"]
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
47
|
+
when "Hello"
|
48
|
+
client.type = msg["type"] || '?'
|
49
|
+
client.agent = msg["agent"] || '?'
|
50
|
+
OUT.puts "Client #{client.name} [#{magenta(client.agent)}] has connected"
|
51
|
+
client.send_about(VERSION, AGENT)
|
52
|
+
when "Bye"
|
53
|
+
@clients.delete(client)
|
54
|
+
OUT.puts "Client #{client.name} has disconnected"
|
55
|
+
when "SetPage"
|
56
|
+
url = msg["url"] || '?'
|
57
|
+
OUT.puts "Client #{client.name} changed page to #{blue(url)}"
|
57
58
|
end
|
58
59
|
end
|
59
60
|
end
|
data/{License.txt → license.txt}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2008 Antonin Hildebrand
|
1
|
+
Copyright (c) 2008-2009 Antonin Hildebrand
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -11,10 +11,10 @@ the following conditions:
|
|
11
11
|
The above copyright notice and this permission notice shall be
|
12
12
|
included in all copies or substantial portions of the Software.
|
13
13
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS",
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHout WARRANTY OF ANY KIND,
|
15
15
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, out OF OR IN CONNECTION
|
20
20
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/readme.md
ADDED
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.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antonin Hildebrand
|
@@ -9,63 +9,53 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
date: 2009-05-26 00:00:00 +02:00
|
13
|
+
default_executable: xrefresh-server
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: term-ansicolor
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: XRefresh is browser refresh automation for web developers
|
36
|
+
email: antonin@hildebrand.cz
|
19
37
|
executables:
|
20
38
|
- xrefresh-server
|
21
39
|
extensions: []
|
22
40
|
|
23
|
-
extra_rdoc_files:
|
24
|
-
|
25
|
-
- License.txt
|
26
|
-
- Manifest.txt
|
27
|
-
- PostInstall.txt
|
28
|
-
- README.txt
|
29
|
-
- website/index.txt
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
30
43
|
files:
|
31
|
-
-
|
32
|
-
- License.txt
|
33
|
-
- Manifest.txt
|
34
|
-
- PostInstall.txt
|
35
|
-
- README.txt
|
36
|
-
- Rakefile
|
44
|
+
- VERSION
|
37
45
|
- bin/xrefresh-server
|
38
|
-
- config/hoe.rb
|
39
|
-
- config/requirements.rb
|
40
|
-
- lib/client.rb
|
41
|
-
- lib/monitor.rb
|
42
|
-
- lib/server.rb
|
43
46
|
- lib/xrefresh-server.rb
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
- tasks/deployment.rake
|
50
|
-
- tasks/environment.rake
|
51
|
-
- tasks/website.rake
|
52
|
-
- website/index.html
|
53
|
-
- website/index.txt
|
54
|
-
- website/javascripts/rounded_corners_lite.inc.js
|
55
|
-
- website/stylesheets/screen.css
|
56
|
-
- website/template.html.erb
|
47
|
+
- lib/xrefresh-server/client.rb
|
48
|
+
- lib/xrefresh-server/monitor.rb
|
49
|
+
- lib/xrefresh-server/server.rb
|
50
|
+
- license.txt
|
51
|
+
- readme.md
|
57
52
|
has_rdoc: true
|
58
|
-
homepage: http://xrefresh-server
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
xrefresh-server
|
63
|
-
(when first launched, you will be asked to setup config file)
|
64
|
-
For more information see http://xrefresh-server.rubyforge.org
|
65
|
-
---
|
53
|
+
homepage: http://github.com/darwin/xrefresh-server
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
66
57
|
rdoc_options:
|
67
|
-
- --
|
68
|
-
- README.txt
|
58
|
+
- --charset=UTF-8
|
69
59
|
require_paths:
|
70
60
|
- lib
|
71
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -83,9 +73,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
73
|
requirements: []
|
84
74
|
|
85
75
|
rubyforge_project: xrefresh-server
|
86
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.3.3
|
87
77
|
signing_key:
|
88
|
-
specification_version:
|
89
|
-
summary: XRefresh filesystem monitor
|
78
|
+
specification_version: 3
|
79
|
+
summary: XRefresh filesystem monitor for OSX
|
90
80
|
test_files: []
|
91
81
|
|