newsman 0.1.10 → 0.1.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1183add95adc6b8574a0c0ffaa9dc50b472edaf3daa2219d9a48b4b0887c822e
4
- data.tar.gz: a74b77f973ff3fee1d9ebd455ab13148d748d9dfa34ca4f328223957f3f672ad
3
+ metadata.gz: 47097e4e1db8dbfaa84c2aa58d8d9a13294cab2ab471a5927f1d083327a713db
4
+ data.tar.gz: 48ea4b8237d6daff81c15bbfc7786850c820a2a3bcceb931332594c5f5e2a02e
5
5
  SHA512:
6
- metadata.gz: aa81431ca58fe417bd8208ada0b642d121faa5c07f3b4633fe43fc12340e938d84688f23f4027d4eb7f9a491ce2f6105ab36a28f77db8248aca7a368623711f4
7
- data.tar.gz: 8c03d5d177c3e9d9b2caf7add86e210429afd52a174506b8333466c80ac47a3e72b313d27a9c7be673914a9d10ce80b81ea2a46871173dd0590f47598176a3b6
6
+ metadata.gz: 662c512d37c279e44957de12a6d2825a266f048edf350ea5e272d23b88f7b35df0461c9eef3478e8e75e1623d6a8f5240d9000bd865d99498285dfec69ffd5bd
7
+ data.tar.gz: 764561fef8f5de1aea6cfa05983b767bc6d40707d82c9e8b5aaa96faffac4815bc934078852d03ec89be6b8f5445e45c9611666fef5b2a3bff26cb3b8bcd19d3
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'erb'
2
4
  require 'redcarpet'
3
5
  require 'nokogiri'
4
6
  # frozen_string_literal: true
5
7
 
6
8
  class Htmlout
7
-
8
9
  TEMPLATE = "
9
10
  <head>
10
11
  <title><%= title %></title>
@@ -18,9 +19,9 @@ class Htmlout
18
19
  def initialize(root = '.')
19
20
  @root = root
20
21
  end
21
-
22
+
22
23
  def print(report, reporter)
23
- title = title(reporter)
24
+ title = title(reporter)
24
25
  renderer = Redcarpet::Render::HTML.new(no_links: true, hard_wrap: true, prettify: true)
25
26
  markdown = Redcarpet::Markdown.new(renderer, autolink: true, tables: true)
26
27
  body = markdown.render(report)
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/http'
2
4
  # frozen_string_literal: true
3
5
 
4
- class Issue
6
+ class Issue
5
7
  attr_accessor :title, :body, :repo, :number
6
8
 
7
9
  def initialize(title, body, repo, number)
@@ -17,7 +19,6 @@ class Issue
17
19
  end
18
20
 
19
21
  class PddIssue
20
-
21
22
  def initialize(title, body, repo, number)
22
23
  @title = title
23
24
  @body = body
@@ -26,18 +27,19 @@ class PddIssue
26
27
  end
27
28
 
28
29
  def extract_real_body
29
- address = issue_link()
30
+ address = issue_link
30
31
  line_numbers = address.scan(/#L(\d+)-L(\d+)/).flatten.map(&:to_i)
31
32
  uri = URI(address)
32
- return Net::HTTP.get(uri).lines[line_numbers[0]-1..line_numbers[1]]
33
+ Net::HTTP.get(uri).lines[line_numbers[0] - 1..line_numbers[1]]
33
34
  end
34
35
 
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/', '')
36
+ def issue_link
37
+ @body[%r{https://github\.com/[\w\-/]+/blob/[\w\d]+/[\w/.-]+#\w+-\w+}, 0].gsub('https://github.com', 'https://raw.githubusercontent.com').gsub(
38
+ 'blob/', ''
39
+ )
37
40
  end
38
41
 
39
42
  def to_s
40
43
  "title: ```#{@title}```,\ndescription: ```#{extract_real_body}```,\nrepo: ```#{@repo}```,\nissue number: \##{@number}\n"
41
44
  end
42
45
  end
43
-
@@ -13,4 +13,3 @@ class PullRequest
13
13
  "title: ```#{@title}```,\ndescription: ```#{@description}```,\nrepo: ```#{@repository}```\n"
14
14
  end
15
15
  end
16
-
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  class Report
4
5
  def initialize(user, position, title)
@@ -6,8 +7,10 @@ class Report
6
7
  @position = position
7
8
  @title = title
8
9
  end
10
+
9
11
  def build(achievements, plans, risks, 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#{risks}\n\nBest regards,\n#{@user}\n#{@position}\n#{date}"
12
+ "From: #{@user}\nSubject: #{week_of_a_year(@title,
13
+ date)}\n\nHi all,\n\nLast week achievements:\n#{achievements}\n\nNext week plans:\n#{plans}\n\nRisks:\n#{risks}\n\nBest regards,\n#{@user}\n#{@position}\n#{date}"
11
14
  end
12
15
  end
13
16
 
@@ -15,4 +18,3 @@ def week_of_a_year(project, today)
15
18
  number = today.strftime('%U').to_i + 1
16
19
  "WEEK #{number} #{project}"
17
20
  end
18
-
data/lib/newsman.rb CHANGED
@@ -76,7 +76,6 @@ def generate
76
76
  # Create a GitHub client instance with your access token
77
77
  client = Octokit::Client.new(github_token: github_token)
78
78
  # Calculate the date one week ago
79
- report_date = Date.today
80
79
  one_week_ago = date_one_week_ago(Date.today)
81
80
  one_month_ago = Date.today.prev_month.strftime('%Y-%m-%d')
82
81
  # Display pull request
@@ -96,7 +95,7 @@ def generate
96
95
  prs << pr
97
96
  end
98
97
  prs = prs.map(&:to_s).join("\n\n\n")
99
-
98
+
100
99
  puts "Searching issues using the following query: '#{issues_query}'"
101
100
  issues = []
102
101
  client.search_issues(issues_query).items.each do |issue|
@@ -105,15 +104,15 @@ def generate
105
104
  repository = issue.repository_url.split('/').last
106
105
  number = issue.number.to_s
107
106
  puts "Found issue in #{repository}:[##{number}] #{title}"
108
- if issue.user.login == "0pdd"
109
- issues << PddIssue.new(title, body, repository, number)
110
- else
111
- issues << Issue.new(title, body, repository, number)
112
- end
107
+ issues << if issue.user.login == '0pdd'
108
+ PddIssue.new(title, body, repository, number)
109
+ else
110
+ Issue.new(title, body, repository, number)
111
+ end
113
112
  end
114
113
  issues = issues.map(&:to_s).join("\n\n\n")
115
- #puts "Found issues:\n #{issues}"
116
-
114
+ # puts "Found issues:\n #{issues}"
115
+
117
116
  puts "\nNow lets test some aggregation using OpenAI\n\n"
118
117
  openai_client = OpenAI::Client.new(access_token: openai_token)
119
118
 
@@ -162,10 +161,9 @@ some-repository-name-y:
162
161
  ],
163
162
  temperature: 0.3
164
163
  }
165
- )
164
+ )
166
165
  issues_full_answer = issues_response.dig('choices', 0, 'message', 'content')
167
166
 
168
-
169
167
  risks_full_answer = openai_client.chat(
170
168
  parameters: {
171
169
  model: 'gpt-3.5-turbo',
@@ -173,26 +171,26 @@ some-repository-name-y:
173
171
  { role: 'system',
174
172
  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.' },
175
173
  { role: 'user',
176
- content: "Please compile a summary of the risks identified in some repositories. If you can't find anything, just leave answer empty. Add some entries to a report only if you are sure it's a risk. Developers usually mention some risks in pull request descriptions. They either mention 'risk' or 'issue'. I will give you a list of pull requests. Each risk should be summarized in a single sentence. Ensure that each sentence includes the corresponding issue number or PR number as an integer value. If a PR or an issue 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_risks}. List of Pull Requests: ```#{prs}```.]"}
174
+ content: "Please compile a summary of the risks identified in some repositories. If you can't find anything, just leave answer empty. Add some entries to a report only if you are sure it's a risk. Developers usually mention some risks in pull request descriptions. They either mention 'risk' or 'issue'. I will give you a list of pull requests. Each risk should be summarized in a single sentence. Ensure that each sentence includes the corresponding issue number or PR number as an integer value. If a PR or an issue 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_risks}. List of Pull Requests: ```#{prs}```.]" }
177
175
  ],
178
176
  temperature: 0.3
179
177
  }
180
178
  ).dig('choices', 0, 'message', 'content')
181
179
 
182
-
183
180
  output_mode = options[:output]
184
181
  puts "Output mode is '#{output_mode}'"
185
- full_answer = Report.new(reporter, reporter_position, options[:title]).build(answer, issues_full_answer, risks_full_answer, Date.today)
182
+ full_answer = Report.new(reporter, reporter_position, options[:title]).build(answer, issues_full_answer,
183
+ risks_full_answer, Date.today)
186
184
  if output_mode.eql? 'txt'
187
- puts "Print result to txy file"
185
+ puts 'Print result to txy file'
188
186
  output = Txtout.new('.')
189
187
  output.print(full_answer, github_username)
190
188
  elsif output_mode.eql? 'html'
191
- puts "Print result to html file"
189
+ puts 'Print result to html file'
192
190
  output = Htmlout.new('.')
193
191
  output.print(full_answer, github_username)
194
192
  else
195
- puts "Print result to stdout"
193
+ puts 'Print result to stdout'
196
194
  output = Stdout.new
197
195
  output.print(full_answer)
198
196
  end
data/test/test_htmlout.rb CHANGED
@@ -25,9 +25,7 @@ require 'minitest/autorun'
25
25
  require_relative '../lib/newsman/html_output'
26
26
 
27
27
  class TestHtmlout < Minitest::Test
28
-
29
-
30
- EXPECTED = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
28
+ EXPECTED = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
31
29
  <html>
32
30
  <head>
33
31
  <title>volodya-lombrozo #{Time.new.strftime('%d.%m.%Y')}</title>
@@ -51,7 +49,8 @@ List is here:<br/>
51
49
  output = Htmlout.new(temp_dir)
52
50
  today = Date.today.strftime('%d.%m.%Y')
53
51
  expected = "#{today}.volodya-lombrozo.html"
54
- output.print("Issue description\n\nHere is a new paragraph\nList is here:\n - one\n - two\n - three", 'volodya-lombrozo')
52
+ output.print("Issue description\n\nHere is a new paragraph\nList is here:\n - one\n - two\n - three",
53
+ 'volodya-lombrozo')
55
54
  assert(File.exist?(File.join(temp_dir, expected)))
56
55
  assert_equal(EXPECTED, File.read(File.join(temp_dir, expected)))
57
56
  end
@@ -26,22 +26,23 @@ require_relative '../lib/newsman/issues'
26
26
 
27
27
  class TestPddIssue < Minitest::Test
28
28
  TEST_BODY = "
29
- The puzzle `531-462261de` from #531 has to be resolved:
29
+ The puzzle `531-462261de` from #531 has to be resolved:
30
30
 
31
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
32
 
33
- The puzzle was created by @volodya-lombrozo on 29-Mar-24.
33
+ The puzzle was created by @volodya-lombrozo on 29-Mar-24.
34
34
 
35
- Estimate: 90 minutes, role: DEV.
35
+ Estimate: 90 minutes, role: DEV.
36
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).
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
38
  "
39
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"
40
+ EXPECTED_DESCRIPTION = [" * @todo #531:90min Check default values for annotation properties.\n",
41
+ " * 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"].freeze
41
42
 
42
43
  def test_parses_pdd_issue
43
44
  issue = PddIssue.new('AnnotationsApplication.java:32-35: Check default values...',
44
- TEST_BODY,
45
+ TEST_BODY,
45
46
  'jeo-maven-plugin', 531)
46
47
  assert_equal(EXPECTED_DESCRIPTION, issue.extract_real_body)
47
48
  end
data/test/test_report.rb CHANGED
@@ -22,7 +22,7 @@
22
22
  # SOFTWARE.
23
23
 
24
24
  require 'minitest/autorun'
25
- require_relative '../lib/newsman/report.rb'
25
+ require_relative '../lib/newsman/report'
26
26
 
27
27
  class TestReport < Minitest::Test
28
28
  def test_report
@@ -47,8 +47,8 @@ User
47
47
  Developer
48
48
  2024-03-14"
49
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)", "- <todo>", Date.new(2024, 3, 14))
50
+ out = report.build("repository-a:\n - Did a lot of for (a) repository",
51
+ "repository-b:\n - I will do a lot for repository (b)", '- <todo>', Date.new(2024, 3, 14))
51
52
  assert_equal expected, out
52
53
  end
53
54
  end
54
-
@@ -30,4 +30,3 @@ class TestWeekOfYear < Minitest::Test
30
30
  assert_equal 'WEEK 9 OPEO', week_of_a_year('OPEO', Date.new(2024, 2, 29))
31
31
  end
32
32
  end
33
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newsman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
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-04-08 00:00:00.000000000 Z
11
+ date: 2024-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -67,61 +67,61 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.2'
69
69
  - !ruby/object:Gem::Dependency
70
- name: octokit
70
+ name: net-http
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '8.0'
75
+ version: '0.4'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '8.0'
82
+ version: '0.4'
83
83
  - !ruby/object:Gem::Dependency
84
- name: optparse
84
+ name: nokogiri
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.4.0
89
+ version: '1.16'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.4.0
96
+ version: '1.16'
97
97
  - !ruby/object:Gem::Dependency
98
- name: ruby-openai
98
+ name: octokit
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '6.3'
103
+ version: '8.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '6.3'
110
+ version: '8.0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: net-http
112
+ name: optparse
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.4'
117
+ version: 0.4.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0.4'
124
+ version: 0.4.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: redcarpet
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -137,19 +137,19 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '3.6'
139
139
  - !ruby/object:Gem::Dependency
140
- name: nokogiri
140
+ name: ruby-openai
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.16'
145
+ version: '6.3'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '1.16'
152
+ version: '6.3'
153
153
  description: A simple gem that gathers GitHub statistics and creates human-readable
154
154
  report
155
155
  email: