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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/README.md +2 -0
- data/fasterer.gemspec +1 -1
- data/lib/fasterer/file_traverser.rb +9 -4
- data/lib/fasterer/offense.rb +0 -1
- data/lib/fasterer/parser.rb +1 -1
- data/lib/fasterer/version.rb +1 -1
- data/spec/lib/fasterer/file_traverser_spec.rb +89 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 440ad7aebc217baefb3e0c8f370af06c70b268c0
|
4
|
+
data.tar.gz: ba9338f1902827973c18dfaf7f00f34149aac042
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 797d7f2a6d9cf016dc529bc2354683ef17c73cbeac91879b374913ff1762987fd01a7844fb4a486b73a6bd9640067792210a8d2a9ff810217138a1a2424f5975
|
7
|
+
data.tar.gz: 39df101b4b4e3693994e2a490f4c40ccba0b4ce067e0a6ed71a503aacbef061f746f56cf1efa5e4159aa36d775bfab4a491fcd1ed4c2451899239d6e9dad5672
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
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.
|
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
|
data/lib/fasterer/offense.rb
CHANGED
data/lib/fasterer/parser.rb
CHANGED
data/lib/fasterer/version.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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.
|
40
|
+
version: '3.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|