newsman 0.1.5 → 0.1.6

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: d3fdd4399988de1849e764c948526111dc93b27815fe062db2c95b0ed595d233
4
- data.tar.gz: e3257b4e7152f3425ee3188efa630c6b0aff0a0f5636b226cf636b3b0dbddeb4
3
+ metadata.gz: c90f8d247e0365b348ec9b04d372cba37a9933f8e01209345d92728b70076067
4
+ data.tar.gz: 20e84be86484a2a62a6d8d13ec20b968efe2132055755d9521991bf1079d800c
5
5
  SHA512:
6
- metadata.gz: e7e7e30de47ebae5151fbcacd9e2211467ff5744d13b43dfaec0aa2c8bb83527dd27014deeb0073ac6c765c00cf06b56fff86eeab45441ba090b152087572cd8
7
- data.tar.gz: 9af599981c3938a4ec8c98de0047c3a02af82ff8ab2ae8d8d56c5353707bdf3bcf8dfe1a4faee11efe6951bc721be26065cf9ffa45c13790d3eb162735e6cdc7
6
+ metadata.gz: 24f7a9676367b76beea8e21614325a5e574af1f2d5f85fe73229d7eadd12d78e86a1d536140fe682c3b16b7f70a0f62bcca50c8024d3713d69115466520f1286
7
+ data.tar.gz: eca46b8ff30fb42918769c0c0a8ff4bd89f3ff3f4d724be17ce72dfeb894215dd0470f54ecde5db199c89dfbb735e4b9489f02f837727600f50281b305109f38
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/lib/newsman.rb CHANGED
@@ -29,6 +29,9 @@ def generate
29
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
30
  options[:output] = o
31
31
  end
32
+ opts.on("-t", "--title TITLE", "Project Title. Empty by default") do |t|
33
+ options[:title] = t
34
+ end
32
35
  end.parse!
33
36
  # Custom method to raise exception with a human-readable message
34
37
  def options.require_option(key, message)
@@ -41,6 +44,7 @@ def generate
41
44
  options.require_option(:repositories, "GitHub repository is required. Please specify one or several repositories using -r or --repositories.")
42
45
  options[:position] ||= "Software Developer"
43
46
  options[:output] ||= "stdout"
47
+ options[:title] ||= ""
44
48
  all_params = options.map { |key, value| "#{key}: #{value}" }.join(", ")
45
49
  puts "Parsed parameters: #{all_params}"
46
50
 
@@ -83,7 +87,11 @@ def generate
83
87
  end
84
88
  puts "\nNow lets test some aggregation using OpenAI\n\n"
85
89
  openai_client = OpenAI::Client.new(access_token: openai_token)
86
- example = "Last week achievements.
90
+
91
+ project_week = "#{week_of_a_year(options[:title], Date.today)}"
92
+
93
+ example = "
94
+ Last week achievements.
87
95
  jeo-meven-plugin:
88
96
  - Added 100 new files to the Dataset [#168]
89
97
  - Fixed the deployment of XYZ [#169]
@@ -121,12 +129,15 @@ response = openai_client.chat(
121
129
  })
122
130
  output_mode = options[:output]
123
131
  puts "Output mode is '#{output_mode}'"
132
+ project_week = "#{week_of_a_year(options[:title], Date.today)}"
133
+ answer = response.dig("choices", 0, "message", "content")
134
+ full_answer = "#{project_week}\n\n#{answer}"
124
135
  if output_mode.eql? "txt"
125
136
  output = Txtout.new(".")
126
- output.print(response.dig("choices", 0, "message", "content"), github_username)
137
+ output.print(full_answer, github_username)
127
138
  else
128
139
  output = Stdout.new
129
- output.print(response.dig("choices", 0, "message", "content"))
140
+ output.print(full_answer)
130
141
  end
131
142
  end
132
143
 
@@ -142,6 +153,10 @@ def date_one_week_ago(today)
142
153
  return formatted_date
143
154
  end
144
155
 
156
+ def week_of_a_year(project, today)
157
+ number = today.strftime('%U').to_i + 1
158
+ return "WEEK #{number} #{project}"
159
+ end
145
160
 
146
161
  # Execute the function only if this script is run directly like `./newsman.rb`
147
162
  if __FILE__ == $0
data/test/test_txtout.rb CHANGED
@@ -26,8 +26,10 @@ class TestTxtout < Minitest::Test
26
26
  def test_writes_to_a_file
27
27
  Dir.mktmpdir do |temp_dir|
28
28
  output = Txtout.new(temp_dir)
29
- expected = '17.03.2024.volodya-lombrozo.txt'
29
+ today = Date.today.strftime("%d.%m.%Y");
30
+ expected = "#{today}.volodya-lombrozo.txt"
30
31
  output.print("496", "volodya-lombrozo")
32
+ puts "Expected #{expected}"
31
33
  assert(File.exist?(File.join(temp_dir, expected)))
32
34
  assert_equal("496\n", File.read(File.join(temp_dir, expected)))
33
35
  end
@@ -0,0 +1,31 @@
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.rb'
24
+
25
+ class TestWeekOfYear < Minitest::Test
26
+ def test_week_of_a_year()
27
+ assert_equal "WEEK 11 JEO", week_of_a_year("JEO", Date.new(2024, 3, 14))
28
+ assert_equal "WEEK 9 OPEO", week_of_a_year("OPEO", Date.new(2024, 2, 29))
29
+ end
30
+ end
31
+
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.5
4
+ version: 0.1.6
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-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -126,6 +126,7 @@ files:
126
126
  - lib/newsman/txt_output.rb
127
127
  - test/test_txtout.rb
128
128
  - test/test_week_before.rb
129
+ - test/test_week_of_a_year.rb
129
130
  homepage: https://github.com/volodya-lombrozo/newsman
130
131
  licenses:
131
132
  - MIT