fasterer 0.1.5 → 0.1.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: d9a60bfaadb97d52f9e2a7569a9eb689711e3c2a
4
- data.tar.gz: 16b63850424fe2df8b7619e1557a77fce37a7b5a
3
+ metadata.gz: 606c81ada0fb247e236a2f92ae042f363b5f4cbf
4
+ data.tar.gz: 323879b3d6230968fd2207d41d85ac697700d1c7
5
5
  SHA512:
6
- metadata.gz: 183a28079f52476cda7cc3d114c785a3e79c8ec6787af3e7ac9b36c6ab3a91b5d472e7be91364f3e25adfe3e0a6d34731beca50a4dd527e487e8b5cf90ad3142
7
- data.tar.gz: 770fb8c56a693144a95c8a69feec8e7a3bbc41195d09040bc48918458d80c507507344309e96940792a4b24f2911399d6b16901351433f7ccdf7b359867a2b12
6
+ metadata.gz: 444e1a9af93389bfe9a05adb3f03af1d689ee0f461ff35568a449493e4c85af73890fabf231e94341ae48d7e27611bf582fc9102e4286265d00e220d352c39ee
7
+ data.tar.gz: 496a9e543b07ef7cb190a765387391a2b1bc0c5dcfbc823f49cb735749d6ff48b1677efdc81404ee8665bf9b4d07633ca471d41df970a740257d0935b7f8d8e6
data/.fasterer.yml CHANGED
@@ -15,3 +15,5 @@ speedups:
15
15
  block_vs_symbol_to_proc: true
16
16
  proc_call_vs_yield: true
17
17
  gsub_vs_tr: true
18
+ exclude_paths:
19
+ - 'vendor/**/*.rb'
data/README.md CHANGED
@@ -46,7 +46,14 @@ Use tr instead of gsub when grepping plain strings. Occured at lines: 161.
46
46
  ```
47
47
  ## Configuration
48
48
 
49
- You can turn off speed suggestions with a simple yaml file called **.fasterer.yml** in the root of your project. Example:
49
+ Configuration is done through the **.fasterer.yml** file placed in the root of your project.
50
+
51
+ Options:
52
+
53
+ * Turn off speed suggestions
54
+ * Blacklist files or complete folder paths
55
+
56
+ Example:
50
57
 
51
58
 
52
59
  ```yaml
@@ -67,6 +74,10 @@ speedups:
67
74
  block_vs_symbol_to_proc: true
68
75
  proc_call_vs_yield: true
69
76
  gsub_vs_tr: true
77
+
78
+ exclude_paths:
79
+ - 'vendor/**/*.rb'
80
+ - 'db/schema.rb'
70
81
  ```
71
82
 
72
83
  ## Speedups TODO:
@@ -13,7 +13,7 @@ module Fasterer
13
13
  alias_method :path, :file_path
14
14
 
15
15
  def initialize(file_path)
16
- @file_path = file_path
16
+ @file_path = file_path.to_s
17
17
  @file_content = File.read(file_path)
18
18
  end
19
19
 
@@ -9,12 +9,17 @@ module Fasterer
9
9
 
10
10
  CONFIG_FILE_NAME = '.fasterer.yml'
11
11
 
12
- attr_reader :ignored_speedups
12
+ SPEEDUPS_KEY = 'speedups'
13
+
14
+ EXCLUDE_PATHS_KEY = 'exclude_paths'
15
+
16
+ attr_reader :ignored_speedups, :ignored_paths
13
17
 
14
18
  def initialize(path)
15
19
  @path = Pathname(path)
16
20
  @parse_error_paths = []
17
21
  set_ignored_speedups
22
+ set_ignored_paths
18
23
  end
19
24
 
20
25
  def traverse
@@ -27,8 +32,14 @@ module Fasterer
27
32
  end
28
33
 
29
34
  def set_ignored_speedups
30
- @ignored_speedups = if config_file
31
- config_file['speedups'].select {|_, value| value == false }.keys.map(&:to_sym)
35
+ @ignored_speedups = if config_file && config_file[SPEEDUPS_KEY]
36
+ config_file[SPEEDUPS_KEY].select {|_, value| value == false }.keys.map(&:to_sym)
37
+ end || []
38
+ end
39
+
40
+ def set_ignored_paths
41
+ @ignored_paths = if config_file && config_file[EXCLUDE_PATHS_KEY]
42
+ config_file[EXCLUDE_PATHS_KEY].flat_map {|path| Dir[path] }
32
43
  end || []
33
44
  end
34
45
 
@@ -50,8 +61,11 @@ module Fasterer
50
61
  end
51
62
 
52
63
  def traverse_directory(path)
53
- Dir["#{path}/**/*.rb"].each do |ruby_file|
54
- scan_file(ruby_file.split('/').drop(1).join('/'))
64
+ Dir["#{path}/**/*.rb"].each do |ruby_file_path|
65
+ relative_ruby_file_path = Pathname(ruby_file_path).relative_path_from(path)
66
+ unless ignored_paths.include?(relative_ruby_file_path.to_s)
67
+ scan_file(relative_ruby_file_path)
68
+ end
55
69
  end
56
70
  end
57
71
 
@@ -1,3 +1,3 @@
1
1
  module Fasterer
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fasterer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damir Svrtan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize