nyx 1.3.4 → 1.4.0
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/nyx +1 -0
- data/lib/nyx.rb +46 -1
- metadata +1 -1
data/bin/nyx
CHANGED
data/lib/nyx.rb
CHANGED
@@ -12,7 +12,30 @@ require 'fssm'
|
|
12
12
|
|
13
13
|
class Nyx
|
14
14
|
|
15
|
-
VERSION = '1.
|
15
|
+
VERSION = '1.4.0'
|
16
|
+
|
17
|
+
def check_php(args)
|
18
|
+
if args.length != 0
|
19
|
+
dirpath = args[0].sub(/(\/)+$/,'')+'/'
|
20
|
+
else # no parameters, assume .
|
21
|
+
dirpath = './'
|
22
|
+
end#if
|
23
|
+
|
24
|
+
# imediate output
|
25
|
+
$stdout.sync = $stderr.sync = true
|
26
|
+
|
27
|
+
$stdout.puts
|
28
|
+
$stdout.puts " PHP syntax check"
|
29
|
+
$stdout.puts " ----------------------------------------------------"
|
30
|
+
error_code = self.error_scan(dirpath)
|
31
|
+
if (error_code == 0)
|
32
|
+
$stdout.puts " finished checking; all files are valid"
|
33
|
+
end
|
34
|
+
$stdout.puts " ----------------------------------------------------"
|
35
|
+
$stdout.puts
|
36
|
+
|
37
|
+
exit error_code
|
38
|
+
end#def
|
16
39
|
|
17
40
|
def compile_scripts(args = nil)
|
18
41
|
|
@@ -521,6 +544,28 @@ class Nyx
|
|
521
544
|
# Helpers
|
522
545
|
#
|
523
546
|
|
547
|
+
def error_scan(path)
|
548
|
+
errors = 0
|
549
|
+
Dir.glob(path+'/*') do |file|
|
550
|
+
next if file == '.' or file == '..'
|
551
|
+
if File.directory? file
|
552
|
+
errors += self.error_scan(file)
|
553
|
+
else # not directory
|
554
|
+
if file =~ /.*\.php$/
|
555
|
+
msg = `php -l #{file}`
|
556
|
+
if ! (msg =~ /^No syntax errors.*/)
|
557
|
+
$stdout.puts " invalid #{file}"
|
558
|
+
$stdout.puts msg.strip
|
559
|
+
$stdout.puts
|
560
|
+
errors += 1
|
561
|
+
end
|
562
|
+
end
|
563
|
+
end
|
564
|
+
end#glob
|
565
|
+
|
566
|
+
return errors
|
567
|
+
end#def
|
568
|
+
|
524
569
|
def download(domain, file, to)
|
525
570
|
Net::HTTP.start(domain) do |http|
|
526
571
|
resp = http.get(file)
|