guard-phpcs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in guard-node-jshint.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 - 2011 Patrik Henningsson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Guard::PHPCS
2
+
3
+ This guard will run [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer) for you automatically when files are modified.
4
+
5
+ ## Install
6
+
7
+ Make sure you have [guard](http://github.com/guard/guard) and [phpcs](http://pear.php.net/package/PHP_CodeSniffer) installed.
8
+
9
+ Install the gem with:
10
+
11
+ gem install guard-phpcs
12
+
13
+ Or add it to your Gemfile:
14
+
15
+ gem 'guard-phpcs'
16
+
17
+ And then add a basic setup to your Guardfile:
18
+
19
+ guard init phpcs
20
+
21
+ ## Options
22
+
23
+ * `:standard # default => "Zend"`
24
+
25
+ The name or path of the coding standard to use.
26
+
27
+ * `:tabs # default => 4`
28
+
29
+ The number of spaces each tab represents.
30
+
31
+ ### Example
32
+
33
+ guard 'phpcs', :standard => 'path/to/MyStandard' do
34
+ watch(%r{.*\.php$})
35
+ end
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "guard/phpcs"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "guard-phpcs"
7
+ s.version = Guard::PHPCS::VERSION
8
+ s.authors = ["Patrik Henningsson"]
9
+ s.email = ["patrik.henningsson@gmail.com"]
10
+ s.homepage = "http://github.com/pahen/guard-phpcs"
11
+ s.summary = "Guard gem for running PHPCS"
12
+ s.description = "Guard::PHPCS automatically runs PHP Code Sniffer when watched files are modified."
13
+
14
+ s.rubyforge_project = "guard-phpcs"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency 'guard', '>= 0.8.8'
22
+ end
@@ -0,0 +1,4 @@
1
+ # Installed by guard-phpcs
2
+ guard 'phpcs' do
3
+ watch(%r{.*\.php$})
4
+ end
@@ -0,0 +1,30 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ module Guard
5
+ class PHPCS < Guard
6
+
7
+ VERSION = '0.0.1'
8
+
9
+ DEFAULT_OPTIONS = {
10
+ :standard => 'Zend',
11
+ :tabs => 4
12
+ }
13
+
14
+ def initialize(watchers = [], options = {})
15
+ defaults = DEFAULT_OPTIONS.clone
16
+ @options = defaults.merge(options)
17
+ super(watchers, @options)
18
+ end
19
+
20
+ def run_on_change(paths)
21
+ paths.each do |path|
22
+ results = `phpcs --report=full --tab-width=#{@options[:tabs]} --standard=#{@options[:standard]} #{path}`
23
+ if $?.to_i > 0 then
24
+ ::Guard::Notifier.notify(results.gsub(/^-+\n/, '').gsub(/^FILE:.*\n/, '').gsub(/^Time:.*\n/, ''), :title => 'PHP Codesniffer', :image => :failed)
25
+ puts results
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-phpcs
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Patrik Henningsson
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-02-21 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: guard
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 47
29
+ segments:
30
+ - 0
31
+ - 8
32
+ - 8
33
+ version: 0.8.8
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: Guard::PHPCS automatically runs PHP Code Sniffer when watched files are modified.
37
+ email:
38
+ - patrik.henningsson@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - .gitignore
47
+ - Gemfile
48
+ - LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - guard-phpcs.gemspec
52
+ - lib/guard/phpcs.rb
53
+ - lib/guard/phpcs/templates/Guardfile
54
+ homepage: http://github.com/pahen/guard-phpcs
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project: guard-phpcs
83
+ rubygems_version: 1.8.17
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Guard gem for running PHPCS
87
+ test_files: []
88
+