gitgrass 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42ff5ca2f74f02fbef656bbf7673aab985c1d4409d2266782d871feba1a07829
4
- data.tar.gz: 19d2c22a87f2de5ed0cfdf0c226d1a224a5d650f554086540dcee1400b9c8e4d
3
+ metadata.gz: 7f1778faedac98f641c7ca611fcadbfb48bda6e9c7b61e51fa7f8837b42e8379
4
+ data.tar.gz: 37831b40c5d6e76e3a0b3c2953069acd338acc343a40cd537dbb61fce20c7c49
5
5
  SHA512:
6
- metadata.gz: 11a5baf40bad7a7d22dbdbee9faeae2d30494fbf5e8d7a306123770433916b3167ceda5b9d35ec091683e8e278dc9f1e5fae39b55855d4ed93c4e76808b21bed
7
- data.tar.gz: eb72e7d2e122207520c0e3109afe6da4095815fcff168a43653e3fc850561f4eed783804f49a193a126482f22867013ecac26947703467b4d1a6b868fd638e24
6
+ metadata.gz: a245b0c7eaf8628904c9bc4e4bf281e291ec9e26e3a3b6d63067cb89f2dcab15864594773fbef6e74213338efdd9c6cd0c9ebddb3593724d5f7a06f9d0921d67
7
+ data.tar.gz: b6b294d85b494733f9780f8331aa80abd354c538c214133fbda72105de3a288bbef6e3299fa3ff04053b1d7c52244185be7fa77e43e9e2809e1a375d5f0bd492
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Gitgrass
2
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
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
- TODO: Write usage instructions here
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
@@ -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 = { 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) }
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.*--color-calendar-graph-day-(bg|L1|L2|L3|L4).*data-date="(.*)".*>/)
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(["dummy"])
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[0].to_sym]
38
+ @tile_table[index] << TILE_COLOR[item.to_sym]
42
39
  end
43
40
  end
44
41
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gitgrass
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.0
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-01-13 00:00:00.000000000 Z
11
+ date: 2021-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor