phare 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +2 -0
- data/README.md +30 -0
- data/Rakefile +1 -0
- data/bin/phare +25 -0
- data/lib/phare.rb +10 -0
- data/lib/phare/checks/javascript_jscs.rb +31 -0
- data/lib/phare/checks/javascript_jshint.rb +33 -0
- data/lib/phare/checks/ruby_rubocop.rb +24 -0
- data/lib/phare/cli.rb +29 -0
- data/lib/phare/version.rb +3 -0
- data/phare.gemspec +25 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9cdce49504a22679ea43dfe644e259f624322c6f
|
4
|
+
data.tar.gz: 3525cfc8920a49d5348c80eb1d4cec5a4c4a57de
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0c495fd0e49ee1a81215cd23c668696f6cdc334882f2e9c77bde160230ca1c997553fda95267e1ed569498d986ea4933f2a8cb5770e56d6cc3cfccabe614f1f0
|
7
|
+
data.tar.gz: 1c573198e4ff077aea4822748b11434dbc58b196764ea1e1a879a77aa4647e11f231dfe16dcc85637431d6bc1021b7dfa000029c78e0ccc2473aa2619a03994b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Phare
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application’s Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'phare'
|
9
|
+
```
|
10
|
+
|
11
|
+
If you wish to check for JavaScript code style using JSHint and JSCS, you must install them too:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
$ npm install -g jshint jscs
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Phare provides an executable named `phare`. You can just use it as is:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ phare
|
23
|
+
```
|
24
|
+
|
25
|
+
One of the best way to use Phare is by hooking it before your version control commits. For example, with `git`:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
$ bundle binstubs phare
|
29
|
+
$ ln -s "`pwd`/bin/phare" .git/hooks/pre-commit
|
30
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/phare
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
|
+
|
5
|
+
require 'phare'
|
6
|
+
|
7
|
+
if ENV['SKIP_CODE_CHECK']
|
8
|
+
puts '--------------------------------------------------------'
|
9
|
+
puts 'Skipping code style checking… Really? Well alright then…'
|
10
|
+
puts '--------------------------------------------------------'
|
11
|
+
else
|
12
|
+
if Phare::CLI.new(Dir.getwd).tap { |c| c.run }.status == 0
|
13
|
+
puts ''
|
14
|
+
puts '------------------------------------------'
|
15
|
+
puts 'Everything looks good, keep on committing!'
|
16
|
+
puts '------------------------------------------'
|
17
|
+
exit 0
|
18
|
+
else
|
19
|
+
puts ''
|
20
|
+
puts '------------------------------------------------------------------------'
|
21
|
+
puts 'Something’s wrong with your code style. Please fix it before committing.'
|
22
|
+
puts '------------------------------------------------------------------------'
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
end
|
data/lib/phare.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Phare
|
2
|
+
module Checks
|
3
|
+
class JavaScriptJSCS
|
4
|
+
attr_reader :status
|
5
|
+
|
6
|
+
def initialize(directory)
|
7
|
+
@config = File.expand_path("#{directory}.jscs.json", __FILE__)
|
8
|
+
@path = File.expand_path("#{directory}app/assets", __FILE__)
|
9
|
+
@command = "jscs #{@path}"
|
10
|
+
|
11
|
+
puts '---------------------------------------------'
|
12
|
+
puts 'Running JSCS to check for JavaScript style…'
|
13
|
+
puts '---------------------------------------------'
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
if File.exists?(@config)
|
18
|
+
system(@command)
|
19
|
+
@status = $CHILD_STATUS.exitstatus
|
20
|
+
|
21
|
+
unless @status == 0
|
22
|
+
puts "Something went wrong. Program exited with #{@status}"
|
23
|
+
end
|
24
|
+
else
|
25
|
+
puts 'No `.jscs.json` configuration file found. Skipping it.'
|
26
|
+
@status = 0
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Phare
|
2
|
+
module Checks
|
3
|
+
class JavaScriptJSHint
|
4
|
+
attr_reader :status
|
5
|
+
|
6
|
+
def initialize(directory)
|
7
|
+
@config = File.expand_path("#{directory}.jshintrc", __FILE__)
|
8
|
+
@path = File.expand_path("#{directory}app/assets/javascripts/**/*", __FILE__)
|
9
|
+
@command = "jshint --config #{@config} --extra-ext .js,.es6.js #{@path}"
|
10
|
+
|
11
|
+
puts '---------------------------------------------'
|
12
|
+
puts 'Running JSHint to check for JavaScript style…'
|
13
|
+
puts '---------------------------------------------'
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
if File.exists?(@config)
|
18
|
+
system(@command)
|
19
|
+
@status = $CHILD_STATUS.exitstatus
|
20
|
+
|
21
|
+
if @status == 0
|
22
|
+
puts 'No code style errors found.'
|
23
|
+
else
|
24
|
+
puts "Something went wrong. Program exited with #{@status}"
|
25
|
+
end
|
26
|
+
else
|
27
|
+
puts 'No `.jshintrc` configuration file found. Skipping it.'
|
28
|
+
@status = 0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Phare
|
2
|
+
module Checks
|
3
|
+
class RubyRubocop
|
4
|
+
attr_reader :status
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@command = 'bundle exec rubocop'
|
8
|
+
|
9
|
+
puts '----------------------------------------'
|
10
|
+
puts 'Running Rubocop to check for Ruby style…'
|
11
|
+
puts '----------------------------------------'
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
system(@command)
|
16
|
+
@status = $CHILD_STATUS.exitstatus
|
17
|
+
|
18
|
+
unless @status == 0
|
19
|
+
puts "Something went wrong. Program exited with #{@status}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/phare/cli.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'English'
|
2
|
+
|
3
|
+
module Phare
|
4
|
+
class CLI
|
5
|
+
attr_reader :status
|
6
|
+
|
7
|
+
def initialize(directory)
|
8
|
+
@directory = directory
|
9
|
+
@directory << '/' unless @directory.end_with?('/')
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
ruby = Checks::RubyRubocop.new
|
14
|
+
ruby.run
|
15
|
+
|
16
|
+
puts ''
|
17
|
+
|
18
|
+
jshint = Checks::JavaScriptJSHint.new(@directory)
|
19
|
+
jshint.run
|
20
|
+
|
21
|
+
puts ''
|
22
|
+
|
23
|
+
jscs = Checks::JavaScriptJSCS.new(@directory)
|
24
|
+
jscs.run
|
25
|
+
|
26
|
+
@status = [ruby.status, jshint.status, jscs.status].find { |status| status > 0 } || 0
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/phare.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'phare/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'phare'
|
8
|
+
spec.version = Phare::VERSION
|
9
|
+
spec.authors = ['Rémi Prévost']
|
10
|
+
spec.email = ['remi@exomel.com']
|
11
|
+
spec.description = ''
|
12
|
+
spec.summary = ''
|
13
|
+
spec.homepage = 'https://github.com/mirego/phare'
|
14
|
+
spec.license = 'BSD 3-Clause'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
|
24
|
+
spec.add_dependency 'rubocop'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phare
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rémi Prévost
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ''
|
56
|
+
email:
|
57
|
+
- remi@exomel.com
|
58
|
+
executables:
|
59
|
+
- phare
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/phare
|
68
|
+
- lib/phare.rb
|
69
|
+
- lib/phare/checks/javascript_jscs.rb
|
70
|
+
- lib/phare/checks/javascript_jshint.rb
|
71
|
+
- lib/phare/checks/ruby_rubocop.rb
|
72
|
+
- lib/phare/cli.rb
|
73
|
+
- lib/phare/version.rb
|
74
|
+
- phare.gemspec
|
75
|
+
homepage: https://github.com/mirego/phare
|
76
|
+
licenses:
|
77
|
+
- BSD 3-Clause
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.1.0
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: ''
|
99
|
+
test_files: []
|
100
|
+
has_rdoc:
|