phare 0.5 → 0.5.1
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.
- checksums.yaml +4 -4
- data/lib/phare.rb +1 -0
- data/lib/phare/check.rb +6 -15
- data/lib/phare/check/jscs.rb +5 -3
- data/lib/phare/check/jshint.rb +6 -4
- data/lib/phare/check/rubocop.rb +4 -2
- data/lib/phare/check/scss_lint.rb +5 -3
- data/lib/phare/git.rb +24 -0
- data/lib/phare/version.rb +1 -1
- data/spec/phare/check/jscs_spec.rb +1 -1
- data/spec/phare/check/rubocop_spec.rb +1 -1
- data/spec/phare/check/scss_lint_spec.rb +1 -1
- data/spec/phare/git_spec.rb +65 -0
- metadata +18 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4252890c78249696e509dff17d5e00f85d7b7e0
|
4
|
+
data.tar.gz: 0d8df6eff8c70b1e2979cae85e2963ef36d8ba39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15fc957a15daf979910740aeeb670691baacfc85b2a8f094cecf983c8fd717a16321d77f0cf941a57f221b158dbb00db4d49b6f1ce1137b0ce994eec3b9e9e56
|
7
|
+
data.tar.gz: 3dce84427d6f0d9947c96244dd928cadf5b9a9acf984ec217d752350df0c67d9a067ad0e854780807ad23900aa340ca7c3bce06e9c6a1ffa9f9046ec354bccd5
|
data/lib/phare.rb
CHANGED
data/lib/phare/check.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module Phare
|
2
2
|
class Check
|
3
|
-
attr_reader :status, :command
|
3
|
+
attr_reader :status, :command, :tree
|
4
|
+
|
5
|
+
def initialize(directory, options = {})
|
6
|
+
@tree = Git.new(@extensions, options)
|
7
|
+
end
|
4
8
|
|
5
9
|
def run
|
6
10
|
if should_run?
|
@@ -20,19 +24,6 @@ module Phare
|
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
23
|
-
def tree_changed?
|
24
|
-
@options[:diff] && tree_changes && tree_changes.any?
|
25
|
-
end
|
26
|
-
|
27
|
-
def tree_changes
|
28
|
-
@modified_files ||= Phare.system_output('git status -s').split("\n").reduce([]) do |memo, diff|
|
29
|
-
filename = diff.split(' ').last
|
30
|
-
|
31
|
-
memo << filename if @extensions.include?(File.extname(filename))
|
32
|
-
memo
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
27
|
def should_run?
|
37
28
|
should_run = binary_exists?
|
38
29
|
|
@@ -41,7 +32,7 @@ module Phare
|
|
41
32
|
end
|
42
33
|
|
43
34
|
if @options[:diff]
|
44
|
-
should_run = should_run &&
|
35
|
+
should_run = should_run && @tree.changed?
|
45
36
|
end
|
46
37
|
|
47
38
|
should_run
|
data/lib/phare/check/jscs.rb
CHANGED
@@ -9,11 +9,13 @@ module Phare
|
|
9
9
|
@path = File.expand_path("#{directory}app/assets", __FILE__)
|
10
10
|
@extensions = %w(.js)
|
11
11
|
@options = options
|
12
|
+
|
13
|
+
super
|
12
14
|
end
|
13
15
|
|
14
16
|
def command
|
15
|
-
if
|
16
|
-
"jscs #{
|
17
|
+
if @tree.changed?
|
18
|
+
"jscs #{@tree.changes.join(' ')}"
|
17
19
|
else
|
18
20
|
"jscs #{@path}"
|
19
21
|
end
|
@@ -30,7 +32,7 @@ module Phare
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def argument_exists?
|
33
|
-
|
35
|
+
@tree.changed? || Dir.exists?(@path)
|
34
36
|
end
|
35
37
|
|
36
38
|
def print_banner
|
data/lib/phare/check/jshint.rb
CHANGED
@@ -8,13 +8,15 @@ module Phare
|
|
8
8
|
@config = File.expand_path("#{directory}.jshintrc", __FILE__)
|
9
9
|
@path = File.expand_path("#{directory}app/assets/javascripts", __FILE__)
|
10
10
|
@glob = File.join(@path, '**/*')
|
11
|
-
@extensions = %w(.js .es6
|
11
|
+
@extensions = %w(.js .es6)
|
12
12
|
@options = options
|
13
|
+
|
14
|
+
super
|
13
15
|
end
|
14
16
|
|
15
17
|
def command
|
16
|
-
if
|
17
|
-
"jshint --config #{@config} --extra-ext #{@extensions.join(',')} #{
|
18
|
+
if @tree.changed?
|
19
|
+
"jshint --config #{@config} --extra-ext #{@extensions.join(',')} #{@tree.changes.join(' ')}"
|
18
20
|
else
|
19
21
|
"jshint --config #{@config} --extra-ext #{@extensions.join(',')} #{@glob}"
|
20
22
|
end
|
@@ -31,7 +33,7 @@ module Phare
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def arguments_exists?
|
34
|
-
|
36
|
+
@tree.changed? || Dir.exists?(@path)
|
35
37
|
end
|
36
38
|
|
37
39
|
def print_banner
|
data/lib/phare/check/rubocop.rb
CHANGED
@@ -6,11 +6,13 @@ module Phare
|
|
6
6
|
@path = directory
|
7
7
|
@extensions = %w(.rb)
|
8
8
|
@options = options
|
9
|
+
|
10
|
+
super
|
9
11
|
end
|
10
12
|
|
11
13
|
def command
|
12
|
-
if
|
13
|
-
"rubocop #{
|
14
|
+
if @tree.changed?
|
15
|
+
"rubocop #{@tree.changes.join(' ')}"
|
14
16
|
else
|
15
17
|
'rubocop'
|
16
18
|
end
|
@@ -8,11 +8,13 @@ module Phare
|
|
8
8
|
@path = File.expand_path("#{directory}app/assets/stylesheets", __FILE__)
|
9
9
|
@extensions = %w(.css .scss)
|
10
10
|
@options = options
|
11
|
+
|
12
|
+
super
|
11
13
|
end
|
12
14
|
|
13
15
|
def command
|
14
|
-
if
|
15
|
-
"scss-lint #{
|
16
|
+
if @tree.changed?
|
17
|
+
"scss-lint #{@tree.changes.join(' ')}"
|
16
18
|
else
|
17
19
|
"scss-lint #{@path}"
|
18
20
|
end
|
@@ -25,7 +27,7 @@ module Phare
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def arguments_exists?
|
28
|
-
|
30
|
+
@tree.changed? || Dir.exists?(@path)
|
29
31
|
end
|
30
32
|
|
31
33
|
def print_banner
|
data/lib/phare/git.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Phare
|
2
|
+
class Git
|
3
|
+
def initialize(extensions, options)
|
4
|
+
@extensions = extensions
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
def changed?
|
9
|
+
@options[:diff] && changes.any?
|
10
|
+
end
|
11
|
+
|
12
|
+
def changes
|
13
|
+
@changes ||= Phare.system_output('git status -s').split("\n").reduce([]) do |memo, diff|
|
14
|
+
filename = diff.split(' ').last
|
15
|
+
|
16
|
+
if diff =~ /^[^D]{2}/ && @extensions.include?(File.extname(filename))
|
17
|
+
memo << filename
|
18
|
+
end
|
19
|
+
|
20
|
+
memo
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/phare/version.rb
CHANGED
@@ -56,7 +56,7 @@ describe Phare::Check::JSCS do
|
|
56
56
|
let(:command) { "jscs #{files.join(' ')}" }
|
57
57
|
let(:jscs_exit_status) { 1337 }
|
58
58
|
|
59
|
-
before { expect(check).to receive(:
|
59
|
+
before { expect(check.tree).to receive(:changes).and_return(files).at_least(:once) }
|
60
60
|
|
61
61
|
it { expect { run! }.to change { check.status }.to(jscs_exit_status) }
|
62
62
|
end
|
@@ -47,7 +47,7 @@ describe Phare::Check::Rubocop do
|
|
47
47
|
let(:command) { "rubocop #{files.join(' ')}" }
|
48
48
|
let(:rubocop_exit_status) { 1337 }
|
49
49
|
|
50
|
-
before { expect(check).to receive(:
|
50
|
+
before { expect(check.tree).to receive(:changes).and_return(files).at_least(:once) }
|
51
51
|
|
52
52
|
it { expect { run! }.to change { check.status }.to(rubocop_exit_status) }
|
53
53
|
end
|
@@ -53,7 +53,7 @@ describe Phare::Check::ScssLint do
|
|
53
53
|
let(:command) { "scss-lint #{files.join(' ')}" }
|
54
54
|
let(:scsslint_exit_status) { 1337 }
|
55
55
|
|
56
|
-
before { expect(check).to receive(:
|
56
|
+
before { expect(check.tree).to receive(:changes).and_return(files).at_least(:once) }
|
57
57
|
|
58
58
|
it { expect { run! }.to change { check.status }.to(scsslint_exit_status) }
|
59
59
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Phare::Git do
|
4
|
+
let(:extensions) { ['.rb'] }
|
5
|
+
let(:options) { { diff: true } }
|
6
|
+
let(:git) { described_class.new(extensions, options) }
|
7
|
+
|
8
|
+
describe :changed? do
|
9
|
+
context 'with --diff options' do
|
10
|
+
before { expect(git).to receive(:changes).and_return(changes) }
|
11
|
+
|
12
|
+
context 'with changes' do
|
13
|
+
let(:changes) { ['foo.rb'] }
|
14
|
+
|
15
|
+
it { expect(git.changed?).to eq(true) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'without changes' do
|
19
|
+
let(:changes) { [] }
|
20
|
+
|
21
|
+
it { expect(git.changed?).to eq(false) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'without --diff options' do
|
26
|
+
let(:options) { { diff: false } }
|
27
|
+
|
28
|
+
it { expect(git.changed?).to eq(false) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe :changes do
|
33
|
+
before { expect(Phare).to receive(:system_output).with('git status -s').and_return(tree) }
|
34
|
+
|
35
|
+
context 'with empty tree' do
|
36
|
+
let(:tree) { '' }
|
37
|
+
|
38
|
+
it { expect(git.changes).to eq([]) }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with untracked file' do
|
42
|
+
let(:tree) { "?? foo.rb" }
|
43
|
+
|
44
|
+
it { expect(git.changes).to eq(['foo.rb']) }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with added file' do
|
48
|
+
let(:tree) { "A foo.rb\nAM bar.rb" }
|
49
|
+
|
50
|
+
it { expect(git.changes).to eq(['foo.rb', 'bar.rb']) }
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with modified file' do
|
54
|
+
let(:tree) { "M foo.rb\nDM bar.rb" }
|
55
|
+
|
56
|
+
it { expect(git.changes).to eq(['foo.rb']) }
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with deleted file' do
|
60
|
+
let(:tree) { " D foo.rb\nMD bar.rb" }
|
61
|
+
|
62
|
+
it { expect(git.changes).to eq([]) }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2014-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.0.0.beta2
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.0.0.beta2
|
55
55
|
description: Phare looks into your files and check for (Ruby, JavaScript and SCSS)
|
@@ -61,10 +61,10 @@ executables:
|
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
-
- .gitignore
|
65
|
-
- .rspec
|
66
|
-
- .rubocop.yml
|
67
|
-
- .travis.yml
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".rubocop.yml"
|
67
|
+
- ".travis.yml"
|
68
68
|
- Gemfile
|
69
69
|
- LICENSE.md
|
70
70
|
- README.md
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/phare/check/scss_lint.rb
|
79
79
|
- lib/phare/check_suite.rb
|
80
80
|
- lib/phare/cli.rb
|
81
|
+
- lib/phare/git.rb
|
81
82
|
- lib/phare/version.rb
|
82
83
|
- phare.gemspec
|
83
84
|
- spec/phare/check/jscs_spec.rb
|
@@ -86,6 +87,7 @@ files:
|
|
86
87
|
- spec/phare/check/scss_lint_spec.rb
|
87
88
|
- spec/phare/check_suite_spec.rb
|
88
89
|
- spec/phare/cli_spec.rb
|
90
|
+
- spec/phare/git_spec.rb
|
89
91
|
- spec/spec_helper.rb
|
90
92
|
homepage: https://github.com/mirego/phare
|
91
93
|
licenses:
|
@@ -97,17 +99,17 @@ require_paths:
|
|
97
99
|
- lib
|
98
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
101
|
requirements:
|
100
|
-
- -
|
102
|
+
- - ">="
|
101
103
|
- !ruby/object:Gem::Version
|
102
104
|
version: '0'
|
103
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
106
|
requirements:
|
105
|
-
- -
|
107
|
+
- - ">="
|
106
108
|
- !ruby/object:Gem::Version
|
107
109
|
version: '0'
|
108
110
|
requirements: []
|
109
111
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.2.2
|
111
113
|
signing_key:
|
112
114
|
specification_version: 4
|
113
115
|
summary: Phare looks into your files and check for (Ruby, JavaScript and SCSS) coding
|
@@ -119,4 +121,5 @@ test_files:
|
|
119
121
|
- spec/phare/check/scss_lint_spec.rb
|
120
122
|
- spec/phare/check_suite_spec.rb
|
121
123
|
- spec/phare/cli_spec.rb
|
124
|
+
- spec/phare/git_spec.rb
|
122
125
|
- spec/spec_helper.rb
|