newsman 0.1.8 → 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.rb +8 -1
- data/test/test_htmlout.rb +52 -0
- metadata +5 -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.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|
|
@@ -160,9 +161,15 @@ def generate
|
|
160
161
|
puts "Output mode is '#{output_mode}'"
|
161
162
|
full_answer = Report.new(reporter, reporter_position, options[:title]).build(answer, issues_full_answer, Date.today)
|
162
163
|
if output_mode.eql? 'txt'
|
164
|
+
puts "Print result to txy file"
|
163
165
|
output = Txtout.new('.')
|
164
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)
|
165
171
|
else
|
172
|
+
puts "Print result to stdout"
|
166
173
|
output = Stdout.new
|
167
174
|
output.print(full_answer)
|
168
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
|
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-04-
|
11
|
+
date: 2024-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -135,11 +135,13 @@ files:
|
|
135
135
|
- README.md
|
136
136
|
- bin/newsman
|
137
137
|
- lib/newsman.rb
|
138
|
+
- lib/newsman/html_output.rb
|
138
139
|
- lib/newsman/issues.rb
|
139
140
|
- lib/newsman/pull_request.rb
|
140
141
|
- lib/newsman/report.rb
|
141
142
|
- lib/newsman/stdout_output.rb
|
142
143
|
- lib/newsman/txt_output.rb
|
144
|
+
- test/test_htmlout.rb
|
143
145
|
- test/test_pdd_issue.rb
|
144
146
|
- test/test_report.rb
|
145
147
|
- test/test_txtout.rb
|
@@ -165,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
167
|
- !ruby/object:Gem::Version
|
166
168
|
version: '0'
|
167
169
|
requirements: []
|
168
|
-
rubygems_version: 3.5.
|
170
|
+
rubygems_version: 3.5.7
|
169
171
|
signing_key:
|
170
172
|
specification_version: 4
|
171
173
|
summary: GitHub user weekly news
|