21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/zayin/rake/php.rb', line 21
def define
namespace :vagrant do
namespace :php do
desc "Run phpunit on a PHP file.\n base_dir The directory on the VM to run the phpunit in.\n phpunit_xml The phpunit.xml file relative to base_dir to configure the\n phpunit run.\n target The class or PHP file relative to base_dir to run the tests on.\n filter The class or method to filter tests by.\n coverage The directory in the VM to put the HTML coverage reports into.\n EOS\n task :unit, [:base_dir,\n :phpunit_xml,\n :target,\n :filter,\n :coverage] do |t, args|\n base_dir = args[:base_dir] || Dir.pwd\n phpunit_xml = args[:phpunit_xml]\n target = args[:target]\n filter = args[:filter]\n coverage = args[:coverage]\n\n opts = []\n opts << \" -c \#{phpunit_xml}\" unless phpunit_xml.nil?\n opts << \" --coverage-html \#{coverage}\" unless coverage.nil?\n opts << \" --filter \#{filter}\" unless filter.nil?\n opts << \" \#{target}\" unless target.nil?\n\n cmd = \"cd \#{base_dir} && phpunit\#{opts.join(' ')}\"\n sh_cmd(cmd, coverage)\n end\n\n desc <<-EOS\nRun phpdoc in a directory.\n base_dir The directory to run phpdoc from.\n output_dir The output directory.\n EOS\n task :doc, [:base_dir, :output_dir] do |t, args|\n base_dir = args[:base_dir] || Dir.pwd\n output_dir = args[:output_dir] || File.join(Dir.pwd, 'docs')\n\n cmd = \"phpdoc -o HTML:frames:earthli -d \#{base_dir} -t \#{output_dir} \" +\n \"-i tests/,dist/,build/\"\n sh_cmd(cmd, output_dir)\n end\n\n desc <<-EOS\nRun PHP Mess Detector in a directory.\n base_dir The directory to run phpmd from.\n output_dir The output directory.\n ruleset An optional ruleset to also test against. This is added to\n the defaults of 'codesize,design,naming,unusedcode'.\n EOS\n task :md, [:base_dir, :output_dir, :ruleset] do |t, args|\n base_dir = args[:base_dir] || Dir.pwd\n output_dir = args[:output_dir] || File.join(Dir.pwd, 'phpmd')\n ruleset = args[:ruleset] || ''\n\n ruleset = ',' + ruleset unless ruleset.empty?\n\n cmd = \"phpmd \#{base_dir} html codesize,design,naming,unusedcode\#{ruleset} \" +\n \"--reportfile \#{output_dir}/index.html\"\n sh_cmd(cmd, output_dir)\n end\n\n desc <<-EOS\nCreate PHP_Depend static code analysis report.\n base_dir The directory to analyze.\n output_dir The output directory.\n EOS\n task :depend, [:base_dir, :output_dir] do |t ,args|\n base_dir = args[:base_dir] || Dir.pwd\n output_dir = args[:output_dir] || File.join(Dir.pwd, 'pdepend')\n\n cmd = \"pdepend --jdepend-xml=\#{output_dir}/jdepend.xml \" +\n \"--jdepend-chart=\#{output_dir}/dependencies.svg \" +\n \"--overview-pyramid=\#{output_dir}/overview-pyramid.svg \" +\n \"\#{base_dir}\"\n sh_cmd(cmd, output_dir)\n end\n\n desc <<-EOS\nGenerate a PHP Copy/Paste Detection report.\n base_dir The directory to analyze.\n output_dir The output directory.\n EOS\n task :cpd, [:base_dir, :output_dir] do |t, args|\n base_dir = args[:base_dir] || Dir.pwd\n output_dir = args[:output_dir] || File.join(Dir.pwd, 'phpcpd')\n\n cmd = \"phpcpd --log-pmd \#{output_dir}/pmd-cpd.xml \#{base_dir}\"\n sh_cmd(cmd, output_dir)\n end\n\n desc <<-EOS\nGenerate a PHP_CodeSniffer report for coding standards.\n base_dir The directory to analyze.\n output_dir The output directory.\n standard The standard to check against (default is Zend).\n args Other arguments (default is none).\n EOS\n task :cs, [:base_dir, :output_dir, :standard, :args] do |t, args|\n base_dir = args[:base_dir] || Dir.pwd\n output_dir = args[:output_dir] || File.join(Dir.pwd, 'phpcs')\n standard = args[:standard] || 'Zend'\n more_args = args[:args] || ''\n\n cmd = \"phpcs --report=checkstyle \" +\n \"--extensions=php \" +\n \"--ignore=*/tests/* \" +\n \"--report-file=\#{output_dir}/checkstyle.xml \" +\n \"--standard=\#{standard} \" +\n more_args +\n \" \#{base_dir}\"\n sh_cmd(cmd, output_dir)\n end\n end\n end\nend\n"
|