fasterer 0.1.12 → 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: a3553ce8184fc77f1acf47f6853044df9e21f5dc
4
- data.tar.gz: cc19c0ab4f3e1f57d865d8dd734da0e5edaddc0a
3
+ metadata.gz: 440ad7aebc217baefb3e0c8f370af06c70b268c0
4
+ data.tar.gz: ba9338f1902827973c18dfaf7f00f34149aac042
5
5
  SHA512:
6
- metadata.gz: 81fdc75a473a31b92c754da7f7a71c93b3f632b03f3a3fb0a7b1e514e27c24429247de20298579663772e92ac447359b409ecad1d712ce4f77ac12ecd7caaa03
7
- data.tar.gz: aa1a4e40b67a12654028fa0f2e2ec9e980436631f3437230a120f95349c608b209627d762e4b915cf88745f7e7b3e92e0be449814177ff1677729b67d18c1b91
6
+ metadata.gz: 797d7f2a6d9cf016dc529bc2354683ef17c73cbeac91879b374913ff1762987fd01a7844fb4a486b73a6bd9640067792210a8d2a9ff810217138a1a2424f5975
7
+ data.tar.gz: 39df101b4b4e3693994e2a490f4c40ccba0b4ce067e0a6ed71a503aacbef061f746f56cf1efa5e4159aa36d775bfab4a491fcd1ed4c2451899239d6e9dad5672
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  *.a
14
14
  mkmf.log
15
15
  *.gem
16
+ .ruby-version
data/.rubocop.yml CHANGED
@@ -1,3 +1,5 @@
1
+ LineLength:
2
+ Max: 100
1
3
  AllCops:
2
4
  Include:
3
5
  - '**/Rakefile'
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
  [![Code Climate](https://codeclimate.com/github/DamirSvrtan/fasterer/badges/gpa.svg)](https://codeclimate.com/github/DamirSvrtan/fasterer)
3
3
  [![Gem Version](https://badge.fury.io/rb/fasterer.svg)](http://badge.fury.io/rb/fasterer)
4
4
  [![Test Coverage](https://codeclimate.com/github/DamirSvrtan/fasterer/badges/coverage.svg)](https://codeclimate.com/github/DamirSvrtan/fasterer/coverage)
5
+ [![Dependency Status](https://gemnasium.com/DamirSvrtan/fasterer.svg)](https://gemnasium.com/DamirSvrtan/fasterer)
6
+
5
7
  # Fasterer
6
8
 
7
9
  Make your Rubies go faster with this command line tool highly inspired by [fast-ruby](https://github.com/JuanitoFatas/fast-ruby) and [Sferik's talk at Baruco Conf](https://speakerdeck.com/sferik/writing-fast-ruby).
data/fasterer.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'colorize', '~> 0.7'
22
- spec.add_dependency 'ruby_parser', '~> 3.6'
22
+ spec.add_dependency 'ruby_parser', '~> 3.7'
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.6'
25
25
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -11,6 +11,7 @@ module Fasterer
11
11
  EXCLUDE_PATHS_KEY = Config::EXCLUDE_PATHS_KEY
12
12
 
13
13
  attr_reader :config
14
+ attr_reader :parse_error_paths
14
15
 
15
16
  def initialize(path)
16
17
  @path = Pathname(path)
@@ -37,14 +38,13 @@ module Fasterer
37
38
 
38
39
  private
39
40
 
40
- attr_reader :parse_error_paths
41
41
  attr_accessor :offenses_found
42
42
 
43
43
  def scan_file(path)
44
44
  analyzer = Analyzer.new(path)
45
45
  analyzer.scan
46
- rescue RubyParser::SyntaxError, Racc::ParseError, Timeout::Error
47
- parse_error_paths.push(path)
46
+ rescue RubyParser::SyntaxError, Racc::ParseError, Timeout::Error => e
47
+ parse_error_paths.push(ErrorData.new(path, e.class, e.message).to_s)
48
48
  else
49
49
  if offenses_grouped_by_type(analyzer).any?
50
50
  output(analyzer)
@@ -85,7 +85,6 @@ module Fasterer
85
85
  puts 'has timed out. Unprocessable files were:'
86
86
  puts '-----------------------------------------------------'
87
87
  puts parse_error_paths
88
- puts
89
88
  end
90
89
 
91
90
  def ignored_speedups
@@ -100,4 +99,10 @@ module Fasterer
100
99
  config.nil_file
101
100
  end
102
101
  end
102
+
103
+ ErrorData = Struct.new(:file_path, :error_class, :error_message) do
104
+ def to_s
105
+ "#{file_path} - #{error_class} - #{error_message}"
106
+ end
107
+ end
103
108
  end
@@ -76,6 +76,5 @@ module Fasterer
76
76
  include_vs_cover_on_range:
77
77
  'Use #cover? instead of #include? on ranges'
78
78
  }
79
-
80
79
  end
81
80
  end
@@ -5,7 +5,7 @@ module Fasterer
5
5
  PARSER_CLASS = RubyParser
6
6
 
7
7
  def self.parse(ruby_code)
8
- PARSER_CLASS.new.parse(ruby_code)
8
+ PARSER_CLASS.for_current_ruby.parse(ruby_code)
9
9
  end
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module Fasterer
2
- VERSION = '0.1.12'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -186,8 +186,7 @@ describe Fasterer::FileTraverser do
186
186
  end
187
187
 
188
188
  before(:each) do
189
- create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME,
190
- config_file_content)
189
+ create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME, config_file_content)
191
190
  create_file(file_name)
192
191
  end
193
192
 
@@ -197,5 +196,93 @@ describe Fasterer::FileTraverser do
197
196
  expect(file_traverser.send(:scannable_files)).to eq([file_name])
198
197
  end
199
198
  end
199
+
200
+ context 'nested ruby files' do
201
+ before(:each) do
202
+ create_file('something.rb')
203
+ create_file('nested/something.rb')
204
+ end
205
+
206
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
207
+
208
+ it 'returns files properly' do
209
+ expect(file_traverser.send(:scannable_files))
210
+ .to match_array(['something.rb', 'nested/something.rb'])
211
+ end
212
+ end
213
+
214
+ context 'ruby files but nested ignored explicitly' do
215
+ let(:config_file_content) do
216
+ "exclude_paths:\n"\
217
+ " - 'nested/something.rb'"
218
+ end
219
+
220
+ before(:each) do
221
+ create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME, config_file_content)
222
+ create_file('something.rb')
223
+ create_file('nested/something.rb')
224
+ end
225
+
226
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
227
+
228
+ it 'returns unignored files' do
229
+ expect(file_traverser.send(:scannable_files))
230
+ .to match_array(['something.rb'])
231
+ end
232
+ end
233
+
234
+ context 'ruby files but nested ignored with *' do
235
+ let(:config_file_content) do
236
+ "exclude_paths:\n"\
237
+ " - 'nested/*'"
238
+ end
239
+
240
+ before(:each) do
241
+ create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME, config_file_content)
242
+ create_file('something.rb')
243
+ create_file('nested/something.rb')
244
+ end
245
+
246
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
247
+
248
+ it 'returns unignored files' do
249
+ expect(file_traverser.send(:scannable_files))
250
+ .to match_array(['something.rb'])
251
+ end
252
+ end
253
+
254
+ context 'ruby files but unnested ignored' do
255
+ let(:config_file_content) do
256
+ "exclude_paths:\n"\
257
+ " - 'something.rb'"
258
+ end
259
+
260
+ before(:each) do
261
+ create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME, config_file_content)
262
+ create_file('something.rb')
263
+ create_file('nested/something.rb')
264
+ end
265
+
266
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
267
+
268
+ it 'returns unignored files' do
269
+ expect(file_traverser.send(:scannable_files))
270
+ .to match_array(['nested/something.rb'])
271
+ end
272
+ end
273
+ end
274
+
275
+ describe 'parse errors' do
276
+ before do
277
+ create_file('user.rb', '[]*/sa*()')
278
+ file_traverser.traverse
279
+ end
280
+
281
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
282
+
283
+ it 'should have errors' do
284
+ expect(file_traverser.parse_error_paths)
285
+ .to match_array(['user.rb - RubyParser::SyntaxError - unterminated string meets end of file. near line 1: ""'])
286
+ end
200
287
  end
201
288
  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.12
4
+ version: 0.2.0
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-12-19 00:00:00.000000000 Z
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.6'
33
+ version: '3.7'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.6'
40
+ version: '3.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement