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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ruumba +4 -0
  3. data/lib/ruumba/analyzer.rb +26 -14
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6dac9e89072fdc292ff6b27e3dc56819de54bf32
4
- data.tar.gz: d6ccb5c317fce4fab35217342f74d0b5b7d9dc28
3
+ metadata.gz: 783240f5de7ece2a461ceb69ffb488e5a826de0c
4
+ data.tar.gz: 23b7ecd5efc3b4f83659625d098ac84b95dfbf26
5
5
  SHA512:
6
- metadata.gz: bd112afb8c479393c8ccaea51335556c1dcd20d4aef38ed9e4a40af0a8ad0e312ee9ae3a1ebd7774e17f13d486dc7499b7c16c32f94cfd177c6d0e58eee1ade9
7
- data.tar.gz: de19904ab69576c0d6de90155ae0e1363752e4efc9554dfa48aa1f0fb575a0d9c8c58fd37ab7d0b8655f77171464de5ef6e4ba2da8fe657fd28bf2f053197db4
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
@@ -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 directory to analyze.
23
- def run(dir = ARGV)
24
- fq_dir = Pathname.new(File.expand_path(dir.first))
25
- pwd = Pathname.new ENV['PWD']
26
- target = fq_dir.relative_path_from(pwd)
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(fq_dir, tmp, pwd)
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(fq_dir, tmp, pwd)
99
+ def copy_erb_files(fq_files_or_dirs, tmp, pwd)
98
100
  extension = '.rb' unless @options[:disable_rb_extension]
99
101
 
100
- Dir["#{fq_dir}/**/*.erb"].each do |f|
101
- n = tmp + Pathname.new(f).relative_path_from(pwd)
102
- FileUtils.mkdir_p(File.dirname(n))
103
-
104
- File.open("#{n}#{extension}", 'w+') do |file|
105
- code = extract f
106
- file.write code
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
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-03-19 00:00:00.000000000 Z
13
+ date: 2018-04-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop