gitgrass 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 +9 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +23 -0
- data/README.md +35 -0
- data/Rakefile +4 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/gitgrass +3 -0
- data/gitgrass.gemspec +38 -0
- data/lib/gitgrass.rb +6 -0
- data/lib/gitgrass/cli.rb +14 -0
- data/lib/gitgrass/git_scrap.rb +45 -0
- data/lib/gitgrass/version.rb +5 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 42ff5ca2f74f02fbef656bbf7673aab985c1d4409d2266782d871feba1a07829
|
4
|
+
data.tar.gz: 19d2c22a87f2de5ed0cfdf0c226d1a224a5d650f554086540dcee1400b9c8e4d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 11a5baf40bad7a7d22dbdbee9faeae2d30494fbf5e8d7a306123770433916b3167ceda5b9d35ec091683e8e278dc9f1e5fae39b55855d4ed93c4e76808b21bed
|
7
|
+
data.tar.gz: eb72e7d2e122207520c0e3109afe6da4095815fcff168a43653e3fc850561f4eed783804f49a193a126482f22867013ecac26947703467b4d1a6b868fd638e24
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gitgrass (0.1.0)
|
5
|
+
rainbow (~> 3.0)
|
6
|
+
thor (~> 1.0, >= 1.0.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
rainbow (3.0.0)
|
12
|
+
rake (13.0.3)
|
13
|
+
thor (1.0.1)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
x86_64-linux
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
gitgrass!
|
20
|
+
rake (~> 13.0)
|
21
|
+
|
22
|
+
BUNDLED WITH
|
23
|
+
2.2.3
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Gitgrass
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gitgrass`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'gitgrass'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install gitgrass
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gitgrass.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "gitgrass"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/gitgrass
ADDED
data/gitgrass.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/gitgrass/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gitgrass"
|
7
|
+
spec.version = Gitgrass::VERSION
|
8
|
+
spec.authors = ["0x6d61"]
|
9
|
+
spec.email = ["0x6d61@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Show commit on github"
|
12
|
+
spec.description = "githubの草をcliで表示するコマンド"
|
13
|
+
spec.homepage = "https://github.com/0x6d61"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
16
|
+
|
17
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = "https://github.com/0x6d61"
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/0x6d61/gitgrass"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/0x6d61/gitgrass/commits/master"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Uncomment to register a new dependency of your gem
|
33
|
+
spec.add_dependency "thor", "~> 1.0", ">= 1.0.1"
|
34
|
+
spec.add_dependency "rainbow", "~> 3.0"
|
35
|
+
|
36
|
+
# For more information and examples about making a new gem, checkout our
|
37
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
38
|
+
end
|
data/lib/gitgrass.rb
ADDED
data/lib/gitgrass/cli.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "thor"
|
2
|
+
require_relative "git_scrap"
|
3
|
+
module Gitgrass
|
4
|
+
class CLI < Thor
|
5
|
+
desc "show user","Shows the number of commits in git"
|
6
|
+
option "year",aliases:"y",desc: 'Specify the year to display'
|
7
|
+
def show(user)
|
8
|
+
git_scrap = GitScrap.new(user)
|
9
|
+
git_scrap.year = options["year"] if options["year"]
|
10
|
+
git_scrap.make_grass_table()
|
11
|
+
git_scrap.tile_table.each { |t| puts t.join }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require "rainbow"
|
3
|
+
require "date"
|
4
|
+
|
5
|
+
class GitScrap
|
6
|
+
attr_reader :tile_table
|
7
|
+
GITHUB_URL = "https://github.com/"
|
8
|
+
TILE_COLOR = { bg: Rainbow("[]").color(235, 237, 240).background(235, 237, 240),
|
9
|
+
L1: Rainbow("[]").color(155, 233, 168).background(155, 233, 168),
|
10
|
+
L2: Rainbow("[]").color(111, 197, 100).background(111, 197, 100),
|
11
|
+
L3: Rainbow("[]").color(90, 162, 79).background(90, 162, 79),
|
12
|
+
L4: Rainbow("[]").color(59, 111, 58).background(59, 111, 58),
|
13
|
+
dummy: Rainbow("[]").color(0,0,0).background(0,0,0) }
|
14
|
+
|
15
|
+
def initialize(user)
|
16
|
+
@user = user
|
17
|
+
@tile_table = Array.new(7) { [] }
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_commit
|
21
|
+
url = @year ? "#{GITHUB_URL}#{@user}?tab=overview&from=#{@year}-01-01&to=#{@year}-12-31" : "#{GITHUB_URL}#{@user}"
|
22
|
+
html = URI(url)
|
23
|
+
body = html.read
|
24
|
+
body.scan(/<rect.*--color-calendar-graph-day-(bg|L1|L2|L3|L4).*data-date="(.*)".*>/)
|
25
|
+
end
|
26
|
+
|
27
|
+
def year=(year)
|
28
|
+
@year = year.to_i
|
29
|
+
end
|
30
|
+
|
31
|
+
def make_grass_table
|
32
|
+
commit_data = self.get_commit()
|
33
|
+
if @year
|
34
|
+
Date.new(@year, 1, 1).wday.times do |n|
|
35
|
+
commit_data.unshift(["dummy"])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
0.step(commit_data.length - 1, 7) do |index|
|
39
|
+
oneweek_tile = commit_data.slice(index, 7)
|
40
|
+
oneweek_tile.each_with_index do |item, index|
|
41
|
+
@tile_table[index] << TILE_COLOR[item[0].to_sym]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitgrass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- '0x6d61'
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rainbow
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.0'
|
47
|
+
description: githubの草をcliで表示するコマンド
|
48
|
+
email:
|
49
|
+
- 0x6d61@gmail.com
|
50
|
+
executables:
|
51
|
+
- gitgrass
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- ".gitignore"
|
56
|
+
- Gemfile
|
57
|
+
- Gemfile.lock
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bin/console
|
61
|
+
- bin/setup
|
62
|
+
- exe/gitgrass
|
63
|
+
- gitgrass.gemspec
|
64
|
+
- lib/gitgrass.rb
|
65
|
+
- lib/gitgrass/cli.rb
|
66
|
+
- lib/gitgrass/git_scrap.rb
|
67
|
+
- lib/gitgrass/version.rb
|
68
|
+
homepage: https://github.com/0x6d61
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata:
|
72
|
+
allowed_push_host: https://rubygems.org
|
73
|
+
homepage_uri: https://github.com/0x6d61
|
74
|
+
source_code_uri: https://github.com/0x6d61/gitgrass
|
75
|
+
changelog_uri: https://github.com/0x6d61/gitgrass/commits/master
|
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: 2.3.0
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubygems_version: 3.2.3
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Show commit on github
|
95
|
+
test_files: []
|