newsman 0.1.5 → 0.1.7

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: d3fdd4399988de1849e764c948526111dc93b27815fe062db2c95b0ed595d233
4
- data.tar.gz: e3257b4e7152f3425ee3188efa630c6b0aff0a0f5636b226cf636b3b0dbddeb4
3
+ metadata.gz: 75f205e7d044fd681d85d0be8985808dfae181b49f4c18dfac392aeadbe34dab
4
+ data.tar.gz: 06f7cc6020990be40c1bbc4e1c28aea4d967e949c5a96ef56a67e278f4db9728
5
5
  SHA512:
6
- metadata.gz: e7e7e30de47ebae5151fbcacd9e2211467ff5744d13b43dfaec0aa2c8bb83527dd27014deeb0073ac6c765c00cf06b56fff86eeab45441ba090b152087572cd8
7
- data.tar.gz: 9af599981c3938a4ec8c98de0047c3a02af82ff8ab2ae8d8d56c5353707bdf3bcf8dfe1a4faee11efe6951bc721be26065cf9ffa45c13790d3eb162735e6cdc7
6
+ metadata.gz: 1e4e5ac7ff8f076e0e1cb0a84101de4b85a1266b265f82a075c6c3cc46891992343a08e46a3f84e1da9a77eaac8ac787bd84d591274accf22fa40b1758484f17
7
+ data.tar.gz: e2f695629a396e1e330df94b8d15c541ba319c196f7f02165d7e7b5c0f07e3ff896f708b5737a2b3549bb66f3899b48d772cb016e9c1bd3389e7c80694892494
data/README.md CHANGED
@@ -61,4 +61,8 @@ To check that everythis is fine, just run the following command:
61
61
  ```
62
62
  newsman --help
63
63
  ```
64
- Annd you should see a welcome message from newsman.
64
+ And you should see a welcome message from newsman.
65
+
66
+ ## Examples
67
+
68
+ You can find examples of generated reports [here](https://github.com/volodya-lombrozo/newsman/tree/gh-pages)
data/bin/newsman CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require_relative "../lib/newsman.rb"
4
+ require_relative '../lib/newsman'
4
5
 
5
6
  generate
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Issue
4
+ attr_accessor :title, :body, :repo, :number
5
+
6
+ def initialize(title, body, repo, number)
7
+ @title = title
8
+ @body = body
9
+ @repo = repo
10
+ @number = number
11
+ end
12
+
13
+ def to_s
14
+ "title: ```#{@title}```,\ndescription: ```#{@body}```,\nrepo: ```#{@repo}```,\nissue number: \##{@number}\n"
15
+ end
16
+ end
17
+
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PullRequest
2
4
  attr_accessor :repository, :title, :description
3
5
 
@@ -8,6 +10,7 @@ class PullRequest
8
10
  end
9
11
 
10
12
  def to_s
11
- "title: ```#{@title}```\n, description: ```#{@description}```\n, repo: ```#{@repository}```\n"
13
+ "title: ```#{@title}```,\ndescription: ```#{@description}```,\nrepo: ```#{@repository}```\n"
12
14
  end
13
15
  end
16
+
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ class Report
4
+ def initialize(user, position, title)
5
+ @user = user
6
+ @position = position
7
+ @title = title
8
+ end
9
+ def build(achievements, plans, date)
10
+ return "From: #{@user}\nSubject: #{week_of_a_year(@title, date)}\n\nHi all,\n\nLast week achievements:\n#{achievements}\n\nNext week plans:\n#{plans}\n\nRisks:\n- <todo>\n\nBest regards,\n#{@user}\n#{@position}\n#{date}"
11
+ end
12
+ end
13
+
14
+ def week_of_a_year(project, today)
15
+ number = today.strftime('%U').to_i + 1
16
+ "WEEK #{number} #{project}"
17
+ end
18
+
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Stdout
2
4
  def print(report)
3
- puts "Print a report to stdout"
5
+ puts 'Print a report to stdout'
4
6
  puts report
5
7
  end
6
8
  end
@@ -1,17 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Txtout
2
- def initialize(root=".")
3
- @root=root
4
+ def initialize(root = '.')
5
+ @root = root
4
6
  end
7
+
5
8
  def print(report, reporter)
6
9
  puts "Create a file in a directory #{@root}"
7
- file = File.new(File.join(@root, filename(reporter)), "w")
10
+ file = File.new(File.join(@root, filename(reporter)), 'w')
8
11
  puts "File #{file.path} was successfully created"
9
12
  file.puts report
10
13
  puts "Report was successfully printed to a #{file.path}"
11
14
  file.close
12
15
  end
16
+
13
17
  def filename(reporter)
14
18
  date = Time.new.strftime('%d.%m.%Y')
15
- "#{date}.#{reporter}.txt"
19
+ "#{date}.#{reporter}.txt"
16
20
  end
17
21
  end
data/lib/newsman.rb CHANGED
@@ -1,34 +1,43 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'octokit'
4
5
  require 'openai'
5
6
  require 'dotenv'
6
7
  require 'optparse'
7
- require_relative 'newsman/pull_request.rb'
8
- require_relative 'newsman/stdout_output.rb'
9
- require_relative 'newsman/txt_output.rb'
8
+ require_relative 'newsman/pull_request'
9
+ require_relative 'newsman/issues'
10
+ require_relative 'newsman/stdout_output'
11
+ require_relative 'newsman/txt_output'
12
+ require_relative 'newsman/report'
10
13
 
11
14
  def generate
12
15
  # Load all options required
13
16
  # Pay attention that some of them have default values.
14
17
  options = {}
15
18
  OptionParser.new do |opts|
16
- opts.banner = "Usage: newsman [options]"
17
- opts.on("-n", "--name NAME", "Reporter name. Human readable name that will be used in a report") do |n|
18
- options[:name] = n
19
+ opts.banner = 'Usage: newsman [options]'
20
+ opts.on('-n', '--name NAME', 'Reporter name. Human readable name that will be used in a report') do |n|
21
+ options[:name] = n
19
22
  end
20
- opts.on("-u", "--username USERNAME", "GitHub username. For example, 'volodya-lombrozo'") do |u|
23
+ opts.on('-u', '--username USERNAME', "GitHub username. For example, 'volodya-lombrozo'") do |u|
21
24
  options[:username] = u
22
25
  end
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|
26
+ opts.on('-r', '--repository REPOSITORIES',
27
+ "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|
24
28
  options[:repositories] = r
25
29
  end
26
- opts.on("-p", "--position POSITION", "Reporter position in a company. Default value is a 'Software Developer'.") do |p|
30
+ opts.on('-p', '--position POSITION',
31
+ "Reporter position in a company. Default value is a 'Software Developer'.") do |p|
27
32
  options[:position] = p
28
33
  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|
34
+ 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 txt'") do |o|
30
36
  options[:output] = o
31
37
  end
38
+ opts.on('-t', '--title TITLE', 'Project Title. Empty by default') do |t|
39
+ options[:title] = t
40
+ end
32
41
  end.parse!
33
42
  # Custom method to raise exception with a human-readable message
34
43
  def options.require_option(key, message)
@@ -36,28 +45,30 @@ def generate
36
45
  end
37
46
 
38
47
  # Check for required options
39
- options.require_option(:name, "Reporter name is required. Please specify using -n or --name.")
40
- options.require_option(:username, "GitHub username is required. Please specify using -u or --username.")
41
- options.require_option(:repositories, "GitHub repository is required. Please specify one or several repositories using -r or --repositories.")
42
- options[:position] ||= "Software Developer"
43
- options[:output] ||= "stdout"
44
- all_params = options.map { |key, value| "#{key}: #{value}" }.join(", ")
48
+ options.require_option(:name, 'Reporter name is required. Please specify using -n or --name.')
49
+ options.require_option(:username, 'GitHub username is required. Please specify using -u or --username.')
50
+ options.require_option(:repositories,
51
+ 'GitHub repository is required. Please specify one or several repositories using -r or --repositories.')
52
+ options[:position] ||= 'Software Developer'
53
+ options[:output] ||= 'stdout'
54
+ options[:title] ||= ''
55
+ all_params = options.map { |key, value| "#{key}: #{value}" }.join(', ')
45
56
  puts "Parsed parameters: #{all_params}"
46
57
 
47
58
  # Load all required environment variables
48
59
  Dotenv.load
49
- Dotenv.require_keys("GITHUB_TOKEN", "OPENAI_TOKEN")
60
+ Dotenv.require_keys('GITHUB_TOKEN', 'OPENAI_TOKEN')
50
61
 
51
62
  # Init all required parameters
52
63
  # Reporter Info
53
64
  reporter = options[:name]
54
65
  reporter_position = options[:position]
55
- # GitHub
66
+ # GitHub
56
67
  github_username = options[:username]
57
- github_repositories = options[:repositories].split(",").map { |repo| "repo:" + repo }.join(" ")
58
-
68
+ github_repositories = options[:repositories].split(',').map { |repo| "repo:#{repo}" }.join(' ')
69
+
59
70
  # Your GitHub personal access token
60
- # Make sure it has the 'repo'
71
+ # Make sure it has the 'repo'
61
72
  github_token = ENV['GITHUB_TOKEN']
62
73
  # Your OpenAI personal access token
63
74
  openai_token = ENV['OPENAI_TOKEN']
@@ -66,85 +77,107 @@ def generate
66
77
  # Calculate the date one week ago
67
78
  report_date = Date.today
68
79
  one_week_ago = date_one_week_ago(Date.today)
80
+ one_month_ago = Date.today.prev_month.strftime('%Y-%m-%d')
69
81
  # Display pull request
70
82
  query = "is:pr author:#{github_username} created:>=#{one_week_ago} #{github_repositories}"
83
+ issues_query = "is:issue is:open author:#{github_username} author:0pdd created:>=#{one_month_ago} #{github_repositories}"
71
84
  puts "Searching pull requests for #{github_username}."
72
85
  puts "Newsman uses the following request to GitHub to gather the required information about user activity: '#{query}'"
73
86
  prs = []
74
87
  pull_requests = client.search_issues(query)
75
88
  pull_requests.items.each do |pr|
76
- title = "#{pr.title}"
77
- description = "#{pr.body}"
89
+ title = pr.title.to_s
90
+ description = pr.body.to_s
78
91
  repository = pr.repository_url.split('/').last
79
92
  puts "Found PR in #{repository}: #{title}"
80
93
  # Create a new PullRequest object and add it to the list
81
94
  pr = PullRequest.new(repository, title, description)
82
95
  prs << pr
83
96
  end
97
+ prs = prs.map(&:to_s).join("\n\n\n")
98
+
99
+ puts "Searching issues using the following query: '#{issues_query}'"
100
+ issues = []
101
+ client.search_issues(issues_query).items.each do |issue|
102
+ title = issue.title.to_s
103
+ body = issue.body.to_s
104
+ repository = issue.repository_url.split('/').last
105
+ number = issue.number.to_s
106
+ puts "Found issue in #{repository}:[##{number}] #{title}"
107
+ issues << Issue.new(title, body, repository, number)
108
+ end
109
+ issues = issues.map(&:to_s).join("\n\n\n")
110
+ #puts "Found issues:\n #{issues}"
111
+
84
112
  puts "\nNow lets test some aggregation using OpenAI\n\n"
85
113
  openai_client = OpenAI::Client.new(access_token: openai_token)
86
- example = "Last week achievements.
87
- jeo-meven-plugin:
114
+
115
+ example = "jeo-meven-plugin:
88
116
  - Added 100 new files to the Dataset [#168]
89
117
  - Fixed the deployment of XYZ [#169]
90
118
  - Refined the requirements [#177]
91
- opeo-maven-plugin
119
+ opeo-maven-plugin:
92
120
  - Removed XYZ class [#57]
93
- - Refactored http module [#69]
121
+ - Refactored http module [#69]"
94
122
 
95
- Next week plans:
96
- jeo-maven-plugin:
97
- - <leave empty>
123
+ example_plans = "jeo-maven-plugin:
124
+ - To publish ABC package draft [#27]
125
+ - To review first draft of the report [#56]
98
126
  opeo-maven-plugin:
99
- - <leave empty>
127
+ - To implement optimization for the class X [#125]"
100
128
 
101
- Risks:
102
- jeo-maven-plugin:
103
- - <leave-empty>
104
- opeo-maven-plugin:
105
- - <leave-empty>
106
-
107
- Best regards,
108
- #{reporter}
109
- #{reporter_position}
110
- #{report_date}
111
- "
112
-
113
- response = openai_client.chat(
129
+ response = openai_client.chat(
114
130
  parameters: {
115
- model: "gpt-3.5-turbo",
116
- messages: [
117
- { role: "system", content: "You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor."},
118
- { role: "user", content: "Please compile a summary of the work completed in the following Pull Requests (PRs). Each PR should be summarized in a single sentence, focusing more on the PR title and less on implementation details. Group the sentences by repositories, each identified by its name mentioned in the 'repository:[name]' attribute of the PR. The grouping is important an should be precise. Ensure that each sentence includes the corresponding issue number as an integer value. If a PR doesn't mention an issue number, just print [#chore]. Combine all the information from each PR into a concise and fluent sentence, as if you were a developer reporting on your work. Please strictly adhere to the example template provided. Example of a report: #{example}. List of Pull Requests: [#{prs}]"}
119
- ],
120
- temperature: 0.3,
121
- })
131
+ model: 'gpt-3.5-turbo',
132
+ messages: [
133
+ { role: 'system',
134
+ content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
135
+ { role: 'user',
136
+ content: "Please compile a summary of the work completed in the following Pull Requests (PRs). Each PR should be summarized in a single sentence, focusing more on the PR title and less on implementation details. Group the sentences by repositories, each identified by its name mentioned in the 'repository:[name]' attribute of the PR. The grouping is important an should be precise. Ensure that each sentence includes the corresponding issue number as an integer value. If a PR doesn't mention an issue number, just print [#chore]. Combine all the information from each PR into a concise and fluent sentence, as if you were a developer reporting on your work. Please strictly adhere to the example template provided. Example of a report: #{example}. List of Pull Requests: [#{prs}]" }
137
+ ],
138
+ temperature: 0.3
139
+ }
140
+ )
141
+ answer = response.dig('choices', 0, 'message', 'content')
142
+ issues_response = openai_client.chat(
143
+ parameters: {
144
+ model: 'gpt-3.5-turbo',
145
+ messages: [
146
+ { role: 'system',
147
+ content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
148
+ { role: 'user',
149
+ content: "Please compile a summary of the plans for the next week using the following GitHub Issues descriptions. Each issue should be summarized in a single sentence, focusing more on the issue title and less on implementation details. Group the sentences by repositories, each identified by its name mentioned in the 'repository:[name]' attribute of the issue. The grouping is important an should be precise. Ensure that each sentence includes the corresponding issue number as an integer value. If an issue doesn't mention an issue number, just print [#chore]. Combine all the information from each Issue into a concise and fluent sentences, as if you were a developer reporting on your work. Please strictly adhere to the example template provided: #{example_plans}. List of GitHub issues to aggregate: [#{issues}]. Use the same formatting as here \n```#{answer}```\n" }
150
+ ],
151
+ temperature: 0.3
152
+ }
153
+ )
154
+ issues_full_answer = issues_response.dig('choices', 0, 'message', 'content')
122
155
  output_mode = options[:output]
123
156
  puts "Output mode is '#{output_mode}'"
124
- if output_mode.eql? "txt"
125
- output = Txtout.new(".")
126
- output.print(response.dig("choices", 0, "message", "content"), github_username)
157
+ full_answer = Report.new(reporter, reporter_position, options[:title]).build(answer, issues_full_answer, Date.today)
158
+ if output_mode.eql? 'txt'
159
+ output = Txtout.new('.')
160
+ output.print(full_answer, github_username)
127
161
  else
128
162
  output = Stdout.new
129
- output.print(response.dig("choices", 0, "message", "content"))
163
+ output.print(full_answer)
130
164
  end
131
165
  end
132
166
 
133
-
134
167
  def date_one_week_ago(today)
135
168
  # Convert today to a Date object if it's not already
136
169
  today = Date.parse(today) unless today.is_a?(Date)
137
170
  # Subtract 7 days to get the date one week ago
138
171
  one_week_ago = today - 7
139
172
  # Format the date as "YYYY-MM-DD"
140
- formatted_date = one_week_ago.strftime("%Y-%m-%d")
173
+ one_week_ago.strftime('%Y-%m-%d')
141
174
  # Return the formatted date
142
- return formatted_date
143
175
  end
144
176
 
145
-
146
- # Execute the function only if this script is run directly like `./newsman.rb`
147
- if __FILE__ == $0
148
- generate()
177
+ def week_of_a_year(project, today)
178
+ number = today.strftime('%U').to_i + 1
179
+ "WEEK #{number} #{project}"
149
180
  end
150
181
 
182
+ # Execute the function only if this script is run directly like `./newsman.rb`
183
+ generate if __FILE__ == $PROGRAM_NAME
@@ -0,0 +1,54 @@
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/report.rb'
26
+
27
+ class TestReport < Minitest::Test
28
+ def test_report
29
+ expected = "From: User
30
+ Subject: WEEK 11 Project
31
+
32
+ Hi all,
33
+
34
+ Last week achievements:
35
+ repository-a:
36
+ - Did a lot of for (a) repository
37
+
38
+ Next week plans:
39
+ repository-b:
40
+ - I will do a lot for repository (b)
41
+
42
+ Risks:
43
+ - <todo>
44
+
45
+ Best regards,
46
+ User
47
+ Developer
48
+ 2024-03-14"
49
+ report = Report.new('User', 'Developer', 'Project')
50
+ out = report.build("repository-a:\n - Did a lot of for (a) repository", "repository-b:\n - I will do a lot for repository (b)", Date.new(2024, 3, 14))
51
+ assert_equal expected, out
52
+ end
53
+ end
54
+
data/test/test_txtout.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (c) 2024 Volodya Lombrozo
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright (c) 2024 Volodya Lombrozo
3
5
  #
4
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
7
  # of this software and associated documentation files (the 'Software'), to deal
@@ -20,14 +22,16 @@
20
22
  # SOFTWARE.
21
23
 
22
24
  require 'minitest/autorun'
23
- require_relative '../lib/newsman/txt_output.rb'
25
+ require_relative '../lib/newsman/txt_output'
24
26
 
25
27
  class TestTxtout < Minitest::Test
26
28
  def test_writes_to_a_file
27
- Dir.mktmpdir do |temp_dir|
29
+ Dir.mktmpdir do |temp_dir|
28
30
  output = Txtout.new(temp_dir)
29
- expected = '17.03.2024.volodya-lombrozo.txt'
30
- output.print("496", "volodya-lombrozo")
31
+ today = Date.today.strftime('%d.%m.%Y')
32
+ expected = "#{today}.volodya-lombrozo.txt"
33
+ output.print('496', 'volodya-lombrozo')
34
+ puts "Expected #{expected}"
31
35
  assert(File.exist?(File.join(temp_dir, expected)))
32
36
  assert_equal("496\n", File.read(File.join(temp_dir, expected)))
33
37
  end
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (c) 2024 Volodya Lombrozo
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright (c) 2024 Volodya Lombrozo
3
5
  #
4
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
5
7
  # of this software and associated documentation files (the 'Software'), to deal
@@ -20,12 +22,11 @@
20
22
  # SOFTWARE.
21
23
 
22
24
  require 'minitest/autorun'
23
- require_relative '../lib/newsman.rb'
25
+ require_relative '../lib/newsman'
24
26
 
25
27
  class TestDateOneWeekAgo < Minitest::Test
26
28
  def test_date_one_week_ago
27
- assert_equal "2024-03-07", date_one_week_ago(Date.new(2024, 3, 14))
28
- assert_equal "2024-02-29", date_one_week_ago(Date.new(2024, 3, 7))
29
+ assert_equal '2024-03-07', date_one_week_ago(Date.new(2024, 3, 14))
30
+ assert_equal '2024-02-29', date_one_week_ago(Date.new(2024, 3, 7))
29
31
  end
30
32
  end
31
-
@@ -0,0 +1,33 @@
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'
26
+
27
+ class TestWeekOfYear < Minitest::Test
28
+ def test_week_of_a_year
29
+ assert_equal 'WEEK 11 JEO', week_of_a_year('JEO', Date.new(2024, 3, 14))
30
+ assert_equal 'WEEK 9 OPEO', week_of_a_year('OPEO', Date.new(2024, 2, 29))
31
+ end
32
+ end
33
+
metadata CHANGED
@@ -1,113 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newsman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
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-18 00:00:00.000000000 Z
11
+ date: 2024-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '5.22'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '5.22'
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.22'
33
+ version: '3.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '5.22'
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: octokit
42
+ name: dotenv
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '8.0'
47
+ version: '3.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '8.0'
54
+ version: '3.1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: optparse
56
+ name: faraday-retry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.4.0
61
+ version: '2.2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.4.0
68
+ version: '2.2'
69
69
  - !ruby/object:Gem::Dependency
70
- name: faraday-retry
70
+ name: octokit
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.2'
75
+ version: '8.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.2'
82
+ version: '8.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: ruby-openai
84
+ name: optparse
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '6.3'
89
+ version: 0.4.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '6.3'
96
+ version: 0.4.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: dotenv
98
+ name: ruby-openai
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.1'
103
+ version: '6.3'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.1'
110
+ version: '6.3'
111
111
  description: A simple gem that gathers GitHub statistics and creates human-readable
112
112
  report
113
113
  email:
@@ -121,11 +121,15 @@ files:
121
121
  - README.md
122
122
  - bin/newsman
123
123
  - lib/newsman.rb
124
+ - lib/newsman/issues.rb
124
125
  - lib/newsman/pull_request.rb
126
+ - lib/newsman/report.rb
125
127
  - lib/newsman/stdout_output.rb
126
128
  - lib/newsman/txt_output.rb
129
+ - test/test_report.rb
127
130
  - test/test_txtout.rb
128
131
  - test/test_week_before.rb
132
+ - test/test_week_of_a_year.rb
129
133
  homepage: https://github.com/volodya-lombrozo/newsman
130
134
  licenses:
131
135
  - MIT