github_scouter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +37 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +2 -0
- data/bin/github_scouter +6 -0
- data/github_scouter.gemspec +25 -0
- data/lib/github_scouter.rb +125 -0
- data/lib/github_scouter/version.rb +3 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 31e30de434b51fe4e0fb8c97dd2c0d4afaa63512
|
4
|
+
data.tar.gz: f3caaf4348900245c7b312d3fd140e799f4990e6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 05f46ed34f95f6e107696cf78fdb4c9938999b9355099ff4b974d3c611993af3e6cd3d864cc3c03aad36fcb96c955631ee81ce40d95dec931284f665da554c7a
|
7
|
+
data.tar.gz: 97b58af47664b40218abcc6f98f64f95fc1815830c476e5009d924b2e91cdf851086861badd9e5f727ac6111319b7f6d8f3d7ae2e535a371c1e588889cc5b719
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Created by https://www.gitignore.io
|
2
|
+
|
3
|
+
### Ruby ###
|
4
|
+
*.gem
|
5
|
+
*.rbc
|
6
|
+
/.config
|
7
|
+
/coverage/
|
8
|
+
/InstalledFiles
|
9
|
+
/pkg/
|
10
|
+
/spec/reports/
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
|
15
|
+
## Specific to RubyMotion:
|
16
|
+
.dat*
|
17
|
+
.repl_history
|
18
|
+
build/
|
19
|
+
|
20
|
+
## Documentation cache and generated files:
|
21
|
+
/.yardoc/
|
22
|
+
/_yardoc/
|
23
|
+
/doc/
|
24
|
+
/rdoc/
|
25
|
+
|
26
|
+
## Environment normalisation:
|
27
|
+
/.bundle/
|
28
|
+
/lib/bundler/man/
|
29
|
+
|
30
|
+
# for a library or gem, you might want to ignore these files since the code is
|
31
|
+
# intended to run in multiple environments; otherwise, check them in:
|
32
|
+
# Gemfile.lock
|
33
|
+
# .ruby-version
|
34
|
+
# .ruby-gemset
|
35
|
+
|
36
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
37
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Tomohiko Himura
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# GithubScouter
|
2
|
+
|
3
|
+
あなたのGitHub戦闘力を計測します。
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'github_scouter'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install github_scouter
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
$ github_scouter [github ID]
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/github_scouter/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
32
|
+
|
33
|
+
## Link
|
34
|
+
|
35
|
+
* [解説記事](http://blog.eiel.info/blog/2014/09/13/github-scouter/)
|
36
|
+
* [eiel/github_scouter](https://github.com/eiel/github_scouter)
|
37
|
+
* [戦闘力 - 座駆動LT大会](https://speakerdeck.com/eiel/zhan-dou-li)
|
38
|
+
* [座駆動LT大会](http://gbdaitokai.doorkeeper.jp/events/12940)
|
data/Rakefile
ADDED
data/bin/github_scouter
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'github_scouter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "github_scouter"
|
8
|
+
spec.version = GithubScouter::VERSION
|
9
|
+
spec.authors = ["Tomohiko Himura"]
|
10
|
+
spec.email = ["eiel.hal@gmail.com"]
|
11
|
+
spec.summary = %q{calculate fighting power}
|
12
|
+
spec.description = %q{calculate fighting power}
|
13
|
+
spec.homepage = "https://github.com/eiel/github_scouter"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "octokit"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require "github_scouter/version"
|
2
|
+
require 'octokit'
|
3
|
+
|
4
|
+
class Array
|
5
|
+
def sum
|
6
|
+
reduce(0) { |a,n| a + n }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module GithubScouter
|
11
|
+
class Scouter
|
12
|
+
def self.atk_base(repo)
|
13
|
+
return 0 if repo.private
|
14
|
+
fork = repo.forks_count
|
15
|
+
start = repo.stargazers_count
|
16
|
+
|
17
|
+
if repo.fork
|
18
|
+
(fork + start).to_f / 10
|
19
|
+
else
|
20
|
+
1 + (fork + 2) * + start
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.language_rank(repos)
|
25
|
+
repos
|
26
|
+
.map(&:language)
|
27
|
+
.delete_if(&:nil?)
|
28
|
+
.reduce(Hash.new(0)) { |a,lang|
|
29
|
+
a[lang] += 1
|
30
|
+
a
|
31
|
+
}.sort_by { |key,value|
|
32
|
+
-value
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(name)
|
37
|
+
@name = name
|
38
|
+
end
|
39
|
+
|
40
|
+
def client
|
41
|
+
options = {
|
42
|
+
auto_paginate: true,
|
43
|
+
access_token: ENV['GITHUB_ACCESS_TOKEN'],
|
44
|
+
}
|
45
|
+
@client ||= Octokit::Client.new(options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def repos
|
49
|
+
@repos ||= client.repositories(@name)
|
50
|
+
end
|
51
|
+
|
52
|
+
def starred
|
53
|
+
@starred ||= client.starred(@name)
|
54
|
+
end
|
55
|
+
|
56
|
+
def orgs
|
57
|
+
@args ||= client.organizations(@name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def atk
|
61
|
+
repos.map { |repo| Scouter.atk_base(repo) }.sum
|
62
|
+
end
|
63
|
+
|
64
|
+
def int
|
65
|
+
rank = Scouter.language_rank(repos)
|
66
|
+
lang = rank.size
|
67
|
+
sum = 0
|
68
|
+
rank.each_with_index do |h,i|
|
69
|
+
value = h[1]
|
70
|
+
sum += value / (lang - i)
|
71
|
+
end
|
72
|
+
lang * sum
|
73
|
+
end
|
74
|
+
|
75
|
+
def agi
|
76
|
+
orgs.map do |org_id|
|
77
|
+
org = client.organization(org_id.login)
|
78
|
+
repo = org.public_repos
|
79
|
+
members = client.organization_members(org.login).count
|
80
|
+
(repo.to_f + members)
|
81
|
+
end.sum
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class Printer
|
86
|
+
def initialize(scouter)
|
87
|
+
@scouter = scouter
|
88
|
+
end
|
89
|
+
|
90
|
+
def put
|
91
|
+
power
|
92
|
+
puts ""
|
93
|
+
repos_rank
|
94
|
+
puts ""
|
95
|
+
starred_rank
|
96
|
+
end
|
97
|
+
|
98
|
+
def power
|
99
|
+
atk = @scouter.atk
|
100
|
+
int = @scouter.int
|
101
|
+
agi = @scouter.agi
|
102
|
+
params = [atk,int,agi]
|
103
|
+
puts "戦闘力: %d" % params.sum
|
104
|
+
puts
|
105
|
+
puts "攻撃力: %d 知力: %d すばやさ: %d" % params
|
106
|
+
end
|
107
|
+
|
108
|
+
def repos_rank
|
109
|
+
rank(@scouter.repos, "repositories")
|
110
|
+
end
|
111
|
+
|
112
|
+
def starred_rank
|
113
|
+
rank(@scouter.starred, "starred")
|
114
|
+
end
|
115
|
+
|
116
|
+
def rank(repos,label)
|
117
|
+
rank = Scouter.language_rank(repos)
|
118
|
+
puts "# #{label} (#{repos.count})"
|
119
|
+
puts ""
|
120
|
+
rank[0..9].each_with_index do |(key,value),i|
|
121
|
+
puts "#{i+1}. ".ljust(4) + key.ljust(20) + value.to_s
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github_scouter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomohiko Himura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: octokit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: calculate fighting power
|
56
|
+
email:
|
57
|
+
- eiel.hal@gmail.com
|
58
|
+
executables:
|
59
|
+
- github_scouter
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/github_scouter
|
69
|
+
- github_scouter.gemspec
|
70
|
+
- lib/github_scouter.rb
|
71
|
+
- lib/github_scouter/version.rb
|
72
|
+
homepage: https://github.com/eiel/github_scouter
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: calculate fighting power
|
96
|
+
test_files: []
|
97
|
+
has_rdoc:
|