newsman 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/newsman +2 -1
- data/lib/newsman/issues.rb +43 -0
- data/lib/newsman/pull_request.rb +4 -1
- data/lib/newsman/report.rb +18 -0
- data/lib/newsman/stdout_output.rb +3 -1
- data/lib/newsman/txt_output.rb +8 -4
- data/lib/newsman.rb +92 -70
- data/test/test_pdd_issue.rb +48 -0
- data/test/test_report.rb +54 -0
- data/test/test_txtout.rb +7 -5
- data/test/test_week_before.rb +6 -5
- data/test/test_week_of_a_year.rb +7 -5
- metadata +36 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6003cd186c9fc0dc4db267e6c51aecddbf3b1c5de58c63331efc985f3c99f996
|
4
|
+
data.tar.gz: 1255f0f57387649a4ffa9bac8c3e726f6f3e6e37fbd67fef022c17121c297f53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd1258731d17b2df35dd46bd2e74c5b22881fed9370c97430c2246db3a879f8dd7289b07f1fb36429ad3e9ed0320e7b886504ebe0a2b734461a18f702551be04
|
7
|
+
data.tar.gz: 70be6d66ebcc920367f1143212c14ed00feb14f2653c514b7a58e6a8e1b939a3d945d4990888a8264a9224d20cd39717e6bddb0c0d0baa6361c8f8243621fac8
|
data/bin/newsman
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
class Issue
|
5
|
+
attr_accessor :title, :body, :repo, :number
|
6
|
+
|
7
|
+
def initialize(title, body, repo, number)
|
8
|
+
@title = title
|
9
|
+
@body = body
|
10
|
+
@repo = repo
|
11
|
+
@number = number
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
"title: ```#{@title}```,\ndescription: ```#{@body}```,\nrepo: ```#{@repo}```,\nissue number: \##{@number}\n"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class PddIssue
|
20
|
+
|
21
|
+
def initialize(title, body, repo, number)
|
22
|
+
@title = title
|
23
|
+
@body = body
|
24
|
+
@repo = repo
|
25
|
+
@number = number
|
26
|
+
end
|
27
|
+
|
28
|
+
def extract_real_body
|
29
|
+
address = issue_link()
|
30
|
+
line_numbers = address.scan(/#L(\d+)-L(\d+)/).flatten.map(&:to_i)
|
31
|
+
uri = URI(address)
|
32
|
+
return Net::HTTP.get(uri).lines[line_numbers[0]-1..line_numbers[1]]
|
33
|
+
end
|
34
|
+
|
35
|
+
def issue_link
|
36
|
+
return @body[/https:\/\/github\.com\/[\w\-\/]+\/blob\/[\w\d]+\/[\w\/\.\-]+#\w+-\w+/, 0].gsub('https://github.com','https://raw.githubusercontent.com').gsub('blob/', '')
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
"title: ```#{@title}```,\ndescription: ```#{extract_real_body}```,\nrepo: ```#{@repo}```,\nissue number: \##{@number}\n"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
data/lib/newsman/pull_request.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class PullRequest
|
2
4
|
attr_accessor :repository, :title, :description
|
3
5
|
|
@@ -8,6 +10,7 @@ class PullRequest
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def to_s
|
11
|
-
"title: ```#{@title}
|
13
|
+
"title: ```#{@title}```,\ndescription: ```#{@description}```,\nrepo: ```#{@repository}```\n"
|
12
14
|
end
|
13
15
|
end
|
16
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
class Report
|
4
|
+
def initialize(user, position, title)
|
5
|
+
@user = user
|
6
|
+
@position = position
|
7
|
+
@title = title
|
8
|
+
end
|
9
|
+
def build(achievements, plans, date)
|
10
|
+
return "From: #{@user}\nSubject: #{week_of_a_year(@title, date)}\n\nHi all,\n\nLast week achievements:\n#{achievements}\n\nNext week plans:\n#{plans}\n\nRisks:\n- <todo>\n\nBest regards,\n#{@user}\n#{@position}\n#{date}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def week_of_a_year(project, today)
|
15
|
+
number = today.strftime('%U').to_i + 1
|
16
|
+
"WEEK #{number} #{project}"
|
17
|
+
end
|
18
|
+
|
data/lib/newsman/txt_output.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Txtout
|
2
|
-
def initialize(root=
|
3
|
-
@root=root
|
4
|
+
def initialize(root = '.')
|
5
|
+
@root = root
|
4
6
|
end
|
7
|
+
|
5
8
|
def print(report, reporter)
|
6
9
|
puts "Create a file in a directory #{@root}"
|
7
|
-
file = File.new(File.join(@root, filename(reporter)),
|
10
|
+
file = File.new(File.join(@root, filename(reporter)), 'w')
|
8
11
|
puts "File #{file.path} was successfully created"
|
9
12
|
file.puts report
|
10
13
|
puts "Report was successfully printed to a #{file.path}"
|
11
14
|
file.close
|
12
15
|
end
|
16
|
+
|
13
17
|
def filename(reporter)
|
14
18
|
date = Time.new.strftime('%d.%m.%Y')
|
15
|
-
"#{date}.#{reporter}.txt"
|
19
|
+
"#{date}.#{reporter}.txt"
|
16
20
|
end
|
17
21
|
end
|
data/lib/newsman.rb
CHANGED
@@ -1,35 +1,41 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'octokit'
|
4
5
|
require 'openai'
|
5
6
|
require 'dotenv'
|
6
7
|
require 'optparse'
|
7
|
-
require_relative 'newsman/pull_request
|
8
|
-
require_relative 'newsman/
|
9
|
-
require_relative 'newsman/
|
8
|
+
require_relative 'newsman/pull_request'
|
9
|
+
require_relative 'newsman/issues'
|
10
|
+
require_relative 'newsman/stdout_output'
|
11
|
+
require_relative 'newsman/txt_output'
|
12
|
+
require_relative 'newsman/report'
|
10
13
|
|
11
14
|
def generate
|
12
15
|
# Load all options required
|
13
16
|
# Pay attention that some of them have default values.
|
14
17
|
options = {}
|
15
18
|
OptionParser.new do |opts|
|
16
|
-
opts.banner =
|
17
|
-
opts.on(
|
18
|
-
options[:name] = n
|
19
|
+
opts.banner = 'Usage: newsman [options]'
|
20
|
+
opts.on('-n', '--name NAME', 'Reporter name. Human readable name that will be used in a report') do |n|
|
21
|
+
options[:name] = n
|
19
22
|
end
|
20
|
-
opts.on(
|
23
|
+
opts.on('-u', '--username USERNAME', "GitHub username. For example, 'volodya-lombrozo'") do |u|
|
21
24
|
options[:username] = u
|
22
25
|
end
|
23
|
-
opts.on(
|
26
|
+
opts.on('-r', '--repository REPOSITORIES',
|
27
|
+
"Specify which repositories to include in a report. You can specify several repositories using a comma separator, for example: '-r objectionary/jeo-maven-plugin,objectionary/opeo-maven-plugin'") do |r|
|
24
28
|
options[:repositories] = r
|
25
29
|
end
|
26
|
-
opts.on(
|
30
|
+
opts.on('-p', '--position POSITION',
|
31
|
+
"Reporter position in a company. Default value is a 'Software Developer'.") do |p|
|
27
32
|
options[:position] = p
|
28
33
|
end
|
29
|
-
opts.on(
|
34
|
+
opts.on('-o', '--output OUTPUT',
|
35
|
+
"Output type. Newsman prints a report to a stdout by default. You can choose another options like '-o html' or '-o txt'") do |o|
|
30
36
|
options[:output] = o
|
31
37
|
end
|
32
|
-
opts.on(
|
38
|
+
opts.on('-t', '--title TITLE', 'Project Title. Empty by default') do |t|
|
33
39
|
options[:title] = t
|
34
40
|
end
|
35
41
|
end.parse!
|
@@ -39,29 +45,30 @@ def generate
|
|
39
45
|
end
|
40
46
|
|
41
47
|
# Check for required options
|
42
|
-
options.require_option(:name,
|
43
|
-
options.require_option(:username,
|
44
|
-
options.require_option(:repositories,
|
45
|
-
|
46
|
-
options[:
|
47
|
-
options[:
|
48
|
-
|
48
|
+
options.require_option(:name, 'Reporter name is required. Please specify using -n or --name.')
|
49
|
+
options.require_option(:username, 'GitHub username is required. Please specify using -u or --username.')
|
50
|
+
options.require_option(:repositories,
|
51
|
+
'GitHub repository is required. Please specify one or several repositories using -r or --repositories.')
|
52
|
+
options[:position] ||= 'Software Developer'
|
53
|
+
options[:output] ||= 'stdout'
|
54
|
+
options[:title] ||= ''
|
55
|
+
all_params = options.map { |key, value| "#{key}: #{value}" }.join(', ')
|
49
56
|
puts "Parsed parameters: #{all_params}"
|
50
57
|
|
51
58
|
# Load all required environment variables
|
52
59
|
Dotenv.load
|
53
|
-
Dotenv.require_keys(
|
60
|
+
Dotenv.require_keys('GITHUB_TOKEN', 'OPENAI_TOKEN')
|
54
61
|
|
55
62
|
# Init all required parameters
|
56
63
|
# Reporter Info
|
57
64
|
reporter = options[:name]
|
58
65
|
reporter_position = options[:position]
|
59
|
-
# GitHub
|
66
|
+
# GitHub
|
60
67
|
github_username = options[:username]
|
61
|
-
github_repositories = options[:repositories].split(
|
62
|
-
|
68
|
+
github_repositories = options[:repositories].split(',').map { |repo| "repo:#{repo}" }.join(' ')
|
69
|
+
|
63
70
|
# Your GitHub personal access token
|
64
|
-
# Make sure it has the 'repo'
|
71
|
+
# Make sure it has the 'repo'
|
65
72
|
github_token = ENV['GITHUB_TOKEN']
|
66
73
|
# Your OpenAI personal access token
|
67
74
|
openai_token = ENV['OPENAI_TOKEN']
|
@@ -70,70 +77,90 @@ def generate
|
|
70
77
|
# Calculate the date one week ago
|
71
78
|
report_date = Date.today
|
72
79
|
one_week_ago = date_one_week_ago(Date.today)
|
80
|
+
one_month_ago = Date.today.prev_month.strftime('%Y-%m-%d')
|
73
81
|
# Display pull request
|
74
82
|
query = "is:pr author:#{github_username} created:>=#{one_week_ago} #{github_repositories}"
|
83
|
+
issues_query = "is:issue is:open author:#{github_username} author:0pdd created:>=#{one_month_ago} #{github_repositories}"
|
75
84
|
puts "Searching pull requests for #{github_username}."
|
76
85
|
puts "Newsman uses the following request to GitHub to gather the required information about user activity: '#{query}'"
|
77
86
|
prs = []
|
78
87
|
pull_requests = client.search_issues(query)
|
79
88
|
pull_requests.items.each do |pr|
|
80
|
-
title =
|
81
|
-
description =
|
89
|
+
title = pr.title.to_s
|
90
|
+
description = pr.body.to_s
|
82
91
|
repository = pr.repository_url.split('/').last
|
83
92
|
puts "Found PR in #{repository}: #{title}"
|
84
93
|
# Create a new PullRequest object and add it to the list
|
85
94
|
pr = PullRequest.new(repository, title, description)
|
86
95
|
prs << pr
|
87
96
|
end
|
97
|
+
prs = prs.map(&:to_s).join("\n\n\n")
|
98
|
+
|
99
|
+
puts "Searching issues using the following query: '#{issues_query}'"
|
100
|
+
issues = []
|
101
|
+
client.search_issues(issues_query).items.each do |issue|
|
102
|
+
title = issue.title.to_s
|
103
|
+
body = issue.body.to_s
|
104
|
+
repository = issue.repository_url.split('/').last
|
105
|
+
number = issue.number.to_s
|
106
|
+
puts "Found issue in #{repository}:[##{number}] #{title}"
|
107
|
+
if issue.user.login == "0pdd"
|
108
|
+
issues << PddIssue.new(title, body, repository, number)
|
109
|
+
else
|
110
|
+
issues << Issue.new(title, body, repository, number)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
issues = issues.map(&:to_s).join("\n\n\n")
|
114
|
+
#puts "Found issues:\n #{issues}"
|
115
|
+
|
88
116
|
puts "\nNow lets test some aggregation using OpenAI\n\n"
|
89
117
|
openai_client = OpenAI::Client.new(access_token: openai_token)
|
90
118
|
|
91
|
-
|
92
|
-
|
93
|
-
example = "
|
94
|
-
Last week achievements.
|
95
|
-
jeo-meven-plugin:
|
119
|
+
example = "jeo-meven-plugin:
|
96
120
|
- Added 100 new files to the Dataset [#168]
|
97
121
|
- Fixed the deployment of XYZ [#169]
|
98
122
|
- Refined the requirements [#177]
|
99
|
-
opeo-maven-plugin
|
123
|
+
opeo-maven-plugin:
|
100
124
|
- Removed XYZ class [#57]
|
101
|
-
- Refactored http module [#69]
|
125
|
+
- Refactored http module [#69]"
|
102
126
|
|
103
|
-
|
104
|
-
|
105
|
-
-
|
127
|
+
example_plans = "jeo-maven-plugin:
|
128
|
+
- To publish ABC package draft [#27]
|
129
|
+
- To review first draft of the report [#56]
|
106
130
|
opeo-maven-plugin:
|
107
|
-
-
|
131
|
+
- To implement optimization for the class X [#125]"
|
108
132
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
#{
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
133
|
+
response = openai_client.chat(
|
134
|
+
parameters: {
|
135
|
+
model: 'gpt-3.5-turbo',
|
136
|
+
messages: [
|
137
|
+
{ role: 'system',
|
138
|
+
content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
|
139
|
+
{ role: 'user',
|
140
|
+
content: "Please compile a summary of the work completed in the following Pull Requests (PRs). Each PR should be summarized in a single sentence, focusing more on the PR title and less on implementation details. Group the sentences by repositories, each identified by its name mentioned in the 'repository:[name]' attribute of the PR. The grouping is important an should be precise. Ensure that each sentence includes the corresponding issue number as an integer value. If a PR doesn't mention an issue number, just print [#chore]. Combine all the information from each PR into a concise and fluent sentence, as if you were a developer reporting on your work. Please strictly adhere to the example template provided. Example of a report: #{example}. List of Pull Requests: [#{prs}]" }
|
141
|
+
],
|
142
|
+
temperature: 0.3
|
143
|
+
}
|
144
|
+
)
|
145
|
+
answer = response.dig('choices', 0, 'message', 'content')
|
146
|
+
issues_response = openai_client.chat(
|
122
147
|
parameters: {
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
148
|
+
model: 'gpt-3.5-turbo',
|
149
|
+
messages: [
|
150
|
+
{ role: 'system',
|
151
|
+
content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
|
152
|
+
{ role: 'user',
|
153
|
+
content: "Please compile a summary of the plans for the next week using the following GitHub Issues descriptions. Each issue should be summarized in a single sentence, focusing more on the issue title and less on implementation details. Group the sentences by repositories, each identified by its name mentioned in the 'repository:[name]' attribute of the issue. The grouping is important an should be precise. Ensure that each sentence includes the corresponding issue number as an integer value. If an issue doesn't mention an issue number, just print [#chore]. Combine all the information from each Issue into a concise and fluent sentences, as if you were a developer reporting on your work. Please strictly adhere to the example template provided: #{example_plans}. List of GitHub issues to aggregate: [#{issues}]. Use the same formatting as here \n```#{answer}```\n" }
|
154
|
+
],
|
155
|
+
temperature: 0.3
|
156
|
+
}
|
157
|
+
)
|
158
|
+
issues_full_answer = issues_response.dig('choices', 0, 'message', 'content')
|
130
159
|
output_mode = options[:output]
|
131
160
|
puts "Output mode is '#{output_mode}'"
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
if output_mode.eql? "txt"
|
136
|
-
output = Txtout.new(".")
|
161
|
+
full_answer = Report.new(reporter, reporter_position, options[:title]).build(answer, issues_full_answer, Date.today)
|
162
|
+
if output_mode.eql? 'txt'
|
163
|
+
output = Txtout.new('.')
|
137
164
|
output.print(full_answer, github_username)
|
138
165
|
else
|
139
166
|
output = Stdout.new
|
@@ -141,25 +168,20 @@ response = openai_client.chat(
|
|
141
168
|
end
|
142
169
|
end
|
143
170
|
|
144
|
-
|
145
171
|
def date_one_week_ago(today)
|
146
172
|
# Convert today to a Date object if it's not already
|
147
173
|
today = Date.parse(today) unless today.is_a?(Date)
|
148
174
|
# Subtract 7 days to get the date one week ago
|
149
175
|
one_week_ago = today - 7
|
150
176
|
# Format the date as "YYYY-MM-DD"
|
151
|
-
|
177
|
+
one_week_ago.strftime('%Y-%m-%d')
|
152
178
|
# Return the formatted date
|
153
|
-
return formatted_date
|
154
179
|
end
|
155
180
|
|
156
181
|
def week_of_a_year(project, today)
|
157
|
-
number =
|
158
|
-
|
182
|
+
number = today.strftime('%U').to_i + 1
|
183
|
+
"WEEK #{number} #{project}"
|
159
184
|
end
|
160
185
|
|
161
186
|
# Execute the function only if this script is run directly like `./newsman.rb`
|
162
|
-
if __FILE__ == $
|
163
|
-
generate()
|
164
|
-
end
|
165
|
-
|
187
|
+
generate if __FILE__ == $PROGRAM_NAME
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright (c) 2024 Volodya Lombrozo
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
|
24
|
+
require 'minitest/autorun'
|
25
|
+
require_relative '../lib/newsman/issues'
|
26
|
+
|
27
|
+
class TestPddIssue < Minitest::Test
|
28
|
+
TEST_BODY = "
|
29
|
+
The puzzle `531-462261de` from #531 has to be resolved:
|
30
|
+
|
31
|
+
https://github.com/objectionary/jeo-maven-plugin/blob/5a42b2c9f7e0ff01cbb2c4626e1dc5dc3f8aa7b8/src/it/annotations/src/main/java/org/eolang/jeo/annotations/AnnotationsApplication.java#L32-L35
|
32
|
+
|
33
|
+
The puzzle was created by @volodya-lombrozo on 29-Mar-24.
|
34
|
+
|
35
|
+
Estimate: 90 minutes, role: DEV.
|
36
|
+
|
37
|
+
If you have any technical questions, don't ask me, submit new tickets instead. The task will be \"done\" when the problem is fixed and the text of the puzzle is _removed_ from the source code. Here is more about [PDD](http://www.yegor256.com/2009/03/04/pdd.html) and [about me](http://www.yegor256.com/2017/04/05/pdd-in-action.html).
|
38
|
+
"
|
39
|
+
|
40
|
+
EXPECTED_DESCRIPTION = " * @todo #531:90min Check default values for annotation properties.\n", " * We still encounter some problems with annotation processing.\n", " * Especially with Autowired annotation from Spring Framework.\n", " * It's relatively simple annotation, but it's not processed correctly.\n", " */\n"
|
41
|
+
|
42
|
+
def test_parses_pdd_issue
|
43
|
+
issue = PddIssue.new('AnnotationsApplication.java:32-35: Check default values...',
|
44
|
+
TEST_BODY,
|
45
|
+
'jeo-maven-plugin', 531)
|
46
|
+
assert_equal(EXPECTED_DESCRIPTION, issue.extract_real_body)
|
47
|
+
end
|
48
|
+
end
|
data/test/test_report.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright (c) 2024 Volodya Lombrozo
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
|
24
|
+
require 'minitest/autorun'
|
25
|
+
require_relative '../lib/newsman/report.rb'
|
26
|
+
|
27
|
+
class TestReport < Minitest::Test
|
28
|
+
def test_report
|
29
|
+
expected = "From: User
|
30
|
+
Subject: WEEK 11 Project
|
31
|
+
|
32
|
+
Hi all,
|
33
|
+
|
34
|
+
Last week achievements:
|
35
|
+
repository-a:
|
36
|
+
- Did a lot of for (a) repository
|
37
|
+
|
38
|
+
Next week plans:
|
39
|
+
repository-b:
|
40
|
+
- I will do a lot for repository (b)
|
41
|
+
|
42
|
+
Risks:
|
43
|
+
- <todo>
|
44
|
+
|
45
|
+
Best regards,
|
46
|
+
User
|
47
|
+
Developer
|
48
|
+
2024-03-14"
|
49
|
+
report = Report.new('User', 'Developer', 'Project')
|
50
|
+
out = report.build("repository-a:\n - Did a lot of for (a) repository", "repository-b:\n - I will do a lot for repository (b)", Date.new(2024, 3, 14))
|
51
|
+
assert_equal expected, out
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/test/test_txtout.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright (c) 2024 Volodya Lombrozo
|
3
5
|
#
|
4
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -20,15 +22,15 @@
|
|
20
22
|
# SOFTWARE.
|
21
23
|
|
22
24
|
require 'minitest/autorun'
|
23
|
-
require_relative '../lib/newsman/txt_output
|
25
|
+
require_relative '../lib/newsman/txt_output'
|
24
26
|
|
25
27
|
class TestTxtout < Minitest::Test
|
26
28
|
def test_writes_to_a_file
|
27
|
-
Dir.mktmpdir do |temp_dir|
|
29
|
+
Dir.mktmpdir do |temp_dir|
|
28
30
|
output = Txtout.new(temp_dir)
|
29
|
-
today = Date.today.strftime(
|
31
|
+
today = Date.today.strftime('%d.%m.%Y')
|
30
32
|
expected = "#{today}.volodya-lombrozo.txt"
|
31
|
-
output.print(
|
33
|
+
output.print('496', 'volodya-lombrozo')
|
32
34
|
puts "Expected #{expected}"
|
33
35
|
assert(File.exist?(File.join(temp_dir, expected)))
|
34
36
|
assert_equal("496\n", File.read(File.join(temp_dir, expected)))
|
data/test/test_week_before.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright (c) 2024 Volodya Lombrozo
|
3
5
|
#
|
4
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -20,12 +22,11 @@
|
|
20
22
|
# SOFTWARE.
|
21
23
|
|
22
24
|
require 'minitest/autorun'
|
23
|
-
require_relative '../lib/newsman
|
25
|
+
require_relative '../lib/newsman'
|
24
26
|
|
25
27
|
class TestDateOneWeekAgo < Minitest::Test
|
26
28
|
def test_date_one_week_ago
|
27
|
-
assert_equal
|
28
|
-
assert_equal
|
29
|
+
assert_equal '2024-03-07', date_one_week_ago(Date.new(2024, 3, 14))
|
30
|
+
assert_equal '2024-02-29', date_one_week_ago(Date.new(2024, 3, 7))
|
29
31
|
end
|
30
32
|
end
|
31
|
-
|
data/test/test_week_of_a_year.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright (c) 2024 Volodya Lombrozo
|
3
5
|
#
|
4
6
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
7
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -20,12 +22,12 @@
|
|
20
22
|
# SOFTWARE.
|
21
23
|
|
22
24
|
require 'minitest/autorun'
|
23
|
-
require_relative '../lib/newsman
|
25
|
+
require_relative '../lib/newsman'
|
24
26
|
|
25
27
|
class TestWeekOfYear < Minitest::Test
|
26
|
-
def test_week_of_a_year
|
27
|
-
assert_equal
|
28
|
-
assert_equal
|
28
|
+
def test_week_of_a_year
|
29
|
+
assert_equal 'WEEK 11 JEO', week_of_a_year('JEO', Date.new(2024, 3, 14))
|
30
|
+
assert_equal 'WEEK 9 OPEO', week_of_a_year('OPEO', Date.new(2024, 2, 29))
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newsman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volodya Lombrozo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.22'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.22'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -25,61 +39,61 @@ dependencies:
|
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '3.2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: dotenv
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
47
|
+
version: '3.1'
|
48
|
+
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '3.1'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: faraday-retry
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '2.2'
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '2.2'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: octokit
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: '8.0'
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: '8.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: optparse
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
89
|
+
version: 0.4.0
|
76
90
|
type: :runtime
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
96
|
+
version: 0.4.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: ruby-openai
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,19 +109,19 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '6.3'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: net-http
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
117
|
+
version: '0.4'
|
104
118
|
type: :runtime
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
124
|
+
version: '0.4'
|
111
125
|
description: A simple gem that gathers GitHub statistics and creates human-readable
|
112
126
|
report
|
113
127
|
email:
|
@@ -121,9 +135,13 @@ files:
|
|
121
135
|
- README.md
|
122
136
|
- bin/newsman
|
123
137
|
- lib/newsman.rb
|
138
|
+
- lib/newsman/issues.rb
|
124
139
|
- lib/newsman/pull_request.rb
|
140
|
+
- lib/newsman/report.rb
|
125
141
|
- lib/newsman/stdout_output.rb
|
126
142
|
- lib/newsman/txt_output.rb
|
143
|
+
- test/test_pdd_issue.rb
|
144
|
+
- test/test_report.rb
|
127
145
|
- test/test_txtout.rb
|
128
146
|
- test/test_week_before.rb
|
129
147
|
- test/test_week_of_a_year.rb
|