github-pulse 0.2.0

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.
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Github
6
+ module Pulse
7
+ class Reporter
8
+ attr_reader :report
9
+
10
+ def initialize(report)
11
+ @report = report
12
+ end
13
+
14
+ def generate(format: :json)
15
+ case format
16
+ when :json
17
+ JSON.generate(report)
18
+ when :pretty
19
+ JSON.pretty_generate(report)
20
+ else
21
+ raise ArgumentError, "Unknown format: #{format}"
22
+ end
23
+ end
24
+
25
+ def summary
26
+ lines = []
27
+ lines << "GitHub Repository Activity Report"
28
+ lines << "=" * 40
29
+
30
+ if report[:metadata][:repository]
31
+ repo = report[:metadata][:repository]
32
+ lines << "Repository: #{repo[:full_name]}"
33
+ lines << "Description: #{repo[:description]}" if repo[:description]
34
+ lines << "Primary Language: #{repo[:language]}" if repo[:language]
35
+ lines << "Stars: #{repo[:stars]} | Forks: #{repo[:forks]}"
36
+ lines << ""
37
+ end
38
+
39
+ if report[:metadata][:period][:since] || report[:metadata][:period][:until]
40
+ lines << "Analysis Period:"
41
+ lines << " From: #{report[:metadata][:period][:since] || 'Beginning'}"
42
+ lines << " To: #{report[:metadata][:period][:until] || 'Present'}"
43
+ lines << ""
44
+ end
45
+
46
+ lines << "Analyzed at: #{report[:metadata][:analyzed_at]}"
47
+ lines << ""
48
+
49
+ # Commits summary
50
+ if report[:commits].any?
51
+ lines << "Commits by Author:"
52
+ report[:commits].each do |author, data|
53
+ lines << " #{author}:"
54
+ lines << " Total Commits: #{data[:total_commits]}"
55
+ lines << " Additions: +#{data[:total_additions]}"
56
+ lines << " Deletions: -#{data[:total_deletions]}"
57
+ end
58
+ lines << ""
59
+ end
60
+
61
+ # Pull requests summary
62
+ if report[:pull_requests].any?
63
+ lines << "Pull Requests by Author:"
64
+ report[:pull_requests].each do |author, data|
65
+ lines << " #{author}:"
66
+ lines << " Total PRs: #{data[:total_prs]}"
67
+ lines << " Merged: #{data[:merged]}"
68
+ lines << " Open: #{data[:open]}"
69
+ lines << " Closed: #{data[:closed]}"
70
+ lines << " Additions: +#{data[:total_additions]}"
71
+ lines << " Deletions: -#{data[:total_deletions]}"
72
+ end
73
+ lines << ""
74
+ end
75
+
76
+ # Lines of code
77
+ if report[:lines_of_code].any?
78
+ lines << "Current Lines of Code by Author:"
79
+ sorted_loc = report[:lines_of_code].sort_by { |_, lines| -lines }
80
+ total_lines = sorted_loc.sum { |_, lines| lines }
81
+
82
+ sorted_loc.each do |author, line_count|
83
+ percentage = (line_count.to_f / total_lines * 100).round(1)
84
+ lines << " #{author}: #{line_count} lines (#{percentage}%)"
85
+ end
86
+ lines << " Total: #{total_lines} lines"
87
+ lines << ""
88
+ end
89
+
90
+ # Commit activity summary
91
+ if report[:commit_activity].any?
92
+ total_commits = report[:commit_activity].values.sum
93
+ lines << "Commit Activity:"
94
+ lines << " Total Commits: #{total_commits}"
95
+ lines << " Active Days: #{report[:commit_activity].size}"
96
+ lines << " Average Commits/Day: #{(total_commits.to_f / report[:commit_activity].size).round(1)}"
97
+ lines << ""
98
+ end
99
+
100
+ lines.join("\n")
101
+ end
102
+
103
+ def to_csv
104
+ require "csv"
105
+
106
+ CSV.generate do |csv|
107
+ # Add headers
108
+ csv << ["Metric", "Author", "Value", "Details"]
109
+
110
+ # Add commit data
111
+ report[:commits].each do |author, data|
112
+ csv << ["Commits", author, data[:total_commits], "Total commits"]
113
+ csv << ["Additions", author, data[:total_additions], "Total lines added"]
114
+ csv << ["Deletions", author, data[:total_deletions], "Total lines deleted"]
115
+ end
116
+
117
+ # Add PR data
118
+ report[:pull_requests].each do |author, data|
119
+ csv << ["Pull Requests", author, data[:total_prs], "Total PRs"]
120
+ csv << ["PR Merged", author, data[:merged], "Merged PRs"]
121
+ csv << ["PR Open", author, data[:open], "Open PRs"]
122
+ end
123
+
124
+ # Add lines of code data
125
+ report[:lines_of_code].each do |author, lines|
126
+ csv << ["Lines of Code", author, lines, "Current lines in codebase"]
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Github
4
+ module Pulse
5
+ VERSION = "0.2.0"
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "pulse/version"
4
+ require_relative "pulse/date_helpers"
5
+ require_relative "pulse/cli"
6
+ require_relative "pulse/analyzer"
7
+ require_relative "pulse/github_client"
8
+ require_relative "pulse/git_analyzer"
9
+ require_relative "pulse/reporter"
10
+
11
+ module Github
12
+ module Pulse
13
+ class Error < StandardError; end
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ module Github
2
+ module Pulse
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github-pulse
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Siegel
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-08-08 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: '9.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '9.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rugged
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: time
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.3'
83
+ description: A Ruby gem to analyze GitHub repository activity, including pull requests,
84
+ lines of code, and commit activity by contributor. Generates visualization-ready
85
+ JSON output.
86
+ email:
87
+ - "<248302+usiegj00@users.noreply.github.com>"
88
+ executables:
89
+ - github-pulse
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - AGENTS.md
94
+ - README.md
95
+ - Rakefile
96
+ - exe/github-pulse
97
+ - github-pulse-report.html
98
+ - lib/github/pulse.rb
99
+ - lib/github/pulse/analyzer.rb
100
+ - lib/github/pulse/cli.rb
101
+ - lib/github/pulse/date_helpers.rb
102
+ - lib/github/pulse/gh_client.rb
103
+ - lib/github/pulse/git_analyzer.rb
104
+ - lib/github/pulse/github_client.rb
105
+ - lib/github/pulse/html_reporter.rb
106
+ - lib/github/pulse/reporter.rb
107
+ - lib/github/pulse/version.rb
108
+ - sig/github/pulse.rbs
109
+ homepage: https://github.com/usiegj00/github-pulse
110
+ licenses: []
111
+ metadata:
112
+ homepage_uri: https://github.com/usiegj00/github-pulse
113
+ source_code_uri: https://github.com/usiegj00/github-pulse
114
+ changelog_uri: https://github.com/usiegj00/github-pulse/blob/main/CHANGELOG.md
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 3.1.0
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubygems_version: 3.5.16
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Analyze GitHub repository activity and contributions
134
+ test_files: []