hubba 0.4.0 → 0.5.0

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
  SHA1:
3
- metadata.gz: e3e04406b046b751a5eb400e8955417ae99498e7
4
- data.tar.gz: 57752bfd47aea766d3db5c467659876216a644a0
3
+ metadata.gz: 319b35fe1bf80f076adbd6a784a85e6e688aa8a4
4
+ data.tar.gz: 1382ba38baefab59976acd68e5e1f1d3dec6de17
5
5
  SHA512:
6
- metadata.gz: f96d7fa167b0e7cf8b685674aa80d19eca790ad237a9ea43cd40650d1c799448ce5827b009bb84b9d14c774b991693e1b0570735bf6573f64ed2c0a9e46c1c1f
7
- data.tar.gz: 5cbdcd4a949763f19ba6275cec64cc1f3cfda6b05abe02950721befac8df17b1a5a1d64d1e41ae8048d23c06b93f41436d69bde91338e81313aa6e19af89236a
6
+ metadata.gz: 791b9e53b4f3efcc0f866e76cbcf18e253be680c1656eaa358343e5f39fad7002a4a0e4a07103f395f6741e3e36f27117c2de199d3d6f3eb35ef584a5ddfe099
7
+ data.tar.gz: 6ef11031170d0300efd81c5213a996ec09a65b458328ab178825062c4ce07cf8e9a9b594ec58bc8d0078e748e4208bb98793b3e67e75456acdc8d2af7caa99e3
@@ -22,6 +22,13 @@ module Hubba
22
22
  def updated_at() @updated_at ||= @data['updated_at'] ? DateTime.strptime( @data['updated_at'], '%Y-%m-%dT%H:%M:%S') : nil; end
23
23
  def pushed_at() @pushed_at ||= @data['pushed_at'] ? DateTime.strptime( @data['pushed_at'], '%Y-%m-%dT%H:%M:%S') : nil; end
24
24
 
25
+ ## date (only) versions
26
+ def created() @created ||= @data['created_at'] ? Date.strptime( @data['created_at'], '%Y-%m-%d') : nil; end
27
+ def updated() @updated ||= @data['updated_at'] ? Date.strptime( @data['updated_at'], '%Y-%m-%d') : nil; end
28
+ def pushed() @pushed ||= @data['pushed_at'] ? Date.strptime( @data['pushed_at'], '%Y-%m-%d') : nil; end
29
+
30
+
31
+
25
32
  def history() @history ||= @data['history'] ? build_history( @data['history'] ) : nil; end
26
33
 
27
34
  def size
@@ -34,14 +41,56 @@ module Hubba
34
41
  @stars ||= history ? history[0].stars : 0
35
42
  end
36
43
 
44
+
45
+ def commits() @data['commits']; end
46
+
47
+ def last_commit() ## convenience shortcut; get first/last commit (use [0]) or nil
48
+ if @data['commits'] && @data['commits'][0]
49
+ @data['commits'][0]
50
+ else
51
+ nil
52
+ end
53
+ end
54
+
55
+ def committed() ## last commit date (from author NOT committer)
56
+ @committed ||= last_commit ? Date.strptime( last_commit['author']['date'], '%Y-%m-%d') : nil
57
+ end
58
+
59
+ def committed_at() ## last commit date (from author NOT committer)
60
+ @committed_at ||= last_commit ? DateTime.strptime( last_commit['author']['date'], '%Y-%m-%dT%H:%M:%S') : nil
61
+ end
62
+
63
+
64
+ def last_commit_message() ## convenience shortcut; last commit message
65
+ h = last_commit
66
+
67
+ committer_name = h['committer']['name']
68
+ author_name = h['author']['name']
69
+ message = h['message']
70
+
71
+ buf = ""
72
+ buf << message
73
+ buf << " by #{author_name}"
74
+
75
+ if committer_name != author_name
76
+ buf << " w/ #{committer_name}"
77
+ end
78
+ end # method commit_message
79
+
80
+
81
+
37
82
  def reset_cache
38
83
  ## reset (invalidate) cached values from data hash
39
84
  ## use after reading or fetching
40
- @full_name = nil
41
- @created_at = @updated_at = @pushed_at = nil
42
- @history = nil
43
- @size = nil
44
- @stars = nil
85
+ @full_name = nil
86
+ @created_at = @updated_at = @pushed_at = nil
87
+ @created = @updated = @pused = nil
88
+ @history = nil
89
+ @size = nil
90
+ @stars = nil
91
+
92
+ @committed_at = nil
93
+ @committed = nil
45
94
  end
46
95
 
47
96
 
@@ -56,6 +105,7 @@ module Hubba
56
105
  def initialize( date:, stars: )
57
106
  @date = date
58
107
  @stars = stars
108
+ @next = nil
59
109
  end
60
110
 
61
111
  ## link items (append item at the end/tail)
@@ -204,6 +254,10 @@ module Hubba
204
254
  'date' => commits.data[0]['commit']['committer']['date'],
205
255
  'name' => commits.data[0]['commit']['committer']['name']
206
256
  },
257
+ 'author' => {
258
+ 'date' => commits.data[0]['commit']['author']['date'],
259
+ 'name' => commits.data[0]['commit']['author']['name']
260
+ },
207
261
  'message' => commits.data[0]['commit']['message']
208
262
  }
209
263
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Hubba
4
4
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
5
- MINOR = 4
5
+ MINOR = 5
6
6
  PATCH = 0
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
@@ -11,11 +11,15 @@
11
11
  },
12
12
  "commits": [
13
13
  {
14
+ "author": {
15
+ "name": "ashmaroli",
16
+ "date": "2018-02-21T19:35:59Z"
17
+ },
14
18
  "committer": {
15
- "date": "2018-01-29T19:02:39Z",
16
- "name": "Frank Taillandier"
19
+ "name": "Frank Taillandier",
20
+ "date": "2018-02-21T19:35:59Z"
17
21
  },
18
- "message": "Release 💎 v2.3.0 (#195)"
22
+ "message": "social icons should resolve baseurl properly (#201)"
19
23
  }
20
24
  ]
21
- }
25
+ }
@@ -10,6 +10,44 @@ require 'helper'
10
10
 
11
11
  class TestStats < MiniTest::Test
12
12
 
13
+
14
+ def test_jekyll_minima
15
+
16
+ stats = Hubba::Stats.new( 'jekyll/minima' )
17
+
18
+ assert_equal 0, stats.size
19
+ assert_equal 0, stats.stars
20
+ assert_nil stats.history
21
+
22
+ stats.read( data_dir: "#{Hubba.root}/test/stats" )
23
+
24
+ assert_equal 321, stats.size
25
+ assert_equal 717, stats.stars
26
+ assert_equal 717, stats.history[0].stars
27
+ assert_equal 1, stats.history.size
28
+
29
+ assert_equal Date.new(2018, 2, 12 ), stats.history[0].date
30
+
31
+ assert_nil stats.history[0].diff_days
32
+
33
+ assert_equal Date.new(2018, 2, 21 ), stats.committed
34
+ assert_equal Date.new(2016, 5, 20 ), stats.created
35
+ assert_equal Date.new(2018, 2, 11 ), stats.updated
36
+ assert_equal Date.new(2018, 2, 7 ), stats.pushed
37
+
38
+ assert_equal DateTime.new(2018, 2, 21, 19, 35, 59 ), stats.committed_at
39
+ assert_equal DateTime.new(2016, 5, 20, 23, 7, 56 ), stats.created_at
40
+ assert_equal DateTime.new(2018, 2, 11, 16, 13, 33 ), stats.updated_at
41
+ assert_equal DateTime.new(2018, 2, 7, 22, 14, 11 ), stats.pushed_at
42
+
43
+
44
+ pp stats.last_commit
45
+ pp stats.last_commit_message
46
+ pp stats.history_str ## pp history pretty printed to string (buffer)
47
+ end
48
+
49
+
50
+
13
51
  def test_awesome_blockchains
14
52
 
15
53
  stats = Hubba::Stats.new( 'openblockchains/awesome-blockchains' )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-12 00:00:00.000000000 Z
11
+ date: 2018-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils