newsman 0.1.7 → 0.1.9
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/lib/newsman/html_output.rb +45 -0
- data/lib/newsman/issues.rb +26 -0
- data/lib/newsman.rb +13 -2
- data/test/test_htmlout.rb +52 -0
- data/test/test_pdd_issue.rb +48 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2394e606a441d219f1b63d81957596975476de4da4a8cf2a8565638d9e5fd31e
|
4
|
+
data.tar.gz: 10c89c9e91a89fde8c67822d72ada6de3cf731b1c3a7fc9aa9d0e7ad90c1f43a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d649675bf107b488ce5c8644414589419518e9f8f8ea497d80da5a3810de6fecc1a1f346fbd4c06a84f41e979df890af50ec89bbc89ed34056af5b7467f40dce
|
7
|
+
data.tar.gz: 7de3191d99baee21f3346434d6aeb6550e9bb07e8f9a944215958206cd94a1176f367f699b84778a063227a165bf4e065bccbe48def5e8d9b1ae33eb6a59d2fc
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'erb'
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
class Htmlout
|
5
|
+
|
6
|
+
TEMPLATE = "<!DOCTYPE html>
|
7
|
+
<html lang=\"en\">
|
8
|
+
<head>
|
9
|
+
<meta charset=\"UTF-8\">
|
10
|
+
<title><%= title %></title>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1><%= title %></h1>
|
14
|
+
<p><%= body %></p>
|
15
|
+
</body>
|
16
|
+
</html>
|
17
|
+
"
|
18
|
+
|
19
|
+
def initialize(root = '.')
|
20
|
+
@root = root
|
21
|
+
end
|
22
|
+
|
23
|
+
def print(report, reporter)
|
24
|
+
title = title(reporter)
|
25
|
+
body = report
|
26
|
+
renderer = ERB.new(TEMPLATE)
|
27
|
+
html_content = renderer.result(binding)
|
28
|
+
puts "Create a html file in a directory #{@root}"
|
29
|
+
file = File.new(File.join(@root, filename(reporter)), 'w')
|
30
|
+
puts "File #{file.path} was successfully created"
|
31
|
+
file.puts html_content
|
32
|
+
puts "Report was successfully printed to a #{file.path}"
|
33
|
+
file.close
|
34
|
+
end
|
35
|
+
|
36
|
+
def title(reporter)
|
37
|
+
date = Time.new.strftime('%d.%m.%Y')
|
38
|
+
"#{reporter} #{date}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def filename(reporter)
|
42
|
+
date = Time.new.strftime('%d.%m.%Y')
|
43
|
+
"#{date}.#{reporter}.html"
|
44
|
+
end
|
45
|
+
end
|
data/lib/newsman/issues.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'net/http'
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
class Issue
|
@@ -15,3 +16,28 @@ class Issue
|
|
15
16
|
end
|
16
17
|
end
|
17
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.rb
CHANGED
@@ -9,6 +9,7 @@ require_relative 'newsman/pull_request'
|
|
9
9
|
require_relative 'newsman/issues'
|
10
10
|
require_relative 'newsman/stdout_output'
|
11
11
|
require_relative 'newsman/txt_output'
|
12
|
+
require_relative 'newsman/html_output'
|
12
13
|
require_relative 'newsman/report'
|
13
14
|
|
14
15
|
def generate
|
@@ -32,7 +33,7 @@ def generate
|
|
32
33
|
options[:position] = p
|
33
34
|
end
|
34
35
|
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
|
36
|
+
"Output type. Newsman prints a report to a stdout by default. You can choose another options like '-o html', '-o txt' or even '-o html'") do |o|
|
36
37
|
options[:output] = o
|
37
38
|
end
|
38
39
|
opts.on('-t', '--title TITLE', 'Project Title. Empty by default') do |t|
|
@@ -104,7 +105,11 @@ def generate
|
|
104
105
|
repository = issue.repository_url.split('/').last
|
105
106
|
number = issue.number.to_s
|
106
107
|
puts "Found issue in #{repository}:[##{number}] #{title}"
|
107
|
-
|
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
|
108
113
|
end
|
109
114
|
issues = issues.map(&:to_s).join("\n\n\n")
|
110
115
|
#puts "Found issues:\n #{issues}"
|
@@ -156,9 +161,15 @@ def generate
|
|
156
161
|
puts "Output mode is '#{output_mode}'"
|
157
162
|
full_answer = Report.new(reporter, reporter_position, options[:title]).build(answer, issues_full_answer, Date.today)
|
158
163
|
if output_mode.eql? 'txt'
|
164
|
+
puts "Print result to txy file"
|
159
165
|
output = Txtout.new('.')
|
160
166
|
output.print(full_answer, github_username)
|
167
|
+
elsif output_mode.eql? 'html'
|
168
|
+
puts "Print result to html file"
|
169
|
+
output = Htmlout.new('.')
|
170
|
+
output.print(full_answer, github_username)
|
161
171
|
else
|
172
|
+
puts "Print result to stdout"
|
162
173
|
output = Stdout.new
|
163
174
|
output.print(full_answer)
|
164
175
|
end
|
@@ -0,0 +1,52 @@
|
|
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/html_output'
|
26
|
+
|
27
|
+
class TestHtmlout < Minitest::Test
|
28
|
+
|
29
|
+
EXPECTED = "<!DOCTYPE html>
|
30
|
+
<html lang=\"en\">
|
31
|
+
<head>
|
32
|
+
<meta charset=\"UTF-8\">
|
33
|
+
<title>volodya-lombrozo #{Time.new.strftime('%d.%m.%Y')}</title>
|
34
|
+
</head>
|
35
|
+
<body>
|
36
|
+
<h1>volodya-lombrozo #{Time.new.strftime('%d.%m.%Y')}</h1>
|
37
|
+
<p>Issue description</p>
|
38
|
+
</body>
|
39
|
+
</html>
|
40
|
+
"
|
41
|
+
|
42
|
+
def test_writes_to_a_html_file
|
43
|
+
Dir.mktmpdir do |temp_dir|
|
44
|
+
output = Htmlout.new(temp_dir)
|
45
|
+
today = Date.today.strftime('%d.%m.%Y')
|
46
|
+
expected = "#{today}.volodya-lombrozo.html"
|
47
|
+
output.print("Issue description", 'volodya-lombrozo')
|
48
|
+
assert(File.exist?(File.join(temp_dir, expected)))
|
49
|
+
assert_equal(EXPECTED, File.read(File.join(temp_dir, expected)))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -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
|
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.9
|
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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '6.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: net-http
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.4'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::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,11 +135,14 @@ files:
|
|
121
135
|
- README.md
|
122
136
|
- bin/newsman
|
123
137
|
- lib/newsman.rb
|
138
|
+
- lib/newsman/html_output.rb
|
124
139
|
- lib/newsman/issues.rb
|
125
140
|
- lib/newsman/pull_request.rb
|
126
141
|
- lib/newsman/report.rb
|
127
142
|
- lib/newsman/stdout_output.rb
|
128
143
|
- lib/newsman/txt_output.rb
|
144
|
+
- test/test_htmlout.rb
|
145
|
+
- test/test_pdd_issue.rb
|
129
146
|
- test/test_report.rb
|
130
147
|
- test/test_txtout.rb
|
131
148
|
- test/test_week_before.rb
|
@@ -150,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
167
|
- !ruby/object:Gem::Version
|
151
168
|
version: '0'
|
152
169
|
requirements: []
|
153
|
-
rubygems_version: 3.5.
|
170
|
+
rubygems_version: 3.5.7
|
154
171
|
signing_key:
|
155
172
|
specification_version: 4
|
156
173
|
summary: GitHub user weekly news
|