ruumba 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/ruumba +4 -0
- data/lib/ruumba/analyzer.rb +26 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 783240f5de7ece2a461ceb69ffb488e5a826de0c
|
4
|
+
data.tar.gz: 23b7ecd5efc3b4f83659625d098ac84b95dfbf26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fcdea229af4eec348539314c1bb116f83d5b1a7a4dfeafb4ca031a3a8118e8080817b7d2e776f9626429b9fbc759d3b622c523f7e2452b3154106e8422d4b66
|
7
|
+
data.tar.gz: e806d424e8515584824f7fb3a9b5efc3d0dffd9eefb752a82fca7066183b2683c095989c8bb93cba17f7fd291d2b47dffa443659ca16a2e550d3ec7a1313a89b
|
data/bin/ruumba
CHANGED
@@ -26,6 +26,10 @@ opts_parser = OptionParser.new do |opts|
|
|
26
26
|
options[:arguments] << File.expand_path(c)
|
27
27
|
end
|
28
28
|
|
29
|
+
opts.on('-d', '--debug', 'Display debug info.') do ||
|
30
|
+
options[:arguments] << '--debug'
|
31
|
+
end
|
32
|
+
|
29
33
|
opts.on('-D', '--display-cop-names', 'Display cop names') do ||
|
30
34
|
options[:arguments] << '--display-cop-names'
|
31
35
|
end
|
data/lib/ruumba/analyzer.rb
CHANGED
@@ -19,14 +19,16 @@ module Ruumba
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Performs static analysis on the provided directory.
|
22
|
-
# @param [Array<String>] dir The
|
23
|
-
def run(
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
# @param [Array<String>] dir The directories / files to analyze.
|
23
|
+
def run(files_or_dirs = ARGV)
|
24
|
+
files_or_dirs = ['.'] if files_or_dirs.empty?
|
25
|
+
fq_files_or_dirs = files_or_dirs.map { |file_or_dir| Pathname.new(File.expand_path(file_or_dir)) }
|
26
|
+
pwd = Pathname.new(ENV['PWD'])
|
27
27
|
tmp = create_temp_dir
|
28
28
|
|
29
|
-
copy_erb_files(
|
29
|
+
copy_erb_files(fq_files_or_dirs, tmp, pwd)
|
30
|
+
|
31
|
+
target = '.'
|
30
32
|
run_rubocop(target, tmp)
|
31
33
|
end
|
32
34
|
|
@@ -94,20 +96,30 @@ module Ruumba
|
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|
97
|
-
def copy_erb_files(
|
99
|
+
def copy_erb_files(fq_files_or_dirs, tmp, pwd)
|
98
100
|
extension = '.rb' unless @options[:disable_rb_extension]
|
99
101
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
102
|
+
fq_files_or_dirs.each do |fq_file_or_dir|
|
103
|
+
if fq_file_or_dir.file?
|
104
|
+
copy_erb_file(fq_file_or_dir, tmp, pwd, extension) if fq_file_or_dir.to_s.end_with?('.erb')
|
105
|
+
else
|
106
|
+
Dir["#{fq_file_or_dir}/**/*.erb"].each do |f|
|
107
|
+
copy_erb_file(f, tmp, pwd, extension)
|
108
|
+
end
|
107
109
|
end
|
108
110
|
end
|
109
111
|
end
|
110
112
|
|
113
|
+
def copy_erb_file(file, tmp, pwd, extension)
|
114
|
+
n = tmp + Pathname.new(file).relative_path_from(pwd)
|
115
|
+
FileUtils.mkdir_p(File.dirname(n))
|
116
|
+
|
117
|
+
File.open("#{n}#{extension}", 'w+') do |tmp_file|
|
118
|
+
code = extract(file)
|
119
|
+
tmp_file.write(code)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
111
123
|
def run_rubocop(target, tmp)
|
112
124
|
args = ['rubocop'] + (@options[:arguments] || []) + [target.to_s]
|
113
125
|
todo = tmp + '.rubocop_todo.yml'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruumba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Weinstein
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-04-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|