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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ruumba/analyzer.rb +21 -19
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e872de735275d0028c5eff6a16f5c980654955c2
4
- data.tar.gz: 5a3ec8e413c08e48c449bc7728dce779a988f8d3
3
+ metadata.gz: 6a949f454dda6d68014119e30527eb824900dbff
4
+ data.tar.gz: aa63b8c9ba731414b631677867317da821cc0697
5
5
  SHA512:
6
- metadata.gz: f2fbbe3e7abc9861f7b5d866b405cec8c0ab7c919561b25b380bcdb27fa311764fe6042050aab1e25b9dc02ba6d6d1fc626e0e7666b06d0ebbb0306ab1ce60ef
7
- data.tar.gz: f4dd9454af010fb43428af7edc584e9c23cfd3f757caff780245031bd0192c135bf65ce7b5f083dea239005f607eefb7ad5c47f9ee55e65d0c447eb423d3abc2
6
+ metadata.gz: 8fb60b02318709d110ff0084f8faec5bb3e2c516e9b539066f752ca5adadf2632ee4315ab775cd2bab1b7977fff3f4e0ba2bea385482f6e2db7a19cc85dce8a3
7
+ data.tar.gz: 80f78791ab4b9033b10373e8d95ad9591e5386ab7a68e447c1fbf9b5f4a58f49b4a2ab49e63b1772de9e0e237d1f1deaf1f24bebd3d4f91337ddb01cfdc9c4f5
@@ -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, temp_dir, !disable_rb_extension?).execute
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}"
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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Weinstein