ruby-watchr 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/watchr/analyse.rb +3 -3
- data/lib/watchr/metrics/flog/class_report_factory.rb +4 -6
- data/lib/watchr/paths.rb +5 -7
- data/lib/watchr/version.rb +1 -1
- data/spec/watchr/paths_spec.rb +10 -2
- metadata +3 -3
data/lib/watchr/analyse.rb
CHANGED
@@ -21,18 +21,18 @@ module Watchr
|
|
21
21
|
# @param {String} Path to code folders.
|
22
22
|
#
|
23
23
|
def initialize(path)
|
24
|
-
files = Paths.files_by_dirs(path)
|
24
|
+
files = Paths.files_by_dirs(['rb'], path)
|
25
25
|
|
26
26
|
# Flay essentially cant be done on file level because its first class
|
27
27
|
# citizen is duplication of code between files. Its done once for all
|
28
28
|
# the files in the analyse and results are injected to the proper file
|
29
29
|
# later.
|
30
|
-
flay = Watchr::FlayMetric::Report.new(files)
|
30
|
+
# flay = Watchr::FlayMetric::Report.new(files)
|
31
31
|
|
32
32
|
# Create report for each file.
|
33
33
|
@files = files.map do |file|
|
34
34
|
Watchr::FileAnalyse.new(file).tap { |file|
|
35
|
-
file.flay(flay.duplications_by_file(file))
|
35
|
+
# file.flay(flay.duplications_by_file(file))
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
@@ -11,12 +11,10 @@ module Watchr
|
|
11
11
|
methods.each do |name, score|
|
12
12
|
next if name =~ /#none/
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
)
|
19
|
-
)
|
14
|
+
method_location = method_locations[name]
|
15
|
+
location = method_location ? Location.from_path(method_location) : nil
|
16
|
+
|
17
|
+
clazz.add_method(FlogReportMethod.new(clazz, name, score, location))
|
20
18
|
end
|
21
19
|
|
22
20
|
clazz
|
data/lib/watchr/paths.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
module Watchr
|
2
2
|
module Paths
|
3
|
-
def self.files_by_dirs *dirs
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
if File.directory? p then
|
8
|
-
Dir[File.join(p, '**', "*.{#{extensions.join(',')}}")]
|
3
|
+
def self.files_by_dirs(extensions, *dirs)
|
4
|
+
dirs.flatten.map { |dir|
|
5
|
+
if File.directory?(dir) then
|
6
|
+
Dir[File.join(dir, '**', "*.{#{extensions.join(',')}}")]
|
9
7
|
else
|
10
|
-
|
8
|
+
dir
|
11
9
|
end
|
12
10
|
}.flatten.sort
|
13
11
|
end
|
data/lib/watchr/version.rb
CHANGED
data/spec/watchr/paths_spec.rb
CHANGED
@@ -3,9 +3,17 @@ require 'watchr/paths'
|
|
3
3
|
|
4
4
|
describe Watchr::Paths do
|
5
5
|
describe '.files_by_dirs' do
|
6
|
+
context 'single folder' do
|
7
|
+
subject { Watchr::Paths.files_by_dirs(['rb'], 'spec/fixtures/') }
|
6
8
|
|
7
|
-
|
9
|
+
it { should include('spec/fixtures/class.rb') }
|
10
|
+
end
|
8
11
|
|
9
|
-
|
12
|
+
context 'multiple folders' do
|
13
|
+
subject { Watchr::Paths.files_by_dirs(['rb'], 'spec/fixtures/', 'lib/') }
|
14
|
+
|
15
|
+
it { should include('lib/watchr.rb') }
|
16
|
+
it { should include('spec/fixtures/class.rb') }
|
17
|
+
end
|
10
18
|
end
|
11
19
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 5
|
9
|
+
version: 0.3.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Petr Janda
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-08-
|
17
|
+
date: 2012-08-15 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|