gitgrass 0.1.0 → 0.1.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 +4 -4
- data/README.md +10 -7
- data/lib/gitgrass/cli.rb +1 -1
- data/lib/gitgrass/git_scrap.rb +12 -15
- data/lib/gitgrass/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f1778faedac98f641c7ca611fcadbfb48bda6e9c7b61e51fa7f8837b42e8379
|
4
|
+
data.tar.gz: 37831b40c5d6e76e3a0b3c2953069acd338acc343a40cd537dbb61fce20c7c49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a245b0c7eaf8628904c9bc4e4bf281e291ec9e26e3a3b6d63067cb89f2dcab15864594773fbef6e74213338efdd9c6cd0c9ebddb3593724d5f7a06f9d0921d67
|
7
|
+
data.tar.gz: b6b294d85b494733f9780f8331aa80abd354c538c214133fbda72105de3a288bbef6e3299fa3ff04053b1d7c52244185be7fa77e43e9e2809e1a375d5f0bd492
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Gitgrass
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Command to display grass of github with CLI
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,15 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
|
24
|
+
Display for the past year:
|
25
|
+
```
|
26
|
+
gitgrass show 0x6d61
|
27
|
+
```
|
28
|
+
Show commit for the specified year:
|
29
|
+
```
|
30
|
+
gitgrass show 0x6d61 -y 2020
|
31
|
+
```
|
26
32
|
|
27
33
|
## Development
|
28
34
|
|
@@ -30,6 +36,3 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
|
|
30
36
|
|
31
37
|
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
38
|
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gitgrass.
|
data/lib/gitgrass/cli.rb
CHANGED
@@ -6,7 +6,7 @@ module Gitgrass
|
|
6
6
|
option "year",aliases:"y",desc: 'Specify the year to display'
|
7
7
|
def show(user)
|
8
8
|
git_scrap = GitScrap.new(user)
|
9
|
-
git_scrap.year = options["year"] if options["year"]
|
9
|
+
git_scrap.year = options["year"].to_i if options["year"]
|
10
10
|
git_scrap.make_grass_table()
|
11
11
|
git_scrap.tile_table.each { |t| puts t.join }
|
12
12
|
end
|
data/lib/gitgrass/git_scrap.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require "open-uri"
|
2
2
|
require "rainbow"
|
3
|
-
require "date"
|
3
|
+
require "date"
|
4
4
|
|
5
5
|
class GitScrap
|
6
6
|
attr_reader :tile_table
|
7
|
+
attr_writer :year
|
7
8
|
GITHUB_URL = "https://github.com/"
|
8
|
-
TILE_COLOR = {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
TILE_COLOR = { "0": Rainbow("[]").color(235, 237, 240).background(235, 237, 240),
|
10
|
+
"1": Rainbow("[]").color(155, 233, 168).background(155, 233, 168),
|
11
|
+
"2": Rainbow("[]").color(111, 197, 100).background(111, 197, 100),
|
12
|
+
"3": Rainbow("[]").color(90, 162, 79).background(90, 162, 79),
|
13
|
+
"4": Rainbow("[]").color(59, 111, 58).background(59, 111, 58),
|
14
|
+
dummy: Rainbow("[]").color(0, 0, 0).background(0, 0, 0) }
|
14
15
|
|
15
16
|
def initialize(user)
|
16
17
|
@user = user
|
@@ -21,24 +22,20 @@ class GitScrap
|
|
21
22
|
url = @year ? "#{GITHUB_URL}#{@user}?tab=overview&from=#{@year}-01-01&to=#{@year}-12-31" : "#{GITHUB_URL}#{@user}"
|
22
23
|
html = URI(url)
|
23
24
|
body = html.read
|
24
|
-
body.scan(/<rect
|
25
|
-
end
|
26
|
-
|
27
|
-
def year=(year)
|
28
|
-
@year = year.to_i
|
25
|
+
body.scan(/<rect.*data-count=.*data-level="(0|1|2|3|4)".*>/)
|
29
26
|
end
|
30
27
|
|
31
28
|
def make_grass_table
|
32
|
-
commit_data = self.get_commit()
|
29
|
+
commit_data = self.get_commit().flatten
|
33
30
|
if @year
|
34
31
|
Date.new(@year, 1, 1).wday.times do |n|
|
35
|
-
commit_data.unshift(
|
32
|
+
commit_data.unshift("dummy")
|
36
33
|
end
|
37
34
|
end
|
38
35
|
0.step(commit_data.length - 1, 7) do |index|
|
39
36
|
oneweek_tile = commit_data.slice(index, 7)
|
40
37
|
oneweek_tile.each_with_index do |item, index|
|
41
|
-
@tile_table[index] << TILE_COLOR[item
|
38
|
+
@tile_table[index] << TILE_COLOR[item.to_sym]
|
42
39
|
end
|
43
40
|
end
|
44
41
|
end
|
data/lib/gitgrass/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitgrass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x6d61'
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|