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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9cdce49504a22679ea43dfe644e259f624322c6f
4
- data.tar.gz: 3525cfc8920a49d5348c80eb1d4cec5a4c4a57de
3
+ metadata.gz: 72b28ae2c619de4e9b95d9dd0d52abc85b10ed9c
4
+ data.tar.gz: 8625df33c0f902de3574ff3b66827e081fa2dfba
5
5
  SHA512:
6
- metadata.gz: 0c495fd0e49ee1a81215cd23c668696f6cdc334882f2e9c77bde160230ca1c997553fda95267e1ed569498d986ea4933f2a8cb5770e56d6cc3cfccabe614f1f0
7
- data.tar.gz: 1c573198e4ff077aea4822748b11434dbc58b196764ea1e1a879a77aa4647e11f231dfe16dcc85637431d6bc1021b7dfa000029c78e0ccc2473aa2619a03994b
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
- gem 'phare'
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
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
4
 
5
5
  require 'phare'
6
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
7
+ Phare::CLI.new(ENV)
@@ -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 File.exists?(@config)
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 File.exists?(@config)
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
- system(@command)
16
- @status = $CHILD_STATUS.exitstatus
11
+ if should_run?
12
+ print_banner
13
+ system(@command)
14
+ @status = $CHILD_STATUS.exitstatus
17
15
 
18
- unless @status == 0
19
- puts "Something went wrong. Program exited with #{@status}"
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
- 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
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
@@ -1,3 +1,3 @@
1
1
  module Phare
2
- VERSION = '0.1'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/phare.rb CHANGED
@@ -1,10 +1,9 @@
1
+ require 'English'
1
2
  require 'phare/version'
2
3
 
3
4
  require 'phare/cli'
5
+ require 'phare/check'
4
6
 
5
7
  require 'phare/checks/ruby_rubocop'
6
8
  require 'phare/checks/javascript_jshint'
7
9
  require 'phare/checks/javascript_jscs'
8
-
9
- module Phare
10
- end
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: '0.1'
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-25 00:00:00.000000000 Z
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: