rubocop-custom 0.0.5 → 0.0.6

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: 08cdf47ef094a2ab2943ff5f23002aedf587c29a
4
- data.tar.gz: f241f2748609b30037ff39dfb91e3ef30a83d0df
3
+ metadata.gz: 3b54804e76ca9710b351f4c146c64f0cbb71aa9d
4
+ data.tar.gz: 52f8a15356b3b335cd843e5d4862c0fdee41ff02
5
5
  SHA512:
6
- metadata.gz: 692ced81b8871f6dbb2f25f6ad1a38669132ce37d44d402f1c9572c4d504b0319265bbb211e242bc7230233eb2982833282a4048211a4b4de10865e9f1208c61
7
- data.tar.gz: e7a112a3c3e41c7b2612058c97ec2f57247cebc00aab613b50828a5b09e4a5ec231bb6e7bce2ad342880b4199decb65d8e1ae64bf52863af225e4c881615029c
6
+ metadata.gz: 3a495724cb521e2e33d057dd445a551e3079f95bbc658a9d185b537e6f3381bea3609faf18f16f50c930808d328c3891dea518a4a798cf4fe730d7072c907e69
7
+ data.tar.gz: c581fa00d1a6f3122f87bd58a078b587e3932c1bb8ebd7e870c09374de891f40f0c8847fc6f290c3affb079c4d00ae7005d5c90a31a8d2855ddc60501c3617d5
data/README.md CHANGED
@@ -1,14 +1,15 @@
1
1
  # RuboCop Custom
2
2
 
3
- This is entirely derivative of [rubocop-rspec](https://github.com/nevir/rubocop-rspec), the primary difference is it's designed to let you host your Cops inside your project rather than in someone's Gem.
3
+ Let's say you work on a few projects and they all have different style preferences. What do you do if those particulars fall outside of those covered by the excellent RuboCop gem?
4
4
 
5
- ## Installation
5
+ Extend it, per project, with custom cops.
6
6
 
7
+ ## Installation
7
8
 
8
- In your `Gemfile` (or perhaps in a custom group)
9
+ In your `Gemfile` (perhaps in a custom group)
9
10
 
10
11
  ```
11
- gem 'rubocop-custom'
12
+ gem 'rubocop-custom', require: false
12
13
  ```
13
14
 
14
15
  And modify your `.rubocop.yml`.
@@ -19,4 +20,10 @@ require: rubocop-custom
19
20
 
20
21
  ## Custom Cops
21
22
 
22
- Make new cops and put them into `spec/cops` and they'll be loaded automatically.
23
+ Make new cops and put them into `spec/cops`, `app/cops`, or `cops` and they'll be loaded automatically.
24
+
25
+ For inspiration, check out [RuboCop's cops](https://github.com/bbatsov/rubocop/tree/master/lib/rubocop/cop) and [RuboCop-rspec's cops](https://github.com/nevir/rubocop-rspec/tree/master/lib/rubocop/cop/rspec).
26
+
27
+ ## Acknowledgments
28
+
29
+ This is entirely derivative of [rubocop-rspec](https://github.com/nevir/rubocop-rspec).
@@ -1,10 +1,33 @@
1
1
  module Rubocop
2
2
  module Custom
3
3
  def self.inject!
4
- path = Dir.pwd.split('spec')
5
- Dir.glob(File.join(path[0], 'spec', 'cops', '*.rb')).each do |file|
6
- require file
4
+ root = Rubocop::Custom.project_root
5
+ return if root.nil?
6
+ ['spec/cops', 'cops', 'app/cops'].each do |subpath|
7
+ Dir.glob(File.join(root, subpath, '*.rb')).each do |file|
8
+ require file
9
+ end
7
10
  end
8
11
  end
12
+
13
+ def self.project_root
14
+ cwd = Dir.pwd
15
+ depth = 10
16
+ while depth > 0
17
+ if Rubocop::Custom.cwd_is_root?(cwd)
18
+ return cwd
19
+ else
20
+ depth -= 1
21
+ cwd = File.expand_path('..', cwd)
22
+ end
23
+ end
24
+ nil
25
+ end
26
+
27
+ def self.cwd_is_root?(cwd)
28
+ %w(Gemfile app).collect do |match|
29
+ File.exist?(File.join(cwd, match))
30
+ end.all?
31
+ end
9
32
  end
10
33
  end
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module Custom
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-custom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zack Hubert