ruumba 0.1.8 → 0.1.9
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/lib/ruumba/analyzer.rb +21 -19
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a949f454dda6d68014119e30527eb824900dbff
|
4
|
+
data.tar.gz: aa63b8c9ba731414b631677867317da821cc0697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fb60b02318709d110ff0084f8faec5bb3e2c516e9b539066f752ca5adadf2632ee4315ab775cd2bab1b7977fff3f4e0ba2bea385482f6e2db7a19cc85dce8a3
|
7
|
+
data.tar.gz: 80f78791ab4b9033b10373e8d95ad9591e5386ab7a68e447c1fbf9b5f4a58f49b4a2ab49e63b1772de9e0e237d1f1deaf1f24bebd3d4f91337ddb01cfdc9c4f5
|
data/lib/ruumba/analyzer.rb
CHANGED
@@ -22,6 +22,22 @@ module Ruumba
|
|
22
22
|
# Performs static analysis on the provided directory.
|
23
23
|
# @param [Array<String>] dir The directories / files to analyze.
|
24
24
|
def run(files_or_dirs = ARGV)
|
25
|
+
if options[:tmp_folder]
|
26
|
+
analyze(File.expand_path(options[:tmp_folder]), files_or_dirs)
|
27
|
+
else
|
28
|
+
Dir.mktmpdir do |dir|
|
29
|
+
analyze(dir, files_or_dirs)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :options
|
37
|
+
|
38
|
+
def analyze(temp_dir, files_or_dirs)
|
39
|
+
temp_dir_path = Pathname.new(temp_dir)
|
40
|
+
|
25
41
|
iterator =
|
26
42
|
if stdin?
|
27
43
|
Iterators::StdinIterator.new(stdin_filename)
|
@@ -30,16 +46,12 @@ module Ruumba
|
|
30
46
|
end
|
31
47
|
|
32
48
|
iterator.each do |file, contents|
|
33
|
-
copy_erb_file(file, contents)
|
49
|
+
copy_erb_file(file, contents, temp_dir_path)
|
34
50
|
end
|
35
51
|
|
36
|
-
RubocopRunner.new(arguments, pwd,
|
52
|
+
RubocopRunner.new(arguments, pwd, temp_dir_path, !disable_rb_extension?).execute
|
37
53
|
end
|
38
54
|
|
39
|
-
private
|
40
|
-
|
41
|
-
attr_reader :options
|
42
|
-
|
43
55
|
def extension
|
44
56
|
'.rb' unless disable_rb_extension?
|
45
57
|
end
|
@@ -64,24 +76,14 @@ module Ruumba
|
|
64
76
|
@pwd ||= Pathname.new(ENV['PWD'])
|
65
77
|
end
|
66
78
|
|
67
|
-
def temp_dir
|
68
|
-
@temp_dir ||= begin
|
69
|
-
if options[:tmp_folder]
|
70
|
-
Pathname.new(File.expand_path(options[:tmp_folder]))
|
71
|
-
else
|
72
|
-
Pathname.new(Dir.mktmpdir)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
79
|
def parser
|
78
80
|
@parser ||= Parser.new
|
79
81
|
end
|
80
82
|
|
81
|
-
def copy_erb_file(file, contents)
|
83
|
+
def copy_erb_file(file, contents, temp_dir)
|
82
84
|
code = parser.extract(contents)
|
83
85
|
|
84
|
-
n = temp_filename_for(file)
|
86
|
+
n = temp_filename_for(file, temp_dir)
|
85
87
|
FileUtils.mkdir_p(File.dirname(n))
|
86
88
|
|
87
89
|
File.open(n, 'w+') do |tmp_file|
|
@@ -89,7 +91,7 @@ module Ruumba
|
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
92
|
-
def temp_filename_for(file)
|
94
|
+
def temp_filename_for(file, temp_dir)
|
93
95
|
name = temp_dir.join(Pathname.new(file).relative_path_from(pwd))
|
94
96
|
|
95
97
|
"#{name}#{extension}"
|