codeguard 0.1.0 → 0.2.0

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: 3343437cf34b7ffe74f59a19d36fe409bb87dce1
4
- data.tar.gz: 9081554e84d84fef8ed4498fe479d0facd708880
3
+ metadata.gz: 1aec9a6eb30cc01b0856df8aa76668b859032359
4
+ data.tar.gz: ff80149e946c095d5171211d8f6546dd8bbfe8ac
5
5
  SHA512:
6
- metadata.gz: b51b9b7d1315526f552af5b272f2490e0a54bcdcfccca057fe202aa231d1ad9ca16630e5525bd46cf9bbf0400717e186288193f5e971895991794a8e8f7eb95c
7
- data.tar.gz: ac84755df4ccdaa3bf6234cc23af3fe1df4c7d54e1125afa3a0f2ee1a65b0346f95597f4b9f41dc639275e6f0bf067e4e4aaae2d0fbb5c773c28ba77ca838bd4
6
+ metadata.gz: 6cbea65fe897dea5e1cdb3f9f4c07b77ea07db912dca95088930fd7df158285eff35b3351323ff4526049557271fdb4508b6d68e11154a40bcec83d83045f9cc
7
+ data.tar.gz: a44fd969783e040a137a689d2172684d7bc06111d20313cec7b5c6c14fab31484d0e546548d9b60b3a7c28a8dc40c98b7620b240d89a3d31d0fc088624453260
data/.rubocop.yml CHANGED
@@ -582,12 +582,12 @@ Style/SignalException:
582
582
 
583
583
  Style/SingleLineBlockParams:
584
584
  Methods:
585
- - reduce:
586
- - a
587
- - e
588
- - inject:
589
- - a
590
- - e
585
+ - reduce: # because reek hates single-letter variables
586
+ - acc
587
+ - el
588
+ - inject: # because reek hates single-letter variables
589
+ - acc
590
+ - el
591
591
 
592
592
  Style/SingleLineMethods:
593
593
  AllowIfMethodIsEmpty: true
@@ -630,6 +630,7 @@ Style/SpaceAroundOperators:
630
630
  MultiSpaceAllowedForOperators:
631
631
  - '='
632
632
  - '=>'
633
+ - '|' # for codequest_pipes
633
634
 
634
635
  Style/SpaceBeforeBlockBraces:
635
636
  EnforcedStyle: space
data/HELP.md ADDED
@@ -0,0 +1,23 @@
1
+ Availables Commands
2
+ ---
3
+ * `codeguard help` - show help message
4
+ * `codeguard install` - install config for current project
5
+ * `codeguard setup` - sets local configuration - this cmd should be run
6
+ in every local environment
7
+ * `codeguard diff` - check if the files were not modified
8
+
9
+ Installed Configuration
10
+ ---
11
+ * coffeelint (http://www.coffeelint.org/)
12
+ * js_hint (https://github.com/damian/jshint)
13
+ * rubocop (https://github.com/bbatsov/rubocop)
14
+ * scss_lint (https://github.com/brigade/scss-lint)
15
+ * pre_commit (https://github.com/jish/pre-commit)
16
+
17
+ Local Setup
18
+ ---
19
+ * `.gitmessage` file will be added as a template in .git/config
20
+ * `pre-commit install` will be run - which will register pre-commit hook
21
+ * `git config pre-commit.ruby` will be added for rvm users. If ruby
22
+ version/gemset is changed then you should run `codeguard install`
23
+ again.
data/README.md CHANGED
@@ -17,4 +17,4 @@ end
17
17
  ```
18
18
  and run `bundle install`.
19
19
 
20
- You can check available options by running: `codeguard help`
20
+ Check [HELP](HELP.md) for more information or run `codeguard help`
data/codeguard.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency 'jshint'
24
24
  spec.add_runtime_dependency 'scss_lint'
25
25
  spec.add_runtime_dependency 'diffy'
26
+ spec.add_runtime_dependency 'pre-commit'
26
27
  spec.add_development_dependency 'bundler', '>= 1.6.9'
27
28
  spec.add_development_dependency 'rake', '~> 10.3'
28
29
  end
data/config/.rubocop.yml CHANGED
@@ -582,12 +582,12 @@ Style/SignalException:
582
582
 
583
583
  Style/SingleLineBlockParams:
584
584
  Methods:
585
- - reduce:
586
- - a
587
- - e
588
- - inject:
589
- - a
590
- - e
585
+ - reduce: # because reek hates single-letter variables
586
+ - acc
587
+ - el
588
+ - inject: # because reek hates single-letter variables
589
+ - acc
590
+ - el
591
591
 
592
592
  Style/SingleLineMethods:
593
593
  AllowIfMethodIsEmpty: true
@@ -630,6 +630,7 @@ Style/SpaceAroundOperators:
630
630
  MultiSpaceAllowedForOperators:
631
631
  - '='
632
632
  - '=>'
633
+ - '|' # for codequest_pipes
633
634
 
634
635
  Style/SpaceBeforeBlockBraces:
635
636
  EnforcedStyle: space
@@ -79,7 +79,7 @@
79
79
  "level": "ignore"
80
80
  },
81
81
  "no_interpolation_in_single_quotes": {
82
- "level": "ignore"
82
+ "level": "warn"
83
83
  },
84
84
  "no_nested_string_interpolation": {
85
85
  "level": "warn"
@@ -131,5 +131,8 @@
131
131
  },
132
132
  "transform_messes_up_line_numbers": {
133
133
  "level": "warn"
134
+ },
135
+ "eol_last": {
136
+ "level": "warn"
134
137
  }
135
138
  }
@@ -0,0 +1,9 @@
1
+ ---
2
+ :checks_remove: []
3
+ :checks_add:
4
+ - :console_log
5
+ - :pry
6
+ - :rubocop
7
+ - :coffeelint
8
+ - :scss_lint
9
+ - :jshint
data/lib/codeguard/cli.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  module Codeguard
2
2
  module CLI
3
- AVAILABLE_OPTIONS = %w(install help diff)
3
+ AVAILABLE_OPTIONS = %w(install setup help diff)
4
4
 
5
5
  module_function
6
6
 
7
7
  def run(*args)
8
8
  command = args.shift
9
9
  unless AVAILABLE_OPTIONS.include?(command)
10
- puts "Invalid option: #{command}"
10
+ puts "Invalid option: #{command}\n\n" if command
11
11
  command = :help
12
12
  end
13
13
 
@@ -1,3 +1,4 @@
1
+ require 'rainbow'
1
2
  module Codeguard
2
3
  module GitMessage
3
4
  module_function
@@ -10,8 +11,9 @@ module Codeguard
10
11
  Codeguard.config_path.join('.gitmessage')
11
12
  end
12
13
 
13
- def after_install
14
+ def setup
14
15
  `git config commit.template .gitmessage`
16
+ puts Rainbow('commit.template was added to git config').green
15
17
  end
16
18
  end # module GitMessage
17
19
  end # module Codeguard
@@ -21,8 +21,6 @@ module Codeguard
21
21
  "File: #{config_project_path} was created!"
22
22
  end
23
23
  puts Rainbow(output).green
24
-
25
- lint.after_install if lint.respond_to?(:after_install)
26
24
  end
27
25
 
28
26
  private
@@ -0,0 +1,23 @@
1
+ require 'rainbow'
2
+ module Codeguard
3
+ module PreCommit
4
+ module_function
5
+
6
+ def config_project_path
7
+ Pathname.new 'config/pre_commit.yml'
8
+ end
9
+
10
+ def config_gem_path
11
+ Codeguard.config_path.join('pre_commit.yml')
12
+ end
13
+
14
+ def setup
15
+ `pre-commit install`
16
+ puts Rainbow('pre-commit hooks were generated').green
17
+
18
+ return if `which rvm`.empty?
19
+ system('git config pre-commit.ruby "rvm `rvm current` do ruby"')
20
+ puts Rainbow('pre-commit.ruby was added to git config').green
21
+ end
22
+ end # module PreCommit
23
+ end # module Codeguard
@@ -0,0 +1,20 @@
1
+ require 'rainbow'
2
+ module Codeguard
3
+ class Setup
4
+ extend Forwardable
5
+ attr_accessor :lint
6
+
7
+ def self.perform(lint)
8
+ new(lint).tap(&:perform)
9
+ end
10
+
11
+ def initialize(lint)
12
+ @lint = lint
13
+ end
14
+
15
+ def perform
16
+ lint.setup
17
+ puts Rainbow("Setup for #{lint} was finished.").green
18
+ end
19
+ end # class Setup
20
+ end # module Codeguard
@@ -1,3 +1,3 @@
1
1
  module Codeguard
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end # module Codeguard
data/lib/codeguard.rb CHANGED
@@ -1,14 +1,18 @@
1
1
  require 'diffy'
2
2
  require 'codeguard/install'
3
+ require 'codeguard/setup'
3
4
  require 'codeguard/coffeelint'
4
5
  require 'codeguard/js_hint'
5
6
  require 'codeguard/rubocop'
6
7
  require 'codeguard/scss_lint'
7
8
  require 'codeguard/git_message'
8
9
  require 'codeguard/diff'
10
+ require 'codeguard/pre_commit'
9
11
 
10
12
  module Codeguard
11
- LINTERS = [Coffeelint, GitMessage, JSHint, Rubocop, SCSSLint]
13
+ LINTERS = [Coffeelint, GitMessage, JSHint, PreCommit, Rubocop, SCSSLint]
14
+ # Lints that require setup in every local environment
15
+ LOCAL_LINTERS = [GitMessage, PreCommit]
12
16
 
13
17
  module_function
14
18
 
@@ -18,6 +22,12 @@ module Codeguard
18
22
  end
19
23
  end
20
24
 
25
+ def setup
26
+ LOCAL_LINTERS.each do |lint|
27
+ Setup.perform(lint)
28
+ end
29
+ end
30
+
21
31
  def diff
22
32
  lints = LINTERS.map do |lint|
23
33
  diff = Diff.perform(lint)
@@ -29,19 +39,7 @@ module Codeguard
29
39
  end
30
40
 
31
41
  def help
32
- puts %(
33
- codeguard help - show this message
34
- codeguard install - install config for current project
35
- codeguard diff - check if the files were not modified
36
-
37
- The project will use configuration for:
38
- - coffeelint (http://www.coffeelint.org/)
39
- - js_hint (https://github.com/damian/jshint)
40
- - rubocop (https://github.com/bbatsov/rubocop)
41
- - scss_lint (https://github.com/brigade/scss-lint)
42
-
43
- .gitmessage file will be added as a template in .git/config
44
- )
42
+ puts IO.read(gem_root.join('HELP.md'))
45
43
  end
46
44
 
47
45
  def config_path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeguard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Wyszynski
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-11 00:00:00.000000000 Z
12
+ date: 2015-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -67,6 +67,20 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: pre-commit
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: bundler
72
86
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +121,7 @@ files:
107
121
  - ".gitignore"
108
122
  - ".rubocop.yml"
109
123
  - Gemfile
124
+ - HELP.md
110
125
  - LICENSE
111
126
  - README.md
112
127
  - Rakefile
@@ -117,6 +132,7 @@ files:
117
132
  - config/.scss-lint.yml
118
133
  - config/coffeelint.json
119
134
  - config/jshint.yml
135
+ - config/pre_commit.yml
120
136
  - eat-glitter.jpg
121
137
  - lib/codeguard.rb
122
138
  - lib/codeguard/cli.rb
@@ -125,8 +141,10 @@ files:
125
141
  - lib/codeguard/git_message.rb
126
142
  - lib/codeguard/install.rb
127
143
  - lib/codeguard/js_hint.rb
144
+ - lib/codeguard/pre_commit.rb
128
145
  - lib/codeguard/rubocop.rb
129
146
  - lib/codeguard/scss_lint.rb
147
+ - lib/codeguard/setup.rb
130
148
  - lib/codeguard/version.rb
131
149
  homepage: https://github.com/codequest-eu/codeguard
132
150
  licenses: