resquirrel 0.1.2 → 0.1.3

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: 775bf06ddae912a198a90c60ea25c438fc61b248b6382093900b6726989eeffd
4
- data.tar.gz: 22f7afd5dc14f52384491a928a3e2f1114d10bc3281270ec541882fd9db2647d
3
+ metadata.gz: c7e1ffeaf1f7ec104553dabc0f016a0ae3d67a6b34638a81d26d0cca0072c1a7
4
+ data.tar.gz: fd3b10b5c35ddaf4399541f99d828b321a68ca396b46128436cd8965a853bca5
5
5
  SHA512:
6
- metadata.gz: bd4b35c5687545c94523f61806bd07f39753fce02fd1bf1b8614cc1643cc01b8be9152b79b3d9f50f867db86c25494088225b07991114a4d3a5891dbb7d2f3f7
7
- data.tar.gz: 65292664a4fdde9fe000967dbb61817319cdc15e554deb4899a3265d73e6ee104ddd16ef60d771b07f478c500bf21bf30dba8126efbc9426753182d22fb90335
6
+ metadata.gz: 20b0e5df45f8dad12622dc5b2ff09a6485ca502ff09867ac7930981b17ef51c1f25cfbf412b56a0129196ff116a844b0ef63181f14bda9252bb28f42bdfc63c2
7
+ data.tar.gz: 0b7c49d458c503666b44da267497ab279fd078e77d8d779a1060008b2c4aaa175654dc9980e4292195204bc5bdb7fb6b10e0ff228ae8668308c8bb36b4eb8a68
data/.rubocop.yml CHANGED
@@ -18,6 +18,11 @@ Metrics/MethodLength:
18
18
  Metrics/AbcSize:
19
19
  Max: 30
20
20
 
21
+ Metrics/BlockLength:
22
+ Max: 50
23
+ Exclude:
24
+ - 'spec/**/*'
25
+
21
26
  Style/Documentation:
22
27
  Enabled: false
23
28
 
data/README.md CHANGED
@@ -10,7 +10,7 @@ RubyGems that automatically create release notes for Notion DB using Open AI API
10
10
  Add this line to your application's Gemfile:
11
11
 
12
12
  ```Gemfile
13
- gem 'fabrique'
13
+ gem 'resquirrel'
14
14
  ```
15
15
 
16
16
  And then execute:
@@ -85,8 +85,9 @@ jobs:
85
85
  ```
86
86
 
87
87
  ```rb
88
- resquirrel = Resquirrel.new
89
- resquirrel.generate_release_note
88
+ require 'resquirrel'
89
+
90
+ Resquirrel.generate_release_note
90
91
  ```
91
92
  それぞれのenvは必須です。
92
93
 
@@ -151,8 +152,9 @@ jobs:
151
152
  ```
152
153
 
153
154
  ```rb
154
- resquirrel = Resquirrel.new
155
- resquirrel.generate_release_note
155
+ require 'resquirrel'
156
+
157
+ Resquirrel.generate_release_note
156
158
  ```
157
159
  Each env is required.
158
160
 
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resquirrel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - yuki-snow1823
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-27 00:00:00.000000000 Z
11
+ date: 2024-05-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: ''
13
+ description: RubyGems that automatically create release notes for Notion DB using
14
+ Open AI API when PR merge.
14
15
  email:
15
16
  - y.horikoshi.pg@gmail.com
16
17
  executables: []
@@ -24,11 +25,6 @@ files:
24
25
  - LICENSE.txt
25
26
  - README.md
26
27
  - Rakefile
27
- - lib/client/notion.rb
28
- - lib/client/openai.rb
29
- - lib/main.rb
30
- - lib/resquirrel.rb
31
- - lib/resquirrel/version.rb
32
28
  homepage: https://github.com/yuki-snow1823/resquirrel
33
29
  licenses:
34
30
  - MIT
@@ -54,6 +50,5 @@ requirements: []
54
50
  rubygems_version: 3.5.3
55
51
  signing_key:
56
52
  specification_version: 4
57
- summary: RubyGems that automatically create release notes for Notion DB using Open
58
- AI API.
53
+ summary: The library to support the creation of release notes
59
54
  test_files: []
data/lib/client/notion.rb DELETED
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "net/http"
4
- require "json"
5
-
6
- class NotionClient
7
- def initialize(api_key, database_id)
8
- @api_key = api_key
9
- @database_id = database_id
10
- end
11
-
12
- def create_release_note(summary, url)
13
- uri = URI("https://api.notion.com/v1/pages")
14
- request = Net::HTTP::Post.new(uri)
15
- request["Authorization"] = "Bearer #{@api_key}"
16
- request["Notion-Version"] = "2022-06-28"
17
- request.content_type = "application/json"
18
- request.body = {
19
- parent: { type: "database_id", database_id: @database_id },
20
- properties: {
21
- title: {
22
- title: [
23
- {
24
- type: "text",
25
- text: {
26
- content: summary
27
- }
28
- }
29
- ]
30
- },
31
- URL: {
32
- url: url
33
- }
34
- }
35
- }.to_json
36
-
37
- Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
38
- http.request(request)
39
- end
40
- end
41
- end
data/lib/client/openai.rb DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "net/http"
4
- require "json"
5
-
6
- class OpenAiClient
7
- BASE_URL = "https://api.openai.com/v1"
8
-
9
- def initialize(api_key, model: "gpt-3.5-turbo")
10
- @api_key = api_key
11
- @model = model
12
- end
13
-
14
- def summary_pr(title, body, max_tokens: 200)
15
- uri = URI("#{BASE_URL}/chat/completions")
16
- request = Net::HTTP::Post.new(uri)
17
- request["Authorization"] = "Bearer #{@api_key}"
18
- request.content_type = "application/json"
19
- request.body = {
20
- model: @model,
21
- messages: [{ "role": "user",
22
- "content":
23
- "これからGitHub PRのタイトルと内容を送ります。
24
- この内容を、プログラミングやウェブ技術にそれほど詳しくない人のために要約してください。
25
- 日本語で必ず返答してください。
26
- 要約の文章はタイトル:本文:のようにせず、文章だけでお願いします。
27
- タイトルと本文を踏まえて、どのような変更があったのか文章にわかりやすくまとめてください。
28
- 以下がPRの内容です。
29
- タイトル: #{title}
30
- 本文: #{body}" }],
31
- max_tokens: max_tokens
32
- }.to_json
33
-
34
- response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
35
- http.request(request)
36
- end
37
-
38
- JSON.parse(response.body)
39
- end
40
- end
data/lib/main.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "resquirrel"
4
-
5
- Resquirrel.generate_release_note
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Resquirrel
4
- VERSION = "0.1.2"
5
- end
data/lib/resquirrel.rb DELETED
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "resquirrel/version"
4
- require_relative "client/openai"
5
- require_relative "client/notion"
6
- require "json"
7
- require "logger"
8
-
9
- module Resquirrel
10
- def self.generate_release_note
11
- openai_client = OpenAiClient.new(ENV["OPENAI_API_KEY"])
12
- notion_client = NotionClient.new(ENV["NOTION_API_KEY"], ENV["NOTION_DATABASE_ID"])
13
- logger = Logger.new($stdout)
14
-
15
- logger.info "Getting PR information..."
16
- pr_data = JSON.parse(File.read(ENV["GITHUB_EVENT_PATH"]))["pull_request"]
17
-
18
- title = pr_data["title"]
19
- body = pr_data["body"]
20
-
21
- logger.info "Summarizing PR with OpenAI..."
22
- response = openai_client.summary_pr(title, body)
23
-
24
- summary = response["choices"].first["message"]["content"]
25
- url = pr_data["html_url"]
26
-
27
- logger.info "Updating Notion database..."
28
- notion_client.create_release_note(summary, url)
29
- end
30
- end