language-usage-charts 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +53 -0
- data/.travis.yml +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +7 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/generate_usage_chart +24 -0
- data/bin/setup +8 -0
- data/language_usage_charts.gemspec +16 -0
- data/lib/language_usage_graphics.rb +35 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ad83c38803901abb10cfef72315ed4088c25454bc04ba413e3b3a0b113812146
|
4
|
+
data.tar.gz: 9be18391cbbeb0f1693c5e972f8a56e136a2572b020f3ba4f5a57ff80b7363d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db2e99ed172e8acebf876852b59876d7438234bf6334ac8ee4666c6884f8e5440dad6ed9da0ae75f9b17f97fac9e09ef0620a11062bfd2817e99aa4474c3b8e9
|
7
|
+
data.tar.gz: f248a28e31b34b2be042582ecca96aa9b4d39d8ec9503903e0011ccd635b8c0a287f452650958e913061d0a21b3ae36b5c6379af0eff05c15fc76782a2b9a9c2
|
data/.gitignore
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2019 Sasha Elaine Fox
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Language Usage Charts
|
2
|
+
|
3
|
+
## What is this project?
|
4
|
+
|
5
|
+
This project started life as a way to add Github language usage-esque
|
6
|
+
graphics to an independent CI/CD pipeline.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
### System Dependencies
|
11
|
+
|
12
|
+
This package relies on Github Linguist which in turn relies on `charlock_holmes`
|
13
|
+
and `rugged`. These dependencies require _quite_ a few system packages to work
|
14
|
+
properly.
|
15
|
+
|
16
|
+
If you're using a Debian variant distro all dependencies can be installed via:
|
17
|
+
|
18
|
+
```shell
|
19
|
+
sudo apt-get install cmake pkg-config libicu-dev zlib1g-dev libcurl4-openssl-dev libssl-dev ruby-dev
|
20
|
+
```
|
21
|
+
|
22
|
+
### Package installation
|
23
|
+
|
24
|
+
From the project root directory (the one containing the `.gempspec` file)
|
25
|
+
run the following command.
|
26
|
+
|
27
|
+
```shell
|
28
|
+
bundle exec rake install
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
Once things have been installed with bundle language usage charts can be generated
|
34
|
+
from anywhere using `generate_usage_chart $OPTS`. The following options are
|
35
|
+
supported.
|
36
|
+
|
37
|
+
| Option | Usage | Example |
|
38
|
+
|---------------|-----------------------------------|---------------------|
|
39
|
+
| `-r`. `--repo`| Path to a git repository. | "." |
|
40
|
+
| `-o`, `--out` | Path where usage chart should go. | "./usage_chart.png" |
|
41
|
+
|
42
|
+
Example usage:
|
43
|
+
|
44
|
+
```shell
|
45
|
+
generate_usage_chart -r "." -o "./language_usage_chart.png"
|
46
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "language_usage_graphics"
|
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__)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
require 'rugged'
|
7
|
+
require 'linguist'
|
8
|
+
require 'gruff'
|
9
|
+
|
10
|
+
require 'language_usage_graphics'
|
11
|
+
|
12
|
+
options = OpenStruct.new
|
13
|
+
OptionParser.new do |opt|
|
14
|
+
opt.on('-r', '--repo REPO', 'Path to a git repository.') { |o| options.repo = o }
|
15
|
+
opt.on('-o', '--out OUT', 'Path where the resulting usage chart should go.') { |o| options.out = o }
|
16
|
+
end.parse!
|
17
|
+
|
18
|
+
repo = Rugged::Repository.new(options.repo)
|
19
|
+
project = Linguist::Repository.new( repo, repo.head.target_id )
|
20
|
+
|
21
|
+
normalized_scores = LanguageUsageCharts.normalize_scores( project.languages )
|
22
|
+
|
23
|
+
graph = LanguageUsageCharts.render_language_breakdown( normalized_scores )
|
24
|
+
graph.write( options.out )
|
data/bin/setup
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'language-usage-charts'
|
3
|
+
s.version = '0.1.0'
|
4
|
+
s.date = '2019-03-18'
|
5
|
+
s.summary = "Stand alone language usage charts."
|
6
|
+
s.description = "Display break-down of programming language usage in a git repo."
|
7
|
+
s.authors = ["Sasha Fox"]
|
8
|
+
s.email = 'sashanullptr@gmail.com'
|
9
|
+
s.files = `git ls-files`.split($\)
|
10
|
+
s.license = 'MIT'
|
11
|
+
s.executables = ["generate_usage_chart"]
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.add_runtime_dependency 'rugged', '~> 0.28', '>= 0.28.1'
|
14
|
+
s.add_runtime_dependency 'github-linguist', '~> 7.3', '>= 7.3.1'
|
15
|
+
s.add_runtime_dependency 'gruff', '~> 0.7', '>= 0.7.0'
|
16
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'gruff'
|
2
|
+
|
3
|
+
module LanguageUsageCharts
|
4
|
+
def self.render_language_breakdown( scores )
|
5
|
+
# Render a Pie Chart using normalized Linguist statistics.
|
6
|
+
|
7
|
+
graph = Gruff::SideStackedBar.new('800x300')
|
8
|
+
graph.title = "Language Breakdown"
|
9
|
+
|
10
|
+
# Graph lavels *must* be defined, however we do not want any labels displayed,
|
11
|
+
# so we set the label for the zero'th bar to nil.
|
12
|
+
graph.labels = {0=>nil}
|
13
|
+
|
14
|
+
scores.each do |k,v|
|
15
|
+
percent = (v*100)
|
16
|
+
label = k + " " + (percent.round(1)).to_s + "%"
|
17
|
+
graph.data( label, percent )
|
18
|
+
end
|
19
|
+
|
20
|
+
graph.sort = true
|
21
|
+
graph
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.normalize_scores( languages )
|
25
|
+
# By default Linguist produces language usage statistics as a dictionary
|
26
|
+
# which takes the following form:
|
27
|
+
# :"Language Name" => Total number of characters written in language.
|
28
|
+
# This function produces a new dictionary with the following form:
|
29
|
+
# :"Language Name" => Fraction of repository written in language.
|
30
|
+
|
31
|
+
num_chars = languages.values.reduce(:+)
|
32
|
+
total_chars = num_chars.to_f
|
33
|
+
languages.inject({}) { |h,(k,v)| h[k] = v/total_chars; h }
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: language-usage-charts
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sasha Fox
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rugged
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.28'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.28.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.28'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.28.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: github-linguist
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '7.3'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 7.3.1
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '7.3'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 7.3.1
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: gruff
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.7'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.7.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.7'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 0.7.0
|
73
|
+
description: Display break-down of programming language usage in a git repo.
|
74
|
+
email: sashanullptr@gmail.com
|
75
|
+
executables:
|
76
|
+
- generate_usage_chart
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- ".gitignore"
|
81
|
+
- ".travis.yml"
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/generate_usage_chart
|
88
|
+
- bin/setup
|
89
|
+
- language_usage_charts.gemspec
|
90
|
+
- lib/language_usage_graphics.rb
|
91
|
+
homepage:
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.7.6
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Stand alone language usage charts.
|
115
|
+
test_files: []
|