newsman 0.1.0 → 0.1.1
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 +14 -3
- data/lib/newsman/stdout_output.rb +6 -0
- data/lib/newsman/txt_output.rb +17 -0
- data/lib/newsman.rb +15 -2
- data/test/test_txtout.rb +35 -0
- data/test/{newsman/test_week_before.rb → test_week_before.rb} +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 311041b0ed2a7e127d74ce647fcb0070a285019c712913599ae77d8dd31176b0
|
4
|
+
data.tar.gz: c5178be43a077cd492df1d5b111e582f90546156cc9d11a3962d9889a214d6b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14c4afb4befdcd83ca8241605a6e9d5bc1d640415a9f1eef9b4dbfb96557fb55ca9b5ef0f7138a8a00375a5679a581a65b96e5bb7831ce6a60e0bc1e00d3fa52
|
7
|
+
data.tar.gz: c06c06f6e45905a4cb6f17483ce8891fc9100f0f1917c2af8536b4262cfa42fb792123c85c03feb84d08705cffc01f3469cfb678ef9f5f9a177909bdec35ec06
|
data/README.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
Newsman is a simple script that collects information about a developer's weekly activity on GitHub and creates a human-readable summary of the work done. To create the summary, Newsman asks ChatGPT to handle all the information about a developer's activity, including their pull requests and created issues.
|
4
4
|
|
5
|
+
## Install
|
6
|
+
|
7
|
+
To install [newsman](https://rubygems.org/gems/newsman) from RubyGems.org use the following command:
|
8
|
+
```shell
|
9
|
+
gem install newsman
|
10
|
+
```
|
11
|
+
The newest version of newsman will be installed on your system.
|
12
|
+
|
5
13
|
## How to Use
|
6
14
|
|
7
15
|
To use newsman, you need to perfom several actions.
|
@@ -27,13 +35,16 @@ Usage: newsman [options]
|
|
27
35
|
```
|
28
36
|
|
29
37
|
### Example
|
30
|
-
|
31
|
-
You can download this repository and run the newsman script directly using the following command:
|
38
|
+
To run `newsman` use the following command:
|
32
39
|
```shell
|
33
|
-
|
40
|
+
newsman --name "Vladimir Zakharov" --username "volodya-lombrozo" --repository objectionary/jeo-maven-plugin,objectionary/opeo-maven-plugin
|
34
41
|
```
|
35
42
|
|
36
43
|
Don't forget to set your own values for `name`, `username` and `repository` parameters.
|
44
|
+
Also you can download this repository and run the newsman script directly using the following command:
|
45
|
+
```shell
|
46
|
+
./bin/newsman --name "Vladimir Zakharov" --username "volodya-lombrozo" --repository objectionary/jeo-maven-plugin,objectionary/opeo-maven-plugin
|
47
|
+
```
|
37
48
|
|
38
49
|
## How to build a gem from sources
|
39
50
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Txtout
|
2
|
+
def initialize(root=".")
|
3
|
+
@root=root
|
4
|
+
end
|
5
|
+
def print(report, reporter)
|
6
|
+
puts "Create a file in a directory #{@root}"
|
7
|
+
file = File.new(File.join(@root, filename(reporter)), "w")
|
8
|
+
puts "File #{file.path} was successfully created"
|
9
|
+
file.puts report
|
10
|
+
puts "Report was successfully printed to a #{file.path}"
|
11
|
+
file.close
|
12
|
+
end
|
13
|
+
def filename(reporter)
|
14
|
+
date = Time.new.strftime('%d.%m.%Y')
|
15
|
+
"#{date}.#{reporter}.txt"
|
16
|
+
end
|
17
|
+
end
|
data/lib/newsman.rb
CHANGED
@@ -5,6 +5,8 @@ require 'openai'
|
|
5
5
|
require 'dotenv'
|
6
6
|
require 'optparse'
|
7
7
|
require_relative 'newsman/pull_request.rb'
|
8
|
+
require_relative 'newsman/stdout_output.rb'
|
9
|
+
require_relative 'newsman/txt_output.rb'
|
8
10
|
|
9
11
|
def generate
|
10
12
|
# Load all options required
|
@@ -21,9 +23,12 @@ def generate
|
|
21
23
|
opts.on("-r", "--repository REPOSITORIES", "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|
|
22
24
|
options[:repositories] = r
|
23
25
|
end
|
24
|
-
opts.on("-p", "--position", "Reporter position in a company. Default value is a 'Software Developer'.") do |p|
|
26
|
+
opts.on("-p", "--position POSITION", "Reporter position in a company. Default value is a 'Software Developer'.") do |p|
|
25
27
|
options[:position] = p
|
26
28
|
end
|
29
|
+
opts.on("-o", "--output OUTPUT", "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
|
+
options[:output] = o
|
31
|
+
end
|
27
32
|
end.parse!
|
28
33
|
# Custom method to raise exception with a human-readable message
|
29
34
|
def options.require_option(key, message)
|
@@ -35,6 +40,7 @@ def generate
|
|
35
40
|
options.require_option(:username, "GitHub username is required. Please specify using -u or --username.")
|
36
41
|
options.require_option(:repositories, "GitHub repository is required. Please specify one or several repositories using -r or --repositories.")
|
37
42
|
options[:position] ||= "Software Developer"
|
43
|
+
options[:output] ||= "stdout"
|
38
44
|
all_params = options.map { |key, value| "#{key}: #{value}" }.join(", ")
|
39
45
|
puts "Parsed parameters: #{all_params}"
|
40
46
|
|
@@ -113,7 +119,14 @@ response = openai_client.chat(
|
|
113
119
|
],
|
114
120
|
temperature: 0.3,
|
115
121
|
})
|
116
|
-
|
122
|
+
output_mode = options[:output]
|
123
|
+
puts "Output mode is '#{output_mode}'"
|
124
|
+
if output_mode.eql? "txt"
|
125
|
+
output = Txtout.new(".", github_username)
|
126
|
+
else
|
127
|
+
output = Stdout.new
|
128
|
+
end
|
129
|
+
output.print(response.dig("choices", 0, "message", "content"))
|
117
130
|
end
|
118
131
|
|
119
132
|
|
data/test/test_txtout.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright (c) 2024 Volodya Lombrozo
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'minitest/autorun'
|
23
|
+
require_relative '../lib/newsman/txt_output.rb'
|
24
|
+
|
25
|
+
class TestTxtout < Minitest::Test
|
26
|
+
def test_writes_to_a_file
|
27
|
+
Dir.mktmpdir do |temp_dir|
|
28
|
+
output = Txtout.new(temp_dir)
|
29
|
+
expected = '17.03.2024.volodya-lombrozo.txt'
|
30
|
+
output.print("496", "volodya-lombrozo")
|
31
|
+
assert(File.exist?(File.join(temp_dir, expected)))
|
32
|
+
assert_equal("496\n", File.read(File.join(temp_dir, expected)))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
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.1
|
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-03-
|
11
|
+
date: 2024-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,7 +38,10 @@ files:
|
|
38
38
|
- bin/newsman
|
39
39
|
- lib/newsman.rb
|
40
40
|
- lib/newsman/pull_request.rb
|
41
|
-
-
|
41
|
+
- lib/newsman/stdout_output.rb
|
42
|
+
- lib/newsman/txt_output.rb
|
43
|
+
- test/test_txtout.rb
|
44
|
+
- test/test_week_before.rb
|
42
45
|
homepage: https://github.com/volodya-lombrozo/newsman
|
43
46
|
licenses:
|
44
47
|
- MIT
|