newsman 0.1.11 → 0.1.13
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 +4 -4
- data/README.md +1 -1
- data/lib/newsman/issues.rb +15 -2
- data/lib/newsman/pull_request.rb +8 -1
- data/lib/newsman/report.rb +29 -2
- data/lib/newsman.rb +6 -4
- data/test/test_report.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0b76df23c180a0cc0a30bdc4d60fd675ece0c5201605bcbdea44bd0a7d25bce
|
4
|
+
data.tar.gz: 72e37a051f065fcc3a625ba3175439b1351e28acc6e0b2cc33a352c3f5dda652
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e66602a260c38095c76e367b8a84f52f1f16bc6a74b103e3b0c0e6e8690e8bea1d1d54b41ca97cc0c259c55b571485e788864b3f788251730759ffd19ce356ec
|
7
|
+
data.tar.gz: e4d0aef6d9a2958084402468adc84f2e24d8f7da507ea8a2dab7515f5855411f6e6a73e1969a4cc30f413e180eee2ceaab520c5addb7d59fa780090516dc7e76
|
data/README.md
CHANGED
@@ -65,4 +65,4 @@ And you should see a welcome message from newsman.
|
|
65
65
|
|
66
66
|
## Examples
|
67
67
|
|
68
|
-
You can find examples of generated reports [here](https://
|
68
|
+
You can find examples of generated reports [here](https://volodya-lombrozo.github.io/newsman/)
|
data/lib/newsman/issues.rb
CHANGED
@@ -5,25 +5,33 @@ require 'net/http'
|
|
5
5
|
|
6
6
|
class Issue
|
7
7
|
attr_accessor :title, :body, :repo, :number
|
8
|
+
attr_reader :url
|
8
9
|
|
9
|
-
def initialize(title, body, repo, number)
|
10
|
+
def initialize(title, body, repo, number, url: 'undefined')
|
10
11
|
@title = title
|
11
12
|
@body = body
|
12
13
|
@repo = repo
|
13
14
|
@number = number
|
15
|
+
@url = url
|
14
16
|
end
|
15
17
|
|
16
18
|
def to_s
|
17
19
|
"title: ```#{@title}```,\ndescription: ```#{@body}```,\nrepo: ```#{@repo}```,\nissue number: \##{@number}\n"
|
18
20
|
end
|
21
|
+
|
22
|
+
def detailed_title
|
23
|
+
"title: #{@title}, repo: #{@repo}, number: \##{@number}, url: #{@url}"
|
24
|
+
end
|
25
|
+
|
19
26
|
end
|
20
27
|
|
21
28
|
class PddIssue
|
22
|
-
def initialize(title, body, repo, number)
|
29
|
+
def initialize(title, body, repo, number, url: 'undefined')
|
23
30
|
@title = title
|
24
31
|
@body = body
|
25
32
|
@repo = repo
|
26
33
|
@number = number
|
34
|
+
@url = url
|
27
35
|
end
|
28
36
|
|
29
37
|
def extract_real_body
|
@@ -42,4 +50,9 @@ class PddIssue
|
|
42
50
|
def to_s
|
43
51
|
"title: ```#{@title}```,\ndescription: ```#{extract_real_body}```,\nrepo: ```#{@repo}```,\nissue number: \##{@number}\n"
|
44
52
|
end
|
53
|
+
|
54
|
+
def detailed_title
|
55
|
+
"title: #{@title}, repo: #{@repo}, issue number: \##{@number}, url: #{@url}"
|
56
|
+
end
|
57
|
+
|
45
58
|
end
|
data/lib/newsman/pull_request.rb
CHANGED
@@ -2,14 +2,21 @@
|
|
2
2
|
|
3
3
|
class PullRequest
|
4
4
|
attr_accessor :repository, :title, :description
|
5
|
+
attr_reader :url
|
5
6
|
|
6
|
-
def initialize(repository, title, description)
|
7
|
+
def initialize(repository, title, description, url: 'undefined')
|
7
8
|
@repository = repository
|
8
9
|
@title = title
|
9
10
|
@description = description
|
11
|
+
@url = url
|
10
12
|
end
|
11
13
|
|
12
14
|
def to_s
|
13
15
|
"title: ```#{@title}```,\ndescription: ```#{@description}```,\nrepo: ```#{@repository}```\n"
|
14
16
|
end
|
17
|
+
|
18
|
+
def detailed_title
|
19
|
+
"title: #{@title}, repo: #{@repository}, url: #{@url}"
|
20
|
+
end
|
21
|
+
|
15
22
|
end
|
data/lib/newsman/report.rb
CHANGED
@@ -2,15 +2,22 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
class Report
|
5
|
-
def initialize(user, position, title)
|
5
|
+
def initialize(user, position, title, additional: ReportItems.new([],[]))
|
6
6
|
@user = user
|
7
7
|
@position = position
|
8
8
|
@title = title
|
9
|
+
@additional = additional
|
9
10
|
end
|
10
11
|
|
11
12
|
def build(achievements, plans, risks, date)
|
12
|
-
"From: #{@user}\nSubject: #{week_of_a_year(@title,
|
13
|
+
start = "From: #{@user}\nSubject: #{week_of_a_year(@title,
|
13
14
|
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}"
|
15
|
+
|
16
|
+
finish = ''
|
17
|
+
if !@additional.empty?
|
18
|
+
finish = "\n------\n" + @additional.to_s
|
19
|
+
end
|
20
|
+
return start + finish;
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
@@ -18,3 +25,23 @@ def week_of_a_year(project, today)
|
|
18
25
|
number = today.strftime('%U').to_i + 1
|
19
26
|
"WEEK #{number} #{project}"
|
20
27
|
end
|
28
|
+
|
29
|
+
|
30
|
+
class ReportItems
|
31
|
+
|
32
|
+
def initialize(prs, issues)
|
33
|
+
@prs = prs || []
|
34
|
+
@issues = issues || []
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns true if there are no pull requests or issues, false otherwise
|
38
|
+
def empty?
|
39
|
+
@prs.empty? && @issues.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_s
|
43
|
+
prs_list = @prs.map(&:detailed_title).map { |obj| " - #{obj}\n" }.join
|
44
|
+
issues_list = @issues.map(&:detailed_title).map { |obj| " - #{obj}\n" }.join
|
45
|
+
return "Closed Pull Requests:\n#{prs_list}\nOpen Issues:\n#{issues_list}"
|
46
|
+
end
|
47
|
+
end
|
data/lib/newsman.rb
CHANGED
@@ -91,9 +91,10 @@ def generate
|
|
91
91
|
repository = pr.repository_url.split('/').last
|
92
92
|
puts "Found PR in #{repository}: #{title}"
|
93
93
|
# Create a new PullRequest object and add it to the list
|
94
|
-
pr = PullRequest.new(repository, title, description)
|
94
|
+
pr = PullRequest.new(repository, title, description, url: pr.html_url)
|
95
95
|
prs << pr
|
96
96
|
end
|
97
|
+
raw_prs = prs
|
97
98
|
prs = prs.map(&:to_s).join("\n\n\n")
|
98
99
|
|
99
100
|
puts "Searching issues using the following query: '#{issues_query}'"
|
@@ -105,11 +106,12 @@ def generate
|
|
105
106
|
number = issue.number.to_s
|
106
107
|
puts "Found issue in #{repository}:[##{number}] #{title}"
|
107
108
|
issues << if issue.user.login == '0pdd'
|
108
|
-
PddIssue.new(title, body, repository, number)
|
109
|
+
PddIssue.new(title, body, repository, number, url: issue.html_url)
|
109
110
|
else
|
110
|
-
Issue.new(title, body, repository, number)
|
111
|
+
Issue.new(title, body, repository, number, url: issue.html_url)
|
111
112
|
end
|
112
113
|
end
|
114
|
+
raw_issues = issues
|
113
115
|
issues = issues.map(&:to_s).join("\n\n\n")
|
114
116
|
# puts "Found issues:\n #{issues}"
|
115
117
|
|
@@ -179,7 +181,7 @@ some-repository-name-y:
|
|
179
181
|
|
180
182
|
output_mode = options[:output]
|
181
183
|
puts "Output mode is '#{output_mode}'"
|
182
|
-
full_answer = Report.new(reporter, reporter_position, options[:title]).build(answer, issues_full_answer,
|
184
|
+
full_answer = Report.new(reporter, reporter_position, options[:title], additional: ReportItems.new(raw_prs, raw_issues)).build(answer, issues_full_answer,
|
183
185
|
risks_full_answer, Date.today)
|
184
186
|
if output_mode.eql? 'txt'
|
185
187
|
puts 'Print result to txy file'
|
data/test/test_report.rb
CHANGED
@@ -23,6 +23,8 @@
|
|
23
23
|
|
24
24
|
require 'minitest/autorun'
|
25
25
|
require_relative '../lib/newsman/report'
|
26
|
+
require_relative '../lib/newsman/issues'
|
27
|
+
require_relative '../lib/newsman/pull_request'
|
26
28
|
|
27
29
|
class TestReport < Minitest::Test
|
28
30
|
def test_report
|
@@ -51,4 +53,16 @@ Developer
|
|
51
53
|
"repository-b:\n - I will do a lot for repository (b)", '- <todo>', Date.new(2024, 3, 14))
|
52
54
|
assert_equal expected, out
|
53
55
|
end
|
56
|
+
|
57
|
+
def test_report_items
|
58
|
+
expected = "Closed Pull Requests:\n - title: title, repo: repo, url: http://some.url.com\n\nOpen Issues:\n - title: title, repo: repo, number: #123, url: http://google.com\n"
|
59
|
+
issues = [ Issue::new('title', 'body', 'repo', '123', url: 'http://google.com')]
|
60
|
+
prs = [ PullRequest::new('repo', 'title', 'body', url: 'http://some.url.com') ]
|
61
|
+
actual = ReportItems.new(prs, issues).to_s
|
62
|
+
|
63
|
+
puts actual
|
64
|
+
assert_equal expected, actual
|
65
|
+
end
|
66
|
+
|
67
|
+
|
54
68
|
end
|
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.
|
4
|
+
version: 0.1.13
|
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-
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|