newsman 0.2.2 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b217b1d0fee448151ff8a04b2099a6e311275e781112144a87f62a4e2a49e03
4
- data.tar.gz: 78de209a3631b3e1589caab3b1bb336925009bcd52861e570e53b589d3ed8a65
3
+ metadata.gz: 3c6eaa01ebc8b603b13a1bb158e8a491ed2c51df32d973d56e9e99d959db7d4a
4
+ data.tar.gz: be86c2c47cc64f2da87a04127cf879a8ccabfff8fa9557730e6f3031a225efdb
5
5
  SHA512:
6
- metadata.gz: 317b520b605b309c9ce5aeed0ac3ba385afb6865a8469a3547189232f248011920a67c3a3cc9bb40470e1f0f0ec0b7014f667f106275e56e9df48469d810f757
7
- data.tar.gz: 65eacb6e1debdcb1581af1d40c0b043d641825fc70780b01471f496c0bf5a336fbc8d13a43eab89ea0dacd39890b7ec38f684c842472d9be970508de20a46f70
6
+ metadata.gz: b2b8972c04260e5c588015270b0e192c47bc39cc72c52124b200b5150b16be0e0d149ebb85d890ebcf2e21d98168b220c49953e769b852a62f6d9e18af627a5c
7
+ data.tar.gz: 12b435a44fb9687e9904f436f8b7203927856be57d1933045ca5fefbbe9d076346869962abd884c71e9bd6c2674daa1f9334186a90a84a79d2baa9b0c47d02a8
data/README.md CHANGED
@@ -6,6 +6,32 @@
6
6
 
7
7
  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.
8
8
 
9
+ ## How it Works
10
+
11
+ `newsman` sends multiple requests to GitHub to retrieve the following data:
12
+
13
+ 1. **Recently Closed Pull Requests by the Author**
14
+ The tool fetches pull requests that were closed recently and were created by the specified author.
15
+ Example query:
16
+
17
+ ```
18
+ is:pr author:volodya-lombrozo created:>=2024-11-29 repo:objectionary/jeo-maven-plugin repo:objectionary/opeo-maven-plugin
19
+ ```
20
+
21
+ 2. **Open Issues Assigned to the Author with the `soon` Label**
22
+ The tool retrieves issues that:
23
+ - Were opened in the last year
24
+ - Are currently open
25
+ - Are assigned to the specified author
26
+ - Have the label `soon`
27
+
28
+ Example query:
29
+ ```
30
+ is:issue is:open assignee:volodya-lombrozo created:>=2023-12-06 repo:objectionary/jeo-maven-plugin repo:objectionary/opeo-maven-plugin label:soon
31
+ ```
32
+
33
+ Once the data is retrieved, the script analyzes it using the model specified with the `--model` option.
34
+
9
35
  ## Install
10
36
 
11
37
  To install [newsman](https://rubygems.org/gems/newsman) from RubyGems.org use the following command:
@@ -53,6 +79,8 @@ Also you can download this repository and run the newsman script directly using
53
79
  ./bin/newsman --name "Vladimir Lombrozo" --username "volodya-lombrozo" --repository objectionary/jeo-maven-plugin,objectionary/opeo-maven-plugin
54
80
  ```
55
81
 
82
+ Actually, this command is also useful during development process.
83
+
56
84
  ## How to build a gem from sources
57
85
 
58
86
  To create a newsman gem from sources first of all you need to build it:
@@ -25,11 +25,6 @@ require 'openai'
25
25
  # This class mimics a robot that can analyse a developer activity.
26
26
  # The assistant uses OpenAI API to analyze.
27
27
  class Assistant
28
- CONTEXT = 'You are a developer tasked'\
29
- ' with composing a concise report detailing your activities'\
30
- ' and progress for the previous week,'\
31
- ' intended for submission to your supervisor.'
32
-
33
28
  def initialize(token, model: 'gpt-3.5-turbo', temperature: 0.3)
34
29
  @token = token
35
30
  @model = model
@@ -117,18 +112,32 @@ class Assistant
117
112
  send(prompt)
118
113
  end
119
114
 
115
+ # rubocop:disable Metrics/MethodLength
120
116
  def send(request)
121
- @client.chat(
122
- parameters: {
123
- model: @model,
124
- messages: [
125
- { role: 'system', content: CONTEXT },
126
- { role: 'user', content: request.to_s }
127
- ],
128
- temperature: @temperature
129
- }
130
- ).dig('choices', 0, 'message', 'content')
117
+ if @model == 'o1-preview'
118
+ @client.chat(
119
+ parameters: {
120
+ model: @model,
121
+ messages: [{ role: 'user', content: request.to_s }]
122
+ }
123
+ ).dig('choices', 0, 'message', 'content')
124
+ else
125
+ @client.chat(
126
+ parameters: {
127
+ model: @model,
128
+ messages: [
129
+ { role: 'system', content: 'You are a developer tasked'\
130
+ ' with composing a concise report detailing your activities'\
131
+ ' and progress for the previous week,'\
132
+ ' intended for submission to your supervisor.' },
133
+ { role: 'user', content: request.to_s }
134
+ ],
135
+ temperature: @temperature
136
+ }
137
+ ).dig('choices', 0, 'message', 'content')
138
+ end
131
139
  end
140
+ # rubocop:enable Metrics/MethodLength
132
141
 
133
142
  def deprecated(method)
134
143
  warn "Warning! '#{method}' is deprecated and will be removed in future versions."
@@ -40,8 +40,8 @@ class Github
40
40
 
41
41
  def issues(username, repositories)
42
42
  one_year_ago = Date.today.prev_year.strftime('%Y-%m-%d')
43
- query = "is:issue is:open author:#{username}"\
44
- " author:0pdd created:>=#{one_year_ago} #{repositories}"
43
+ query = "is:issue is:open assignee:#{username}"\
44
+ " created:>=#{one_year_ago} #{repositories} label:#{IMPORTANT_ISSUE}"
45
45
  puts "Searching issues using the following query: '#{query}'"
46
46
  @client.search_issues(query).items.map do |issue|
47
47
  parse_issue(issue)
@@ -23,6 +23,8 @@
23
23
  require 'net/http'
24
24
  require 'json'
25
25
 
26
+ IMPORTANT_ISSUE = 'soon'
27
+
26
28
  # This class represents a GitHub Issue abstraction created by a user.
27
29
  class Issue
28
30
  attr_accessor :title, :body, :repo, :number
@@ -69,7 +71,7 @@ class Issue
69
71
  end
70
72
 
71
73
  def important?
72
- labels.include? 'soon'
74
+ labels.include? IMPORTANT_ISSUE
73
75
  end
74
76
  end
75
77
 
@@ -124,7 +126,7 @@ class PddIssue
124
126
  end
125
127
 
126
128
  def important?
127
- labels.include? 'soon'
129
+ labels.include? IMPORTANT_ISSUE
128
130
  end
129
131
 
130
132
  def url
data/lib/newsman.rb CHANGED
@@ -129,15 +129,15 @@ def generate
129
129
  output_mode = options[:output]
130
130
  puts "Output mode is '#{output_mode}'"
131
131
  if output_mode.eql? 'txt'
132
- puts 'Print result to txy file'
132
+ puts 'Print result to a txt file'
133
133
  output = Txtout.new('.')
134
134
  output.print(full_answer, github_username)
135
135
  elsif output_mode.eql? 'html'
136
- puts 'Print result to html file'
136
+ puts 'Print result to a html file'
137
137
  output = Htmlout.new('.')
138
138
  output.print(full_answer, github_username, options[:model])
139
139
  else
140
- puts 'Print result to stdout'
140
+ puts 'Print result to a stdout'
141
141
  output = Stdout.new
142
142
  output.print(full_answer)
143
143
  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.2.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Lombrozo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-02 00:00:00.000000000 Z
11
+ date: 2024-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -198,7 +198,7 @@ homepage: https://github.com/volodya-lombrozo/newsman
198
198
  licenses:
199
199
  - MIT
200
200
  metadata: {}
201
- post_install_message:
201
+ post_install_message:
202
202
  rdoc_options: []
203
203
  require_paths:
204
204
  - lib
@@ -214,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  requirements: []
217
- rubygems_version: 3.5.18
218
- signing_key:
217
+ rubygems_version: 3.5.22
218
+ signing_key:
219
219
  specification_version: 4
220
220
  summary: GitHub user weekly news
221
221
  test_files: []