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.
@@ -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
- clazz.add_method(
15
- FlogReportMethod.new(
16
- clazz, name, score,
17
- Location.from_path(method_locations[name])
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
- extensions = ['rb']
5
-
6
- dirs.flatten.map { |p|
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
- p
8
+ dir
11
9
  end
12
10
  }.flatten.sort
13
11
  end
@@ -1,3 +1,3 @@
1
1
  module Watchr
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -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
- subject { Watchr::Paths.files_by_dirs('spec/fixtures/') }
9
+ it { should include('spec/fixtures/class.rb') }
10
+ end
8
11
 
9
- it { should include('spec/fixtures/class.rb') }
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
- - 4
9
- version: 0.3.4
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-13 00:00:00 +02:00
17
+ date: 2012-08-15 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency