getclonedata 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40a0d5c6633ff4dd9ba068b15e71c64b67463531
4
- data.tar.gz: fcc1023787feda5b83fcbeeecb8d5bbf3039b966
3
+ metadata.gz: c11f4f5f885c086c29a337d67533efaaec59e070
4
+ data.tar.gz: ac4e3c9ebb61812849ada701250ab8553bcc0038
5
5
  SHA512:
6
- metadata.gz: dfe5e85353ab7b6a4e05bc211aef1f2f65ee0ae82b4785389c6fe04898cc382b3cec93e2c047a3dbe98474efe29a8d4191631dd62eb406a75712fbe4089cf6d2
7
- data.tar.gz: bf2a0a6ae31207d6cf2aa2e2bb6fef1f61f222d9e70ae4f9e8db4bca5ae20462502328a27a48b757fb0be08afd9c13df2bc208b22554c3c5d95937b033b857ba
6
+ metadata.gz: 609ecc2d8b5ceab9257fc0920050169634ad6e48a5d367f04f645ca8653cc8ed06b37a8c84edc1d0a808a74f0c7bcd2bacc694e6ba6be2d0d6729755e366f999
7
+ data.tar.gz: fbc527f85bb3c85eef7c3f96891e71327e41cb4715f79fce481c362257dc2364acd33a6befe8b2a430d941f4cbd818f6c46fcf104d7fa33c6c8322977b2a1b51
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- getclonedata (0.2.1)
4
+ getclonedata (0.3.0)
5
5
  cloc (~> 0.9)
6
6
  flay (~> 2.8)
7
7
  flog (~> 4.4)
@@ -9,7 +9,7 @@ module GetCloneData
9
9
 
10
10
  @@itt = 0
11
11
 
12
- attr_reader :flog, :flog, :flay, :rubocop, :loc
12
+ attr_reader :flog, :flog, :flay, :rubocop, :loc, :ruby_files
13
13
 
14
14
  def initialize(repo_path:)
15
15
  @repo_path = repo_path
@@ -44,10 +44,24 @@ module GetCloneData
44
44
  @@itt
45
45
  end
46
46
 
47
+ def ruby_files
48
+ return @ruby_files if @ruby_files
49
+
50
+ path_rb_expander = PathExpander.new [@repo_path], "**/*.{rb,rake}"
51
+ @ruby_files = path_rb_expander.process
52
+ @ruby_files
53
+ end
54
+
47
55
  def get_flog_scores
48
56
  if Dir.exist? @repo_path
49
- flog_response = `flog #{@repo_path}`.split("\n")
50
- .map { |item| item.split(":").first.to_f }
57
+ flog = Flog.new
58
+ flog.flog(*ruby_files)
59
+ #flog.calculate_total_score
60
+ flog_response = {
61
+ total_score: flog.total_score,
62
+ max_score: flog.max_score,
63
+ average: flog.average
64
+ }
51
65
  end
52
66
  # reponse is an array of all the flog scores from total , ave, each method...
53
67
  flog_response if flog_response
@@ -55,20 +69,20 @@ module GetCloneData
55
69
 
56
70
  def get_flay_score
57
71
  if Dir.exist? @repo_path
58
- flay = `flay #{@repo_path}`.split("=").last.split("\n").first.to_f
72
+ flay = Flay.new
73
+ flay.process(*ruby_files)
74
+ flay.analyze
75
+ flay = flay.summary.values.first
59
76
  end
60
77
  flay if flay
61
78
  end
62
79
 
63
80
  def get_rubocop_errors
64
- holder = Array.new()
65
81
  if Dir.exist? @repo_path
66
- rubocop_response = `rubocop #{@repo_path}`
67
- holder << rubocop_response.split("\n").last.split("files").first.to_f
68
- holder << rubocop_response.split("\n").last.split(",").last.split("offenses").first.to_f
82
+ rubocop_response = `rubocop #{@repo_path} --format json`
83
+ summary = JSON.parse(rubocop_response, :symbolize_names => true)[:summary]
84
+ summary
69
85
  end
70
- # response is array [no. of files, no. of offenses]
71
- holder
72
86
  end
73
87
 
74
88
  def get_loc
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GetCloneData
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/getclonedata.rb CHANGED
@@ -1,4 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
4
+ require 'flog'
5
+ require 'flay'
6
+ require 'path_expander'
7
+
3
8
  files = Dir.glob(File.join(File.dirname(__FILE__), 'getclonedata/*.rb'))
4
9
  files.each { |lib| require_relative lib }
@@ -18,10 +18,24 @@ describe 'Github specifications' do
18
18
  end
19
19
 
20
20
  it 'HAPPY: should contain flog' do
21
- @repository.get_flog_scores.must_be_instance_of Array
21
+ flog = {
22
+ total_score: 407.33109526582183,
23
+ max_score: 142.57356872856903,
24
+ average: 31.333161174293988
25
+ }
26
+ @repository.get_flog_scores.must_equal flog
22
27
  end
23
28
 
24
29
  it 'HAPPY: should contain flay' do
25
30
  @repository.get_flay_score.must_be_instance_of Float
26
31
  end
32
+
33
+ it 'HAPPY: should contain rubocop summary' do
34
+ summary = {
35
+ offense_count: 578,
36
+ target_file_count: 6,
37
+ inspected_file_count: 6
38
+ }
39
+ @repository.get_rubocop_errors.must_equal summary
40
+ end
27
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getclonedata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renaud Jollet
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-12-19 00:00:00.000000000 Z
13
+ date: 2016-12-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http