getclonedata 0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: da3abaebdbc7f5154ddf8d81e2224e9152427826
4
+ data.tar.gz: c2ff17229504b77aa1fa3e05ef75eb433e106c5c
5
+ SHA512:
6
+ metadata.gz: 378364cfda4ed03710efd27f1a31c019f089e884c92ba3747e9e9c3190cb90beae8147592bb5ad169f5001d2b9905ddbc719fbeae190b0ca0afbae788b6677c5
7
+ data.tar.gz: 38d20c6d9a7c4b1122edf1e1875434fb6863525c02183d3b6281c59cad39e17d2c3b912b811d168c79b0425cad12231cf6d1e58aead6b0e6a7fabdaad934d8c2
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ coverage/
2
+ cloned_repo_tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ AllCops:
3
+ TargetRubyVersion: 2.3
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.1
4
+ - 2.2
5
+ - 2.1
6
+ branches:
7
+ only:
8
+ - master
9
+ script: bundle exec rake spec
10
+ gemfile:
11
+ - Gemfile
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ getclonedata (0.1)
5
+ cloc (~> 0.9)
6
+ flay (~> 2.8)
7
+ flog (~> 4.4)
8
+ http (~> 2.1)
9
+ rubocop (~> 0.42)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ addressable (2.5.0)
15
+ public_suffix (~> 2.0, >= 2.0.2)
16
+ ast (2.3.0)
17
+ cloc (0.9.0)
18
+ docile (1.1.5)
19
+ domain_name (0.5.20161129)
20
+ unf (>= 0.0.5, < 1.0.0)
21
+ erubis (2.7.0)
22
+ flay (2.8.1)
23
+ erubis (~> 2.7.0)
24
+ path_expander (~> 1.0)
25
+ ruby_parser (~> 3.0)
26
+ sexp_processor (~> 4.0)
27
+ flog (4.4.0)
28
+ path_expander (~> 1.0)
29
+ ruby_parser (~> 3.1, > 3.1.0)
30
+ sexp_processor (~> 4.4)
31
+ http (2.1.0)
32
+ addressable (~> 2.3)
33
+ http-cookie (~> 1.0)
34
+ http-form_data (~> 1.0.1)
35
+ http_parser.rb (~> 0.6.0)
36
+ http-cookie (1.0.3)
37
+ domain_name (~> 0.5)
38
+ http-form_data (1.0.1)
39
+ http_parser.rb (0.6.0)
40
+ json (2.0.2)
41
+ minitest (5.10.1)
42
+ minitest-rg (5.2.0)
43
+ minitest (~> 5.0)
44
+ parser (2.3.3.1)
45
+ ast (~> 2.2)
46
+ path_expander (1.0.1)
47
+ powerpack (0.1.1)
48
+ public_suffix (2.0.4)
49
+ rainbow (2.1.0)
50
+ rake (11.3.0)
51
+ rubocop (0.46.0)
52
+ parser (>= 2.3.1.1, < 3.0)
53
+ powerpack (~> 0.1)
54
+ rainbow (>= 1.99.1, < 3.0)
55
+ ruby-progressbar (~> 1.7)
56
+ unicode-display_width (~> 1.0, >= 1.0.1)
57
+ ruby-progressbar (1.8.1)
58
+ ruby_parser (3.8.3)
59
+ sexp_processor (~> 4.1)
60
+ sexp_processor (4.7.0)
61
+ simplecov (0.12.0)
62
+ docile (~> 1.1.0)
63
+ json (>= 1.8, < 3)
64
+ simplecov-html (~> 0.10.0)
65
+ simplecov-html (0.10.0)
66
+ unf (0.1.4)
67
+ unf_ext
68
+ unf_ext (0.0.7.2)
69
+ unicode-display_width (1.1.2)
70
+
71
+ PLATFORMS
72
+ ruby
73
+
74
+ DEPENDENCIES
75
+ getclonedata!
76
+ minitest (~> 5.9)
77
+ minitest-rg (~> 5.2)
78
+ rake (~> 11.3)
79
+ simplecov (~> 0.12)
80
+
81
+ BUNDLED WITH
82
+ 1.13.6
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) Rubeasts <https://github.com/Rubeasts>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ ![CI](https://api.travis-ci.org/Rubeasts/git-clone.svg?branch=master)
2
+
3
+ # git-clone
4
+ Git Clone, quality script
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ require 'rake/testtask'
3
+
4
+ require_relative 'lib/getclonedata'
5
+
6
+ task default: :spec
7
+
8
+ Rake::TestTask.new(:spec) do |t|
9
+ t.pattern = 'spec/*_spec.rb'
10
+ t.warning = false
11
+ end
12
+
13
+ desc 'delete clone repository'
14
+ task :wipe do
15
+ GetCloneData::ClonedRepo.wipe
16
+ end
17
+
18
+ namespace :quality do
19
+ desc 'run all quality checks'
20
+ task all: [:rubocop, :flog, :flay]
21
+
22
+ task :flog do
23
+ sh 'flog lib/'
24
+ end
25
+
26
+ task :flay do
27
+ sh 'flay lib/'
28
+ end
29
+
30
+ task :rubocop do
31
+ sh 'rubocop'
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'getclonedata/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'getclonedata'
7
+ s.version = GetCloneData::VERSION
8
+
9
+ s.summary = 'Clone git repo and check the code quality using objective measure (flog, flay, rubocop)'
10
+ s.description = 'Extracts repository code quality'
11
+ s.authors = ['Renaud Jollet',
12
+ 'Nicholas Danks',
13
+ 'Sami Larrousi Tribek']
14
+ s.email = ['renaudjollet@neurow.org',
15
+ 'nicholasdanks@hotmail.com',
16
+ 'sami@slt.fr']
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- spec/*`.split("\n")
20
+
21
+ s.add_runtime_dependency 'http', '~> 2.1'
22
+ s.add_runtime_dependency 'flog', '~> 4.4'
23
+ s.add_runtime_dependency 'flay', '~> 2.8'
24
+ s.add_runtime_dependency 'rubocop', '~> 0.42'
25
+ s.add_runtime_dependency 'cloc', '~> 0.9'
26
+
27
+ s.add_development_dependency 'minitest', '~> 5.9'
28
+ s.add_development_dependency 'minitest-rg', '~> 5.2'
29
+ s.add_development_dependency 'rake', '~> 11.3'
30
+ s.add_development_dependency 'simplecov', '~> 0.12'
31
+
32
+ s.homepage = 'https://github.com/Rubeasts/gitget'
33
+ s.license = 'MIT'
34
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+ module GetCloneData
3
+ class ClonedRepo
4
+ CLONED_REPO_PATH = File.expand_path(
5
+ File.join(
6
+ File.dirname(__FILE__), '..', '..', 'cloned_repo_tmp'
7
+ )
8
+ )
9
+
10
+ attr_reader :flog, :flog, :flay, :rubocop, :loc
11
+
12
+ def initialize(repo_path:)
13
+ @repo_path = repo_path
14
+ @flog = get_flog_scores
15
+ @flay = get_flay_score
16
+ @rubocop = get_rubocop_errors
17
+ @loc = get_loc
18
+ wipe
19
+ end
20
+
21
+ def self.clone(git_url:)
22
+ repo_path = self.get_repo_path(git_url: git_url)
23
+ `git clone #{git_url} #{repo_path}`
24
+ return nil unless Dir.exists? repo_path
25
+ new(repo_path: repo_path)
26
+ end
27
+
28
+ def self.wipe
29
+ `rm -R -f #{CLONED_REPO_PATH}/*`
30
+ end
31
+
32
+ def wipe
33
+ `rm -R -f #{@repo_path}`
34
+ end
35
+
36
+ def self.get_repo_path(git_url:)
37
+ repository = git_url.gsub('.git','').split('/')[3,4]
38
+ File.expand_path(
39
+ File.join(
40
+ CLONED_REPO_PATH, repository[0], repository[1]
41
+ )
42
+ )
43
+ end
44
+
45
+ def get_flog_scores
46
+ if Dir.exist? @repo_path
47
+ flog_response = `flog #{@repo_path}`.split("\n")
48
+ .map { |item| item.split(":").first.to_f }
49
+ end
50
+ # reponse is an array of all the flog scores from total , ave, each method...
51
+ flog_response if flog_response
52
+ end
53
+
54
+ def get_flay_score
55
+ if Dir.exist? @repo_path
56
+ flay = `flay #{@repo_path}`.split("=").last.split("\n").first.to_f
57
+ end
58
+ flay if flay
59
+ end
60
+
61
+ def get_rubocop_errors
62
+ holder = Array.new()
63
+ if Dir.exist? @repo_path
64
+ rubocop_response = `rubocop #{@repo_path}`
65
+ holder << rubocop_response.split("\n").last.split("files").first.to_f
66
+ holder << rubocop_response.split("\n").last.split(",").last.split("offenses").first.to_f
67
+ end
68
+ # response is array [no. of files, no. of offenses]
69
+ holder
70
+ end
71
+
72
+ def get_loc
73
+ if Dir.exist? @repo_path
74
+ loc_response = `cloc #{@repo_path}`
75
+ if loc_response.empty?
76
+ loc_response = nil
77
+ else
78
+ loc_response = loc_response.split('SUM').last.split("\n").first
79
+ .split(' ')[2..5].map(&:to_f)
80
+ end
81
+ end
82
+ loc_response
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GetCloneData
4
+ VERSION = '0.1'
5
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ files = Dir.glob(File.join(File.dirname(__FILE__), 'getclonedata/*.rb'))
4
+ files.each { |lib| require_relative lib }
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'spec_helper'
4
+
5
+ describe 'Github specifications' do
6
+ before do
7
+ GetCloneData::ClonedRepo.wipe
8
+ @repository = GetCloneData::ClonedRepo.clone(git_url: HAPPY_GIT_URL)
9
+ @sad_repository = GetCloneData::ClonedRepo.clone(git_url: SAD_GIT_URL)
10
+ end
11
+
12
+ it 'SAD: should return nil for sad repository' do
13
+ @sad_repository.must_be_nil
14
+ end
15
+
16
+ it 'HAPPY: should not return nil for happy repository' do
17
+ @repository.must_be_instance_of GetCloneData::ClonedRepo
18
+ end
19
+
20
+ it 'HAPPY: should contain flog' do
21
+ @repository.flog.must_be_instance_of Array
22
+ end
23
+
24
+ it 'HAPPY: should contain flay' do
25
+ @repository.flay.must_be_instance_of Float
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ require 'minitest/autorun'
7
+ require 'minitest/rg'
8
+ require 'yaml'
9
+
10
+ require_relative '../lib/getclonedata'
11
+
12
+ HAPPY_GIT_URL = 'git://github.com/rjollet/DeepViz.git'
13
+ SAD_GIT_URL = 'git://github.com/notexistowner/notexistrepo.git'
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: getclonedata
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Renaud Jollet
8
+ - Nicholas Danks
9
+ - Sami Larrousi Tribek
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-12-16 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: http
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.1'
29
+ - !ruby/object:Gem::Dependency
30
+ name: flog
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '4.4'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '4.4'
43
+ - !ruby/object:Gem::Dependency
44
+ name: flay
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.8'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '2.8'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rubocop
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '0.42'
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '0.42'
71
+ - !ruby/object:Gem::Dependency
72
+ name: cloc
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '0.9'
78
+ type: :runtime
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '0.9'
85
+ - !ruby/object:Gem::Dependency
86
+ name: minitest
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '5.9'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '5.9'
99
+ - !ruby/object:Gem::Dependency
100
+ name: minitest-rg
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '5.2'
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '5.2'
113
+ - !ruby/object:Gem::Dependency
114
+ name: rake
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '11.3'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '11.3'
127
+ - !ruby/object:Gem::Dependency
128
+ name: simplecov
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - "~>"
132
+ - !ruby/object:Gem::Version
133
+ version: '0.12'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - "~>"
139
+ - !ruby/object:Gem::Version
140
+ version: '0.12'
141
+ description: Extracts repository code quality
142
+ email:
143
+ - renaudjollet@neurow.org
144
+ - nicholasdanks@hotmail.com
145
+ - sami@slt.fr
146
+ executables: []
147
+ extensions: []
148
+ extra_rdoc_files: []
149
+ files:
150
+ - ".gitignore"
151
+ - ".rubocop.yml"
152
+ - ".travis.yml"
153
+ - Gemfile
154
+ - Gemfile.lock
155
+ - LICENSE
156
+ - README.md
157
+ - Rakefile
158
+ - getclonedata.gemspec
159
+ - lib/getclonedata.rb
160
+ - lib/getclonedata/getclonedata_clonerepo.rb
161
+ - lib/getclonedata/version.rb
162
+ - spec/clonerepo_spec.rb
163
+ - spec/spec_helper.rb
164
+ homepage: https://github.com/Rubeasts/gitget
165
+ licenses:
166
+ - MIT
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ requirements: []
183
+ rubyforge_project:
184
+ rubygems_version: 2.5.1
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: Clone git repo and check the code quality using objective measure (flog,
188
+ flay, rubocop)
189
+ test_files:
190
+ - spec/clonerepo_spec.rb
191
+ - spec/spec_helper.rb