phare 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +49 -0
- data/README.md +4 -2
- data/bin/phare +2 -20
- data/lib/phare/check.rb +23 -0
- data/lib/phare/checks/javascript_jscs.rb +16 -6
- data/lib/phare/checks/javascript_jshint.rb +15 -6
- data/lib/phare/checks/ruby_rubocop.rb +23 -8
- data/lib/phare/cli.rb +22 -24
- data/lib/phare/version.rb +1 -1
- data/lib/phare.rb +2 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72b28ae2c619de4e9b95d9dd0d52abc85b10ed9c
|
4
|
+
data.tar.gz: 8625df33c0f902de3574ff3b66827e081fa2dfba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcc6e5cc92116b198cc50b9eda3cdc4db2c0469a0cea936bc8852a0541eb4f6bcee077418520d4502a6f4ba50bb19a3540d325b7b27e74ec54c4165079ce5296
|
7
|
+
data.tar.gz: 1f9b87c9982baea160b59e8c61365c4557ec2cc2d6c57f053c65811802c4ca13da21468b26c90c8d99bd709012245fa5114d2a7da090b802103f3fd663d2deae
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
AllCops:
|
2
|
+
Includes:
|
3
|
+
- Rakefile
|
4
|
+
- config.ru
|
5
|
+
- Gemfile
|
6
|
+
|
7
|
+
Documentation:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Encoding:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
LineLength:
|
14
|
+
Max: 200
|
15
|
+
|
16
|
+
AccessModifierIndentation:
|
17
|
+
EnforcedStyle: outdent
|
18
|
+
|
19
|
+
IfUnlessModifier:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
CaseIndentation:
|
23
|
+
IndentWhenRelativeTo: case
|
24
|
+
IndentOneStep: true
|
25
|
+
|
26
|
+
MethodLength:
|
27
|
+
CountComments: false
|
28
|
+
Max: 20
|
29
|
+
|
30
|
+
SignalException:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
ColonMethodCall:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
AsciiComments:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Lambda:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
RegexpLiteral:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
RedundantBegin:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
AssignmentInCondition:
|
49
|
+
Enabled: false
|
data/README.md
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
## Installation
|
4
4
|
|
5
|
-
Add this line to your application’s Gemfile:
|
5
|
+
Add this line to your application’s Gemfile as a development dependancy:
|
6
6
|
|
7
7
|
```ruby
|
8
|
-
|
8
|
+
group :development do
|
9
|
+
gem 'phare'
|
10
|
+
end
|
9
11
|
```
|
10
12
|
|
11
13
|
If you wish to check for JavaScript code style using JSHint and JSCS, you must install them too:
|
data/bin/phare
CHANGED
@@ -1,25 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
4
|
|
5
5
|
require 'phare'
|
6
6
|
|
7
|
-
|
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
|
7
|
+
Phare::CLI.new(ENV)
|
data/lib/phare/check.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Phare
|
2
|
+
class Check
|
3
|
+
attr_reader :status
|
4
|
+
|
5
|
+
def initialize(directory)
|
6
|
+
@directory = directory
|
7
|
+
@directory << '/' unless @directory.end_with?('/')
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
ruby = Checks::RubyRubocop.new
|
12
|
+
ruby.run
|
13
|
+
|
14
|
+
jshint = Checks::JavaScriptJSHint.new(@directory)
|
15
|
+
jshint.run
|
16
|
+
|
17
|
+
jscs = Checks::JavaScriptJSCS.new(@directory)
|
18
|
+
jscs.run
|
19
|
+
|
20
|
+
@status = [ruby.status, jshint.status, jscs.status].find { |status| status > 0 } || 0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -7,25 +7,35 @@ module Phare
|
|
7
7
|
@config = File.expand_path("#{directory}.jscs.json", __FILE__)
|
8
8
|
@path = File.expand_path("#{directory}app/assets", __FILE__)
|
9
9
|
@command = "jscs #{@path}"
|
10
|
-
|
11
|
-
puts '---------------------------------------------'
|
12
|
-
puts 'Running JSCS to check for JavaScript style…'
|
13
|
-
puts '---------------------------------------------'
|
14
10
|
end
|
15
11
|
|
16
12
|
def run
|
17
|
-
if
|
13
|
+
if should_run?
|
14
|
+
print_banner
|
18
15
|
system(@command)
|
19
16
|
@status = $CHILD_STATUS.exitstatus
|
20
17
|
|
21
18
|
unless @status == 0
|
22
19
|
puts "Something went wrong. Program exited with #{@status}"
|
23
20
|
end
|
21
|
+
|
22
|
+
puts ''
|
24
23
|
else
|
25
|
-
puts 'No `.jscs.json` configuration file found. Skipping it.'
|
26
24
|
@status = 0
|
27
25
|
end
|
28
26
|
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def should_run?
|
31
|
+
!`which jscs`.empty? && File.exists?(@config)
|
32
|
+
end
|
33
|
+
|
34
|
+
def print_banner
|
35
|
+
puts '---------------------------------------------'
|
36
|
+
puts 'Running JSCS to check for JavaScript style…'
|
37
|
+
puts '---------------------------------------------'
|
38
|
+
end
|
29
39
|
end
|
30
40
|
end
|
31
41
|
end
|
@@ -7,14 +7,10 @@ module Phare
|
|
7
7
|
@config = File.expand_path("#{directory}.jshintrc", __FILE__)
|
8
8
|
@path = File.expand_path("#{directory}app/assets/javascripts/**/*", __FILE__)
|
9
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
10
|
end
|
15
11
|
|
16
12
|
def run
|
17
|
-
if
|
13
|
+
if should_run?
|
18
14
|
system(@command)
|
19
15
|
@status = $CHILD_STATUS.exitstatus
|
20
16
|
|
@@ -23,11 +19,24 @@ module Phare
|
|
23
19
|
else
|
24
20
|
puts "Something went wrong. Program exited with #{@status}"
|
25
21
|
end
|
22
|
+
|
23
|
+
puts ''
|
26
24
|
else
|
27
|
-
puts 'No `.jshintrc` configuration file found. Skipping it.'
|
28
25
|
@status = 0
|
29
26
|
end
|
30
27
|
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def should_run?
|
32
|
+
!`which jshint`.empty? && File.exists?(@config)
|
33
|
+
end
|
34
|
+
|
35
|
+
def print_banner
|
36
|
+
puts '---------------------------------------------'
|
37
|
+
puts 'Running JSHint to check for JavaScript style…'
|
38
|
+
puts '---------------------------------------------'
|
39
|
+
end
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
@@ -5,20 +5,35 @@ module Phare
|
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@command = 'bundle exec rubocop'
|
8
|
-
|
9
|
-
puts '----------------------------------------'
|
10
|
-
puts 'Running Rubocop to check for Ruby style…'
|
11
|
-
puts '----------------------------------------'
|
12
8
|
end
|
13
9
|
|
14
10
|
def run
|
15
|
-
|
16
|
-
|
11
|
+
if should_run?
|
12
|
+
print_banner
|
13
|
+
system(@command)
|
14
|
+
@status = $CHILD_STATUS.exitstatus
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
unless @status == 0
|
17
|
+
puts "Something went wrong. Program exited with #{@status}"
|
18
|
+
end
|
19
|
+
|
20
|
+
puts ''
|
21
|
+
else
|
22
|
+
@status = 0
|
20
23
|
end
|
21
24
|
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def should_run?
|
29
|
+
!`which rubocop`.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_banner
|
33
|
+
puts '----------------------------------------'
|
34
|
+
puts 'Running Rubocop to check for Ruby style…'
|
35
|
+
puts '----------------------------------------'
|
36
|
+
end
|
22
37
|
end
|
23
38
|
end
|
24
39
|
end
|
data/lib/phare/cli.rb
CHANGED
@@ -1,29 +1,27 @@
|
|
1
|
-
require 'English'
|
2
|
-
|
3
1
|
module Phare
|
4
2
|
class CLI
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
3
|
+
def initialize(env)
|
4
|
+
if env['SKIP_CODE_CHECK']
|
5
|
+
puts '--------------------------------------------------------'
|
6
|
+
puts 'Skipping code style checking… Really? Well alright then…'
|
7
|
+
puts '--------------------------------------------------------'
|
8
|
+
|
9
|
+
exit 0
|
10
|
+
else
|
11
|
+
if Phare::Check.new(Dir.getwd).tap { |c| c.run }.status == 0
|
12
|
+
puts '------------------------------------------'
|
13
|
+
puts 'Everything looks good, keep on committing!'
|
14
|
+
puts '------------------------------------------'
|
15
|
+
|
16
|
+
exit 0
|
17
|
+
else
|
18
|
+
puts '------------------------------------------------------------------------'
|
19
|
+
puts 'Something’s wrong with your code style. Please fix it before committing.'
|
20
|
+
puts '------------------------------------------------------------------------'
|
21
|
+
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
end
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
data/lib/phare/version.rb
CHANGED
data/lib/phare.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémi Prévost
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,11 +61,13 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- .gitignore
|
64
|
+
- .rubocop.yml
|
64
65
|
- Gemfile
|
65
66
|
- README.md
|
66
67
|
- Rakefile
|
67
68
|
- bin/phare
|
68
69
|
- lib/phare.rb
|
70
|
+
- lib/phare/check.rb
|
69
71
|
- lib/phare/checks/javascript_jscs.rb
|
70
72
|
- lib/phare/checks/javascript_jshint.rb
|
71
73
|
- lib/phare/checks/ruby_rubocop.rb
|
@@ -97,4 +99,3 @@ signing_key:
|
|
97
99
|
specification_version: 4
|
98
100
|
summary: ''
|
99
101
|
test_files: []
|
100
|
-
has_rdoc:
|