geiyepa 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 +60 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +104 -0
- data/LICENSE.txt +21 -0
- data/README.md +72 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/pa +18 -0
- data/geiyepa.gemspec +36 -0
- data/lib/pa.rb +33 -0
- data/lib/pa/cache.rb +46 -0
- data/lib/pa/client.rb +29 -0
- data/lib/pa/version.rb +3 -0
- metadata +166 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ebae4eadaa34c96befc8a30d827aae1d146ad9d01aef68535dc6ad2070023b61
|
4
|
+
data.tar.gz: 96de0ea67efbb997ba3c5d8c0ee3ec9d1f4423c13c41eece509a6eb93613d165
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 715a70631f4dca348123bf83ac2eeb6e38685242ec070dd89467566a2c18ba6655eb51a755f5433584c6911f4d730b12989a976c14088bf3f8f83d359a7c9592
|
7
|
+
data.tar.gz: 19d959822c21fcc5bd47f133f79f5b581850b20b869f15e6eca93467f181bfeaa12bf712cbb20cc5d91b96016925a66789e6d39ad9c73716f53d859f24493ebd
|
data/.gitignore
ADDED
@@ -0,0 +1,60 @@
|
|
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
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
57
|
+
|
58
|
+
/.envrc
|
59
|
+
/repos
|
60
|
+
/.vendor
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at TODO: Write your email address. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
geiyepa (0.1.0)
|
5
|
+
activesupport (~> 6.1, >= 6.1.3.2)
|
6
|
+
awesome_print (~> 1.9, >= 1.9.2)
|
7
|
+
octokit (~> 4.21)
|
8
|
+
pry (~> 0.14.1)
|
9
|
+
rubocop (~> 1.16)
|
10
|
+
table_print (~> 1.5, >= 1.5.7)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
activesupport (6.1.3.2)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
zeitwerk (~> 2.3)
|
21
|
+
addressable (2.7.0)
|
22
|
+
public_suffix (>= 2.0.2, < 5.0)
|
23
|
+
ast (2.4.2)
|
24
|
+
awesome_print (1.9.2)
|
25
|
+
coderay (1.1.3)
|
26
|
+
concurrent-ruby (1.1.9)
|
27
|
+
diff-lcs (1.4.4)
|
28
|
+
faraday (1.4.2)
|
29
|
+
faraday-em_http (~> 1.0)
|
30
|
+
faraday-em_synchrony (~> 1.0)
|
31
|
+
faraday-excon (~> 1.1)
|
32
|
+
faraday-net_http (~> 1.0)
|
33
|
+
faraday-net_http_persistent (~> 1.1)
|
34
|
+
multipart-post (>= 1.2, < 3)
|
35
|
+
ruby2_keywords (>= 0.0.4)
|
36
|
+
faraday-em_http (1.0.0)
|
37
|
+
faraday-em_synchrony (1.0.0)
|
38
|
+
faraday-excon (1.1.0)
|
39
|
+
faraday-net_http (1.0.1)
|
40
|
+
faraday-net_http_persistent (1.1.0)
|
41
|
+
i18n (1.8.10)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
method_source (1.0.0)
|
44
|
+
minitest (5.14.4)
|
45
|
+
multipart-post (2.1.1)
|
46
|
+
octokit (4.21.0)
|
47
|
+
faraday (>= 0.9)
|
48
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
49
|
+
parallel (1.20.1)
|
50
|
+
parser (3.0.1.1)
|
51
|
+
ast (~> 2.4.1)
|
52
|
+
pry (0.14.1)
|
53
|
+
coderay (~> 1.1)
|
54
|
+
method_source (~> 1.0)
|
55
|
+
public_suffix (4.0.6)
|
56
|
+
rainbow (3.0.0)
|
57
|
+
rake (12.3.3)
|
58
|
+
regexp_parser (2.1.1)
|
59
|
+
rexml (3.2.5)
|
60
|
+
rspec (3.10.0)
|
61
|
+
rspec-core (~> 3.10.0)
|
62
|
+
rspec-expectations (~> 3.10.0)
|
63
|
+
rspec-mocks (~> 3.10.0)
|
64
|
+
rspec-core (3.10.1)
|
65
|
+
rspec-support (~> 3.10.0)
|
66
|
+
rspec-expectations (3.10.1)
|
67
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
68
|
+
rspec-support (~> 3.10.0)
|
69
|
+
rspec-mocks (3.10.2)
|
70
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
+
rspec-support (~> 3.10.0)
|
72
|
+
rspec-support (3.10.2)
|
73
|
+
rubocop (1.17.0)
|
74
|
+
parallel (~> 1.10)
|
75
|
+
parser (>= 3.0.0.0)
|
76
|
+
rainbow (>= 2.2.2, < 4.0)
|
77
|
+
regexp_parser (>= 1.8, < 3.0)
|
78
|
+
rexml
|
79
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
80
|
+
ruby-progressbar (~> 1.7)
|
81
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
82
|
+
rubocop-ast (1.7.0)
|
83
|
+
parser (>= 3.0.1.1)
|
84
|
+
ruby-progressbar (1.11.0)
|
85
|
+
ruby2_keywords (0.0.4)
|
86
|
+
sawyer (0.8.2)
|
87
|
+
addressable (>= 2.3.5)
|
88
|
+
faraday (> 0.8, < 2.0)
|
89
|
+
table_print (1.5.7)
|
90
|
+
tzinfo (2.0.4)
|
91
|
+
concurrent-ruby (~> 1.0)
|
92
|
+
unicode-display_width (2.0.0)
|
93
|
+
zeitwerk (2.4.2)
|
94
|
+
|
95
|
+
PLATFORMS
|
96
|
+
ruby
|
97
|
+
|
98
|
+
DEPENDENCIES
|
99
|
+
geiyepa!
|
100
|
+
rake (~> 12.0)
|
101
|
+
rspec (~> 3.0)
|
102
|
+
|
103
|
+
BUNDLED WITH
|
104
|
+
2.1.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Martin Tan
|
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,72 @@
|
|
1
|
+
# 爬 Pa
|
2
|
+
|
3
|
+
Ranging activities of Github repos.
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
### Install as an executable file
|
10
|
+
|
11
|
+
```shell
|
12
|
+
gem install geiyepa
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
### Setup
|
18
|
+
|
19
|
+
1. Tell `geiyepa` the repos which you want to scrape
|
20
|
+
|
21
|
+
```shell
|
22
|
+
mkdir -p ~/.pa/cache
|
23
|
+
echo "mtanneb/pa" >> ~/.pa/repos
|
24
|
+
```
|
25
|
+
|
26
|
+
2. Export your Github token to console
|
27
|
+
|
28
|
+
```shell
|
29
|
+
export TOKEN="YOUR GITHUB TOKEN"
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
```shell
|
35
|
+
$ pa
|
36
|
+
|
37
|
+
"mtanneb/pa"
|
38
|
+
MESSAGE | AUTHOR | DATE
|
39
|
+
----------------------------------|------------|--------------------------
|
40
|
+
feat: create a gem package | Martin Tan | 2021-06-16 14:20:53 +0800
|
41
|
+
feat: add cache and github client | Martin Tan | 2021-06-16 12:19:22 +0800
|
42
|
+
Init | Martin Tan | 2021-06-16 12:00:41 +0800
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
The defualt timezone is UTC+8, you can customize it by the following command.
|
48
|
+
|
49
|
+
```shell
|
50
|
+
export TIMEZONE="Asia/Shanghai"
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
## Development
|
56
|
+
|
57
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
58
|
+
|
59
|
+
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).
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mtanneb/pa. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mtanneb/pa/blob/master/CODE_OF_CONDUCT.md).
|
64
|
+
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
69
|
+
|
70
|
+
## Code of Conduct
|
71
|
+
|
72
|
+
Everyone interacting in the Pa project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mtanneb/pa/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pa"
|
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/setup
ADDED
data/exe/pa
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'Pa'
|
5
|
+
|
6
|
+
Pa::App.repos.each do |repo|
|
7
|
+
ap repo
|
8
|
+
|
9
|
+
commits = {}
|
10
|
+
Pa::Client.branches(repo).each do |branch|
|
11
|
+
c = Pa::App.cache.fetch("branches/#{branch.commit.sha}", 60 * 60 * 24 * 7 * 30) do
|
12
|
+
Pa::Client.commits(repo, branch.name).to_json
|
13
|
+
end
|
14
|
+
commits.merge! JSON.parse c, symbolize_names: true
|
15
|
+
end
|
16
|
+
|
17
|
+
Pa::Client.puts commits
|
18
|
+
end
|
data/geiyepa.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'lib/pa/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "geiyepa"
|
5
|
+
spec.version = Pa::VERSION
|
6
|
+
spec.authors = ["Martin Tan"]
|
7
|
+
# spec.email = ["TODO: Write your email address"]
|
8
|
+
|
9
|
+
spec.summary = %q{Ranging activities of a repo.}
|
10
|
+
spec.description = %q{Ranging activities of a repo.}
|
11
|
+
spec.homepage = "https://github.com/mtanneb/pa"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/mtanneb/pa"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/mtanneb/pa"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency 'octokit', '~> 4.21'
|
31
|
+
spec.add_dependency 'awesome_print', '~> 1.9', '>= 1.9.2'
|
32
|
+
spec.add_dependency 'table_print', '~> 1.5', '>= 1.5.7'
|
33
|
+
spec.add_dependency 'rubocop', '~> 1.16'
|
34
|
+
spec.add_dependency 'pry', '~> 0.14.1'
|
35
|
+
spec.add_dependency 'activesupport', '~> 6.1', '>= 6.1.3.2'
|
36
|
+
end
|
data/lib/pa.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "pa/version"
|
2
|
+
require 'octokit'
|
3
|
+
require 'awesome_print'
|
4
|
+
require 'table_print'
|
5
|
+
require 'pry'
|
6
|
+
require 'active_support/core_ext/time'
|
7
|
+
require 'active_support/time_with_zone'
|
8
|
+
|
9
|
+
module Pa
|
10
|
+
class Error < StandardError; end
|
11
|
+
class App
|
12
|
+
def self.root
|
13
|
+
@root ||= File.dirname(File.expand_path(__dir__))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.cache
|
17
|
+
@cache ||= Pa::Cache.new '~/.pa'
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.repos
|
21
|
+
@repos ||= IO.readlines(File.expand_path('~/.pa/repos'), chomp: true)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.config
|
25
|
+
OpenStruct.new(
|
26
|
+
timezone: ENV.fetch('TIMEZONE', 'Asia/Shanghai'),
|
27
|
+
token: ENV.fetch('TOKEN')
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Dir["#{Pa::App.root}/lib/pa/*.rb"].sort.each { |file| require_relative file }
|
data/lib/pa/cache.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Pa
|
4
|
+
class Cache
|
5
|
+
attr_reader :path
|
6
|
+
|
7
|
+
def initialize(path)
|
8
|
+
@path = File.join(path, 'cache')
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch(key, time, &block)
|
12
|
+
write(key, (yield block)) if !exists?(key) || expired?(key, time)
|
13
|
+
read key
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def expired?(key, time)
|
19
|
+
Time.now.in_time_zone(App.config.timezone) - File.mtime(file_path(key)) > time
|
20
|
+
end
|
21
|
+
|
22
|
+
def exists?(key)
|
23
|
+
File.exist? file_path(key)
|
24
|
+
end
|
25
|
+
|
26
|
+
def read(key)
|
27
|
+
IO.read file_path(key), mode: 'r'
|
28
|
+
end
|
29
|
+
|
30
|
+
def write(key, content)
|
31
|
+
initialize_path! file_path(key)
|
32
|
+
IO.write file_path(key), content
|
33
|
+
end
|
34
|
+
|
35
|
+
def file_path(key)
|
36
|
+
File.expand_path File.join(path, key)
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize_path!(path)
|
40
|
+
return if File.exist?(path)
|
41
|
+
|
42
|
+
FileUtils.mkdir_p File.dirname path
|
43
|
+
FileUtils.touch path
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/pa/client.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Pa
|
2
|
+
class Client
|
3
|
+
class << self
|
4
|
+
def branches(repo)
|
5
|
+
client.branches repo
|
6
|
+
end
|
7
|
+
|
8
|
+
def commits(repo, branch, per_page = 5)
|
9
|
+
client.commits(repo, branch, per_page: per_page).each_with_object({}) do |commit, res|
|
10
|
+
res[commit.sha] = { message: commit.commit.message,
|
11
|
+
author: commit.commit.author.name,
|
12
|
+
date: commit.commit.committer.date.in_time_zone(App.config.timezone) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def puts(commits)
|
17
|
+
tp commits.values.reject { |h| h[:message].start_with? 'Merge' }
|
18
|
+
.sort_by { |h| h[:date] }.reverse[0..5],
|
19
|
+
{ message: { width: 60 } }, :author, :date
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def client
|
25
|
+
@client ||= Octokit::Client.new(access_token: App.config.token)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/pa/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geiyepa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Tan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-16 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: '4.21'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.21'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: awesome_print
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.9.2
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.9'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.9.2
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: table_print
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.5'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.5.7
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.5'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.5.7
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rubocop
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.16'
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.16'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: pry
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.14.1
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.14.1
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: activesupport
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '6.1'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 6.1.3.2
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '6.1'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 6.1.3.2
|
115
|
+
description: Ranging activities of a repo.
|
116
|
+
email:
|
117
|
+
executables:
|
118
|
+
- pa
|
119
|
+
extensions: []
|
120
|
+
extra_rdoc_files: []
|
121
|
+
files:
|
122
|
+
- ".gitignore"
|
123
|
+
- ".rspec"
|
124
|
+
- ".travis.yml"
|
125
|
+
- CODE_OF_CONDUCT.md
|
126
|
+
- Gemfile
|
127
|
+
- Gemfile.lock
|
128
|
+
- LICENSE.txt
|
129
|
+
- README.md
|
130
|
+
- Rakefile
|
131
|
+
- bin/console
|
132
|
+
- bin/setup
|
133
|
+
- exe/pa
|
134
|
+
- geiyepa.gemspec
|
135
|
+
- lib/pa.rb
|
136
|
+
- lib/pa/cache.rb
|
137
|
+
- lib/pa/client.rb
|
138
|
+
- lib/pa/version.rb
|
139
|
+
homepage: https://github.com/mtanneb/pa
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata:
|
143
|
+
allowed_push_host: https://rubygems.org
|
144
|
+
homepage_uri: https://github.com/mtanneb/pa
|
145
|
+
source_code_uri: https://github.com/mtanneb/pa
|
146
|
+
changelog_uri: https://github.com/mtanneb/pa
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: 2.3.0
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubygems_version: 3.1.2
|
163
|
+
signing_key:
|
164
|
+
specification_version: 4
|
165
|
+
summary: Ranging activities of a repo.
|
166
|
+
test_files: []
|