zayin 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.
@@ -0,0 +1,132 @@
1
+ require 'fileutils'
2
+ require 'rake'
3
+ require 'rake/tasklib'
4
+
5
+ module Zayin
6
+ module Rake
7
+ class PhpTasks < ::Rake::TaskLib
8
+ def initialize
9
+ yield self if block_given?
10
+ define
11
+ end
12
+
13
+ def sh_cmd(cmd, output_dir)
14
+ puts ">>> #{cmd}"
15
+ unless output_dir.nil? || File.directory?(output_dir)
16
+ FileUtils.mkdir_p(output_dir, :verbose => true)
17
+ end
18
+ sh cmd
19
+ end
20
+
21
+ def define
22
+ namespace :vagrant do
23
+ namespace :php do
24
+ desc <<-EOS
25
+ Run phpunit on a PHP file.
26
+ base_dir The directory on the VM to run the phpunit in.
27
+ phpunit_xml The phpunit.xml file relative to base_dir to configure the
28
+ phpunit run.
29
+ target The class or PHP file relative to base_dir to run the tests on.
30
+ coverage The directory in the VM to put the HTML coverage reports into.
31
+ EOS
32
+ task :unit, [:base_dir,
33
+ :phpunit_xml,
34
+ :target,
35
+ :coverage] do |t, args|
36
+ base_dir = args[:base_dir] || Dir.pwd
37
+ phpunit_xml = args[:phpunit_xml]
38
+ target = args[:target]
39
+ coverage = args[:coverage]
40
+
41
+ opts = []
42
+ opts << " -c #{phpunit_xml}" unless phpunit_xml.nil?
43
+ opts << " --coverage-html #{coverage}" unless coverage.nil?
44
+ opts << " #{target}" unless target.nil?
45
+
46
+ cmd = "cd #{base_dir} && phpunit#{opts.join(' ')}"
47
+ sh_cmd(cmd, coverage)
48
+ end
49
+
50
+ desc <<-EOS
51
+ Run phpdoc in a directory.
52
+ base_dir The directory to run phpdoc from.
53
+ output_dir The output directory.
54
+ EOS
55
+ task :doc, [:base_dir, :output_dir] do |t, args|
56
+ base_dir = args[:base_dir] || Dir.pwd
57
+ output_dir = args[:output_dir] || File.join(Dir.pwd, 'docs')
58
+
59
+ cmd = "phpdoc -o HTML:frames:earthli -d #{base_dir} -t #{output_dir} " +
60
+ "-i tests/,dist/,build/"
61
+ sh_cmd(cmd, output_dir)
62
+ end
63
+
64
+ desc <<-EOS
65
+ Run PHP Mess Detector in a directory.
66
+ base_dir The directory to run phpmd from.
67
+ output_dir The output directory.
68
+ EOS
69
+ task :md, [:base_dir, :output_dir] do |t, args|
70
+ base_dir = args[:base_dir] || Dir.pwd
71
+ output_dir = args[:output_dir] || File.join(Dir.pwd, 'phpmd')
72
+
73
+ cmd = "phpmd #{base_dir} html codesize,design,naming,unusedcode " +
74
+ "--reportfile #{output_dir}/index.html"
75
+ sh_cmd(cmd, output_dir)
76
+ end
77
+
78
+ desc <<-EOS
79
+ Create PHP_Depend static code analysis report.
80
+ base_dir The directory to analyze.
81
+ output_dir The output directory.
82
+ EOS
83
+ task :depend, [:base_dir, :output_dir] do |t ,args|
84
+ base_dir = args[:base_dir] || Dir.pwd
85
+ output_dir = args[:output_dir] || File.join(Dir.pwd, 'pdepend')
86
+
87
+ cmd = "pdepend --jdepend-xml=#{output_dir}/jdepend.xml " +
88
+ "--jdepend-chart=#{output_dir}/dependencies.svg " +
89
+ "--overview-pyramid=#{output_dir}/overview-pyramid.svg " +
90
+ "#{base_dir}"
91
+ sh_cmd(cmd, output_dir)
92
+ end
93
+
94
+ desc <<-EOS
95
+ Generate a PHP Copy/Paste Detection report.
96
+ base_dir The directory to analyze.
97
+ output_dir The output directory.
98
+ EOS
99
+ task :cpd, [:base_dir, :output_dir] do
100
+ base_dir = args[:base_dir] || Dir.pwd
101
+ output_dir = args[:output_dir] || File.join(Dir.pwd, 'phpcpd')
102
+
103
+ cmd = "phpcpd --log-pmd #{output_dir}/pmd-cpd.xml #{base_dir}"
104
+ sh_cmd(cmd, output_dir)
105
+ end
106
+
107
+ desc <<-EOS
108
+ Generate a PHP_CodeSniffer report for coding standards.
109
+ base_dir The directory to analyze.
110
+ output_dir The output directory.
111
+ standard The standard to check against (default is Zend).
112
+ EOS
113
+ task :cs, [:base_dir, :output_dir, :standard] do
114
+ base_dir = args[:base_dir] || Dir.pwd
115
+ output_dir = args[:output_dir] || File.join(Dir.pwd, 'phpcs')
116
+ standard = args[:standard] || 'Zend'
117
+
118
+ cmd = "phpcs --report=checkstyle " +
119
+ "--extensions=php " +
120
+ "--ignore=*/tests/* " +
121
+ "--report-file=#{output_dir}/checkstyle.xml " +
122
+ "--standard=#{standard} " +
123
+ "#{base_dir}"
124
+ sh_cmd(cmd, output_dir)
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
132
+
@@ -0,0 +1,140 @@
1
+ require 'fileutils'
2
+ require 'rake'
3
+ require 'rake/tasklib'
4
+ require 'vagrant'
5
+
6
+ module Zayin
7
+ module Rake
8
+ module Vagrant
9
+ class PhpTasks < ::Rake::TaskLib
10
+ def initialize
11
+ yield self if block_given?
12
+ @env ||= ::Vagrant::Environment.new
13
+ define
14
+ end
15
+
16
+ def vm_ssh(cmd, output_dir)
17
+ puts ">>> #{cmd}"
18
+ @env.primary_vm.ssh.execute do |ssh|
19
+ unless output_dir.nil?
20
+ ssh.exec("if [ ! -d #{output_dir} ]; then mkdir -p #{output_dir}; fi")
21
+ end
22
+ ssh.exec!(cmd) do |channel, stream, data|
23
+ print data
24
+ $stdout.flush
25
+ end
26
+ end
27
+ end
28
+
29
+ def define
30
+ namespace :vagrant do
31
+ namespace :php do
32
+ desc <<-EOS
33
+ Run phpunit on a PHP file.
34
+ base_dir The directory on the VM to run the phpunit in.
35
+ phpunit_xml The phpunit.xml file relative to base_dir to configure the
36
+ phpunit run.
37
+ target The class or PHP file relative to base_dir to run the tests on.
38
+ coverage The directory in the VM to put the HTML coverage reports into.
39
+ EOS
40
+ task :unit, [:base_dir,
41
+ :phpunit_xml,
42
+ :target,
43
+ :coverage] do |t, args|
44
+ base_dir = args[:base_dir] || '/vagrant'
45
+ phpunit_xml = args[:phpunit_xml]
46
+ target = args[:target]
47
+ coverage = args[:coverage]
48
+
49
+ opts = []
50
+ opts << " -c #{phpunit_xml}" unless phpunit_xml.nil?
51
+ opts << " --coverage-html #{coverage}" unless coverage.nil?
52
+ opts << " #{target}" unless target.nil?
53
+
54
+ cmd = "cd #{base_dir} && phpunit#{opts.join(' ')}"
55
+ vm_ssh(cmd, coverage)
56
+ end
57
+
58
+ desc <<-EOS
59
+ Run phpdoc in a directory.
60
+ base_dir The directory to run phpdoc from.
61
+ output_dir The output directory.
62
+ EOS
63
+ task :doc, [:base_dir, :output_dir] do |t, args|
64
+ base_dir = args[:base_dir] || '/vagrant'
65
+ output_dir = args[:output_dir] || '/vagrant/docs'
66
+
67
+ cmd = "phpdoc -o HTML:frames:earthli -d #{base_dir} -t #{output_dir} " +
68
+ "-i tests/,dist/,build/"
69
+ vm_ssh(cmd, output_dir)
70
+ end
71
+
72
+ desc <<-EOS
73
+ Run PHP Mess Detector in a directory.
74
+ base_dir The directory to run phpmd from.
75
+ output_dir The output directory.
76
+ EOS
77
+ task :md, [:base_dir, :output_dir] do |t, args|
78
+ base_dir = args[:base_dir] || '/vagrant'
79
+ output_dir = args[:output_dir] || '/vagrant/phpmd'
80
+
81
+ cmd = "phpmd #{base_dir} html codesize,design,naming,unusedcode " +
82
+ "--reportfile #{output_dir}/index.html"
83
+ vm_ssh(cmd, output_dir)
84
+ end
85
+
86
+ desc <<-EOS
87
+ Create PHP_Depend static code analysis report.
88
+ base_dir The directory to analyze.
89
+ output_dir The output directory.
90
+ EOS
91
+ task :depend, [:base_dir, :output_dir] do |t ,args|
92
+ base_dir = args[:base_dir] || '/vagrant'
93
+ output_dir = args[:output_dir] || '/vagrant/pdepend'
94
+
95
+ cmd = "pdepend --jdepend-xml=#{output_dir}/jdepend.xml " +
96
+ "--jdepend-chart=#{output_dir}/dependencies.svg " +
97
+ "--overview-pyramid=#{output_dir}/overview-pyramid.svg " +
98
+ "#{base_dir}"
99
+ vm_ssh(cmd, output_dir)
100
+ end
101
+
102
+ desc <<-EOS
103
+ Generate a PHP Copy/Paste Detection report.
104
+ base_dir The directory to analyze.
105
+ output_dir The output directory.
106
+ EOS
107
+ task :cpd, [:base_dir, :output_dir] do
108
+ base_dir = args[:base_dir] || '/vagrant'
109
+ output_dir = args[:output_dir] || '/vagrant/phpcpd'
110
+
111
+ cmd = "phpcpd --log-pmd #{output_dir}/pmd-cpd.xml #{base_dir}"
112
+ vm_ssh(cmd, output_dir)
113
+ end
114
+
115
+ desc <<-EOS
116
+ Generate a PHP_CodeSniffer report for coding standards.
117
+ base_dir The directory to analyze.
118
+ output_dir The output directory.
119
+ standard The standard to check against (default is Zend).
120
+ EOS
121
+ task :cs, [:base_dir, :output_dir, :standard] do
122
+ base_dir = args[:base_dir] || '/vagrant'
123
+ output_dir = args[:output_dir] || '/vagrant/phpcs'
124
+ standard = args[:standard] || 'Zend'
125
+
126
+ cmd = "phpcs --report=checkstyle " +
127
+ "--extensions=php " +
128
+ "--ignore=*/tests/* " +
129
+ "--report-file=#{output_dir}/checkstyle.xml " +
130
+ "--standard=#{standard} " +
131
+ "#{base_dir}"
132
+ vm_ssh(cmd, output_dir)
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zayin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-06 00:00:00.000000000 Z
12
+ date: 2011-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &2152885820 !ruby/object:Gem::Requirement
16
+ requirement: &2169628060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.8'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152885820
24
+ version_requirements: *2169628060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shoulda
27
- requirement: &2152884820 !ruby/object:Gem::Requirement
27
+ requirement: &2169627580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2152884820
35
+ version_requirements: *2169627580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2152900060 !ruby/object:Gem::Requirement
38
+ requirement: &2169643480 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2152900060
46
+ version_requirements: *2169643480
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &2152899140 !ruby/object:Gem::Requirement
49
+ requirement: &2169643000 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152899140
57
+ version_requirements: *2169643000
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &2152898520 !ruby/object:Gem::Requirement
60
+ requirement: &2169642520 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2152898520
68
+ version_requirements: *2169642520
69
69
  description: A collection of Ruby utilities and Rake tasks.
70
70
  email: erochest@gmail.com
71
71
  executables: []
@@ -77,7 +77,9 @@ files:
77
77
  - lib/zayin.rb
78
78
  - lib/zayin/rake/docco.rb
79
79
  - lib/zayin/rake/haskell.rb
80
+ - lib/zayin/rake/php.rb
80
81
  - lib/zayin/rake/vagrant.rb
82
+ - lib/zayin/rake/vagrant/php.rb
81
83
  - LICENSE.txt
82
84
  - README.md
83
85
  homepage: http://github.com/erochest/zayin
@@ -95,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
97
  version: '0'
96
98
  segments:
97
99
  - 0
98
- hash: -690619307997794117
100
+ hash: 181829463773986760
99
101
  required_rubygems_version: !ruby/object:Gem::Requirement
100
102
  none: false
101
103
  requirements: