nyx 1.3.4 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/nyx +1 -0
  2. data/lib/nyx.rb +46 -1
  3. metadata +1 -1
data/bin/nyx CHANGED
@@ -24,6 +24,7 @@ puts <<eos
24
24
  nyx compile:scripts <dir> - compile scripts
25
25
  nyx watch:style <dir> - initiate style monitors
26
26
  nyx compile:style <dir> - compile style
27
+ nyx check:php <dir> - check php syntax
27
28
  eos
28
29
 
29
30
  end#if
data/lib/nyx.rb CHANGED
@@ -12,7 +12,30 @@ require 'fssm'
12
12
 
13
13
  class Nyx
14
14
 
15
- VERSION = '1.3.4'
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: