newsman 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbdbadb8ae1727aa56b52deae928ceb16d0068d9b0190ac2672a75a98c669231
4
- data.tar.gz: 5b0487e709dd265cfcfe39ffadab3ac1bff14fd0e94ad547fb49aa56567e317d
3
+ metadata.gz: a4c62dd4456a16613a0e0d56216eddc8ab292ce140ba3392efea52a1e60eb582
4
+ data.tar.gz: 979d40aba31400af7600f11561d2b0b143b2b6948d9c5489b95f6aebb60beeb7
5
5
  SHA512:
6
- metadata.gz: 749af2c2ce1a20006ad4ba4373c2d53f0f52c604c8f9801acb87f6f2cd6bd421d79690e643e46b5c97fad09a80a7ea75e41db8e6e4523da689c07025d0e0b059
7
- data.tar.gz: 68e39b6efe454c926b8164e4c3c7e7fe6682c6086f80b0a579a84cc3116df2f424c2bad1f8572d2466bf07f8fc6c3b703c9325fa295eba028b229935c53535b9
6
+ metadata.gz: 0663b8583dbc3aade358d1fbe4087aab6cb092892b347936ab415fb729dab781fdfdb3164c72ec48b64767b781d4a9f46f58c7e2cb072e4fc0a1d1b80ee0c89e
7
+ data.tar.gz: af4e35da01996ff3495e8e052d9692ac5582b65e981da51b4bd4594158cb255af9bf8cd38a88e85cc508401e7ac8574cb9701c150c7a72328947be109d26b9dc
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
- ./bin/newsman --name "Vladimir Zakharov" --username "volodya-lombrozo" --repository objectionary/jeo-maven-plugin,objectionary/opeo-maven-plugin
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,6 @@
1
+ class Stdout
2
+ def print(report)
3
+ puts "Print a report to stdout"
4
+ puts report
5
+ end
6
+ end
@@ -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
- puts response.dig("choices", 0, "message", "content")
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
 
@@ -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
@@ -20,7 +20,7 @@
20
20
  # SOFTWARE.
21
21
 
22
22
  require 'minitest/autorun'
23
- require_relative '../../lib/newsman/newsman.rb'
23
+ require_relative '../lib/newsman.rb'
24
24
 
25
25
  class TestDateOneWeekAgo < Minitest::Test
26
26
  def test_date_one_week_ago
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.0
4
+ version: 0.1.2
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-12 00:00:00.000000000 Z
11
+ date: 2024-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -24,6 +24,62 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.22'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.22'
41
+ - !ruby/object:Gem::Dependency
42
+ name: octokit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '8.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '8.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: optparse
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday-retry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.2'
27
83
  description: A simple gem that gathers GitHub statistics and creates human-readable
28
84
  report
29
85
  email:
@@ -38,7 +94,10 @@ files:
38
94
  - bin/newsman
39
95
  - lib/newsman.rb
40
96
  - lib/newsman/pull_request.rb
41
- - test/newsman/test_week_before.rb
97
+ - lib/newsman/stdout_output.rb
98
+ - lib/newsman/txt_output.rb
99
+ - test/test_txtout.rb
100
+ - test/test_week_before.rb
42
101
  homepage: https://github.com/volodya-lombrozo/newsman
43
102
  licenses:
44
103
  - MIT