p8-file_stats_checker 0.0.2 → 0.0.3
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/bin/file_stats_checker +7 -0
- data/bin/file_stats_server +11 -0
- data/lib/file_stats_checker.rb +34 -0
- metadata +4 -4
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
|
+
|
5
|
+
# Has a dependency in /Library/LaunchAgents/net.deheus.petrik.FileStatServer.plist
|
6
|
+
#
|
7
|
+
|
8
|
+
server = FileStatsServer.new('voltron.local', 3333)
|
9
|
+
server.audit = true
|
10
|
+
server.start
|
11
|
+
server.join
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'gserver'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
class FileStatsServer < GServer
|
5
|
+
|
6
|
+
def initialize(host, port)
|
7
|
+
p "Starting server at #{host}:#{port}"
|
8
|
+
super(port, host)
|
9
|
+
end
|
10
|
+
|
11
|
+
def serve(client)
|
12
|
+
file, stat = client.readline.split(',', 2).each{|str| str.strip!}
|
13
|
+
if file && File.exist?(file) && ["mtime", "ctime", "size"].include?(stat)
|
14
|
+
client.puts(File.stat(file).send(stat))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class FileStatsClient
|
20
|
+
|
21
|
+
def initialize(host, port)
|
22
|
+
@sm = TCPSocket.new(host, port)
|
23
|
+
end
|
24
|
+
|
25
|
+
def stat(file, stat)
|
26
|
+
@sm.puts [file, stat].join(',')
|
27
|
+
@sm.readline.strip
|
28
|
+
rescue EOFError
|
29
|
+
p
|
30
|
+
end
|
31
|
+
|
32
|
+
def terminate() @sm.close; end
|
33
|
+
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: p8-file_stats_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petrik de Heus
|
@@ -23,9 +23,9 @@ extra_rdoc_files: []
|
|
23
23
|
|
24
24
|
files:
|
25
25
|
- README
|
26
|
-
- bin/
|
27
|
-
- bin/
|
28
|
-
- lib/
|
26
|
+
- bin/file_stats_checker
|
27
|
+
- bin/file_stats_server
|
28
|
+
- lib/file_stats_checker.rb
|
29
29
|
- test/file_stats_checker_test.rb
|
30
30
|
has_rdoc: false
|
31
31
|
homepage:
|