gitpoint 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +63 -0
- data/README.md +33 -0
- data/Rakefile +3 -0
- data/bin/console +14 -0
- data/bin/gitpoint +16 -0
- data/bin/setup +8 -0
- data/gitpoint.gemspec +30 -0
- data/lib/gitpoint.rb +8 -0
- data/lib/gitpoint/app.rb +62 -0
- data/lib/gitpoint/git.rb +40 -0
- data/lib/gitpoint/version.rb +3 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 935ec109d2c31bb2cb3334f9f5e716eb45c51c59
|
4
|
+
data.tar.gz: c06b1e5213de365831f5145294af65c2ed54b022
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 28243f425c9a2371fe1cace03b1221103349111b45e01796e6322326e913d576fa648f3343212cfc740a2db46e7ee8da121dd5d05cfad316068d86a2fdcc6c6a
|
7
|
+
data.tar.gz: 1e17762811c17add28a9eab9d3f3e33113b652390ef0e2954d20f8ec93b3add2fa01aa13678caffa9bc1cf009564ab678c2b7f73c3526317df4e91f129f2d8c2
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gitpoint (0.1.4)
|
5
|
+
activesupport (~> 5.1.5)
|
6
|
+
github_api (~> 0.18.2)
|
7
|
+
rainbow (~> 3.0)
|
8
|
+
thor (~> 0.19.1)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (5.1.5)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
+
i18n (~> 0.7)
|
16
|
+
minitest (~> 5.1)
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
addressable (2.5.2)
|
19
|
+
public_suffix (>= 2.0.2, < 4.0)
|
20
|
+
concurrent-ruby (1.0.5)
|
21
|
+
descendants_tracker (0.0.4)
|
22
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
23
|
+
faraday (0.12.2)
|
24
|
+
multipart-post (>= 1.2, < 3)
|
25
|
+
github_api (0.18.2)
|
26
|
+
addressable (~> 2.4)
|
27
|
+
descendants_tracker (~> 0.0.4)
|
28
|
+
faraday (~> 0.8)
|
29
|
+
hashie (~> 3.5, >= 3.5.2)
|
30
|
+
oauth2 (~> 1.0)
|
31
|
+
hashie (3.5.7)
|
32
|
+
i18n (0.9.5)
|
33
|
+
concurrent-ruby (~> 1.0)
|
34
|
+
jwt (1.5.6)
|
35
|
+
minitest (5.11.3)
|
36
|
+
multi_json (1.13.1)
|
37
|
+
multi_xml (0.6.0)
|
38
|
+
multipart-post (2.0.0)
|
39
|
+
oauth2 (1.4.0)
|
40
|
+
faraday (>= 0.8, < 0.13)
|
41
|
+
jwt (~> 1.0)
|
42
|
+
multi_json (~> 1.3)
|
43
|
+
multi_xml (~> 0.5)
|
44
|
+
rack (>= 1.2, < 3)
|
45
|
+
public_suffix (3.0.2)
|
46
|
+
rack (2.0.4)
|
47
|
+
rainbow (3.0.0)
|
48
|
+
rake (10.5.0)
|
49
|
+
thor (0.19.4)
|
50
|
+
thread_safe (0.3.6)
|
51
|
+
tzinfo (1.2.5)
|
52
|
+
thread_safe (~> 0.1)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
bundler (~> 1.16)
|
59
|
+
gitpoint!
|
60
|
+
rake (~> 10.0)
|
61
|
+
|
62
|
+
BUNDLED WITH
|
63
|
+
1.16.0
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Gitpoint
|
2
|
+
|
3
|
+
Gitpoint is a simple command line app that displays usage statistics for organizations repos. Then main purpose of the gem is to fetch and analyze repository information, such as the programming languages used on the organization and the rate of usage, relative to each other.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
|
8
|
+
Install app from rubygems:
|
9
|
+
|
10
|
+
$ gem install gitpoint
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Langstats
|
15
|
+
|
16
|
+
The initial feature, implemented on Gitpoint, is langstats. Langstats provides a list of programming languages used on a given organization's public repositories. Langstats provides, also, a relative percentage of usage per language for the organization.
|
17
|
+
|
18
|
+
To extract the above information, pass the name of the organization, to --organization parameter, as below:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gitpoint langstats --organization <organization_name>
|
22
|
+
```
|
23
|
+
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kkalpakloglou/gitpoint.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gitpoint"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/gitpoint
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
gem_path = (Pathname.new(__FILE__).dirname + '..').expand_path
|
5
|
+
source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
|
6
|
+
|
7
|
+
ENV["BUNDLE_GEMFILE"] = gem_path.to_s << "/Gemfile"
|
8
|
+
|
9
|
+
$LOAD_PATH << source_path
|
10
|
+
|
11
|
+
require 'bundler/setup'
|
12
|
+
|
13
|
+
require 'gitpoint'
|
14
|
+
|
15
|
+
GITPOINT::App.start
|
16
|
+
|
data/bin/setup
ADDED
data/gitpoint.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "gitpoint/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gitpoint"
|
8
|
+
spec.version = Gitpoint::VERSION
|
9
|
+
spec.platform = Gem::Platform::RUBY
|
10
|
+
spec.authors = ["Konstantinos Kalpakloglou"]
|
11
|
+
spec.email = ["kkalpakloglou@yahoo.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{A Simple command line app to search git repos and fetch language stats.}
|
14
|
+
spec.description = %q{A Simple command line app to search git repos and fetch language statistics.}
|
15
|
+
spec.homepage = ""
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = "bin"
|
22
|
+
spec.executables = ['gitpoint']
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_dependency 'thor', '~> 0.19.1'
|
27
|
+
spec.add_dependency 'rainbow', '~> 3.0'
|
28
|
+
spec.add_dependency 'github_api', '~> 0.18.2'
|
29
|
+
spec.add_dependency "activesupport", "~> 5.1.5"
|
30
|
+
end
|
data/lib/gitpoint.rb
ADDED
data/lib/gitpoint/app.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
module GITPOINT
|
2
|
+
class App < Thor
|
3
|
+
|
4
|
+
desc "langStats --organization", "Returns git repos language statistics for a given organization"
|
5
|
+
method_option :organization, type: :string, required: true
|
6
|
+
def langstats
|
7
|
+
|
8
|
+
# Fetch Repositories of Organization
|
9
|
+
say Rainbow("Connecting to github & fetching organization\'s repos...").bright
|
10
|
+
repos = Git.new.fetch(:all, {org: options[:organization], visibility: 'public'})
|
11
|
+
if repos[:status] == 200
|
12
|
+
say Rainbow("Organization\'s repos fetched successfully!").green
|
13
|
+
else
|
14
|
+
say Rainbow("Something went wrong!").red
|
15
|
+
raise Error, Rainbow(repos[:error_message]).red
|
16
|
+
end
|
17
|
+
|
18
|
+
@repositories = repos[:response]
|
19
|
+
raise Error, Rainbow("Github API response is empty! Process cannot continue").red if @repositories.nil?
|
20
|
+
|
21
|
+
fetch_repository_names
|
22
|
+
|
23
|
+
# Fetch Languages used per repository
|
24
|
+
@languages = []
|
25
|
+
|
26
|
+
say Rainbow("Fetching repos\'s languages...").bright
|
27
|
+
@repository_names.each do |repo|
|
28
|
+
repo_languages = Git.new.fetch(:list_languages, {user: options[:organization], repo: repo})
|
29
|
+
if repo_languages[:status] == 200
|
30
|
+
@languages << repo_languages[:response].keys unless repo_languages[:response].nil?
|
31
|
+
else
|
32
|
+
say Rainbow("Something went wrong!").red
|
33
|
+
raise Error, Rainbow(repos[:error_message]).red
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
say Rainbow("Computng results...").bright
|
38
|
+
calculate_language_appearance
|
39
|
+
|
40
|
+
# Print Results to User
|
41
|
+
results = {
|
42
|
+
"organization" => options[:organization],
|
43
|
+
"languages" => Hash[@language_hash.sort_by {|k, v| -v}]
|
44
|
+
}
|
45
|
+
|
46
|
+
say Rainbow(JSON.pretty_generate(results)).green
|
47
|
+
end
|
48
|
+
|
49
|
+
no_commands do
|
50
|
+
private
|
51
|
+
def calculate_language_appearance
|
52
|
+
flat_array_of_languages = @languages.flatten
|
53
|
+
@language_hash = flat_array_of_languages.group_by {|e| e}.inject({}) {|h, (k,v)| h.merge!(k => (v.count / flat_array_of_languages.count.to_f).round(2))}
|
54
|
+
end
|
55
|
+
|
56
|
+
def fetch_repository_names
|
57
|
+
@repository_names = @repositories.map(&:name).to_a
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/lib/gitpoint/git.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module GITPOINT
|
2
|
+
class Git < Thor
|
3
|
+
def initialize
|
4
|
+
@@git ||= Github.new basic_auth: basic_authentication
|
5
|
+
end
|
6
|
+
|
7
|
+
no_commands do
|
8
|
+
|
9
|
+
def fetch(method_name, options = {})
|
10
|
+
status, response, error_message = nil
|
11
|
+
begin
|
12
|
+
response = @@git.repos.public_send(method_name, options)
|
13
|
+
status = response.headers.status
|
14
|
+
rescue Github::Error::GithubError => e
|
15
|
+
if e.is_a? Github::Error::ServiceError
|
16
|
+
# handle GitHub service errors such as 404
|
17
|
+
error_message = "A Service Error occured! \n #{e.message}"
|
18
|
+
elsif e.is_a? Github::Error::ClientError
|
19
|
+
# handle client errors e.i. missing required parameter in request
|
20
|
+
error_message = "A Client Error occured! \n #{e.message}"
|
21
|
+
else
|
22
|
+
error_message = "An unknown error occured!"
|
23
|
+
end
|
24
|
+
rescue => e
|
25
|
+
error_message = "An internal Error occured! \n #{e}"
|
26
|
+
end
|
27
|
+
return {response: response, status: status, error_message: error_message}
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def basic_authentication
|
32
|
+
if ENV['gihub_login'].present? && ENV['gihub_password'].present?
|
33
|
+
return [ENV['gihub_login'], ENV['gihub_password']].join(":")
|
34
|
+
else
|
35
|
+
return nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitpoint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantinos Kalpakloglou
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.19.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.19.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rainbow
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: github_api
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.18.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.18.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activesupport
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 5.1.5
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 5.1.5
|
97
|
+
description: A Simple command line app to search git repos and fetch language statistics.
|
98
|
+
email:
|
99
|
+
- kkalpakloglou@yahoo.com
|
100
|
+
executables:
|
101
|
+
- gitpoint
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- Gemfile
|
106
|
+
- Gemfile.lock
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- bin/console
|
110
|
+
- bin/gitpoint
|
111
|
+
- bin/setup
|
112
|
+
- gitpoint.gemspec
|
113
|
+
- lib/gitpoint.rb
|
114
|
+
- lib/gitpoint/app.rb
|
115
|
+
- lib/gitpoint/git.rb
|
116
|
+
- lib/gitpoint/version.rb
|
117
|
+
homepage: ''
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.5.2
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: A Simple command line app to search git repos and fetch language stats.
|
141
|
+
test_files: []
|