jekyll-chatgpt-translate 0.0.28 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/features/cli.feature +5 -0
- data/jekyll-chatgpt-translate.gemspec +1 -1
- data/lib/jekyll-chatgpt-translate/generator.rb +1 -1
- data/lib/jekyll-chatgpt-translate/plain.rb +2 -0
- data/lib/jekyll-chatgpt-translate/version.rb +1 -1
- data/test/test_chatgpt.rb +12 -9
- data/test/test_plain.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ac852a5c56511f0e7500c8d907058b3b90f94a976446603fe852ba57132253e
|
4
|
+
data.tar.gz: da8e37f819dcbbf5d907bf343d8dee167b36aedeef3863f68ca18bacf0783f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43e2cf29a74222c71c645323fbce0fe9ab5f2a27198c558bc0aa3bbab8620c48d794beb97f7e6a7e5898daf47227ab2ed0ea31b4bf92c098334a082d9c6d2f1f
|
7
|
+
data.tar.gz: e14939086f28a2a1d865e3332e738f274f2ea18d673599509b5288558ad3856a5e1f67f9787ad4ac57d388854519adf9e125b2583bb5017e55304a2334480324
|
data/.rubocop.yml
CHANGED
data/features/cli.feature
CHANGED
@@ -103,6 +103,10 @@ Feature: Simple site building
|
|
103
103
|
language: en
|
104
104
|
permalink: about-me.html
|
105
105
|
"""
|
106
|
+
And I have a "boom.html" file with content:
|
107
|
+
"""
|
108
|
+
Boom!
|
109
|
+
"""
|
106
110
|
And I have a "_layouts/default.html" file with content:
|
107
111
|
"""
|
108
112
|
{{ content }}
|
@@ -120,3 +124,4 @@ Feature: Simple site building
|
|
120
124
|
And File "_site/2023/01/01/hello.html" exists
|
121
125
|
And File "_site/about-me.html" exists
|
122
126
|
And File "_site/about-me.html" contains "foo-file-foo"
|
127
|
+
And File "_site/boom.html" exists
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
29
29
|
s.required_ruby_version = '>= 2.6'
|
30
30
|
s.name = 'jekyll-chatgpt-translate'
|
31
|
-
s.version = '0.0.
|
31
|
+
s.version = '0.0.30'
|
32
32
|
s.license = 'MIT'
|
33
33
|
s.summary = 'Translate Jekyll Pages Through ChatGPT'
|
34
34
|
s.description = [
|
@@ -106,7 +106,7 @@ class GptTranslate::Generator < Jekyll::Generator
|
|
106
106
|
mode: 'a+'
|
107
107
|
)
|
108
108
|
site.pages << Jekyll::Page.new(site, site.source, File.dirname(path), File.basename(path))
|
109
|
-
site.static_files.delete_if { |f|
|
109
|
+
site.static_files.delete_if { |f| f.is_a?(GptTranslate::Ping::DownloadedFile) && f.link == link }
|
110
110
|
translated += 1
|
111
111
|
Jekyll.logger.info("Translated via ChatGPT \
|
112
112
|
in #{(Time.now - start).round(2)}s: #{path} (#{File.size(path)} bytes)")
|
data/test/test_chatgpt.rb
CHANGED
@@ -38,22 +38,19 @@ class GptTranslate::ChatGPTTest < Minitest::Test
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_start_with_link
|
41
|
-
|
42
|
-
.to_return(body: '{"choices":[{"message":{"content": "done!"}}]}')
|
41
|
+
stub_it!
|
43
42
|
chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
|
44
43
|
assert_equal('done!', chat.translate('[OpenAI](https://openai.com) is the creator of ChatGPT', min: 10))
|
45
44
|
end
|
46
45
|
|
47
46
|
def test_unordered_list_item
|
48
|
-
|
49
|
-
.to_return(body: '{"choices":[{"message":{"content": "done!"}}]}')
|
47
|
+
stub_it!
|
50
48
|
chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
|
51
49
|
assert_equal("* done!\n\n* done!", chat.translate("* First\n\n* Second", min: 1))
|
52
50
|
end
|
53
51
|
|
54
52
|
def test_ordered_list_item
|
55
|
-
|
56
|
-
.to_return(body: '{"choices":[{"message":{"content": "done!"}}]}')
|
53
|
+
stub_it!
|
57
54
|
chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
|
58
55
|
assert_equal("1. done!\n\n1. done!", chat.translate("1. First\n\n2. Second", min: 1))
|
59
56
|
end
|
@@ -94,9 +91,15 @@ class GptTranslate::ChatGPTTest < Minitest::Test
|
|
94
91
|
end
|
95
92
|
|
96
93
|
def test_through_webmock
|
97
|
-
|
98
|
-
.to_return(body: '{"choices":[{"message":{"content": "boom!"}}]}')
|
94
|
+
stub_it!
|
99
95
|
chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
|
100
|
-
assert_equal('
|
96
|
+
assert_equal('done!', chat.translate('This is the text to send to OpenAI'))
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def stub_it!
|
102
|
+
stub_request(:any, 'https://api.openai.com/v1/chat/completions')
|
103
|
+
.to_return(body: '{"choices":[{"message":{"content": "done!"}}]}')
|
101
104
|
end
|
102
105
|
end
|
data/test/test_plain.rb
CHANGED
@@ -40,6 +40,11 @@ class GptTranslate::PlainTest < Minitest::Test
|
|
40
40
|
assert_equal('Hi, dude!', GptTranslate::Plain.new(" Hi,\ndude!\n").to_s)
|
41
41
|
end
|
42
42
|
|
43
|
+
def test_strip_meta_markup
|
44
|
+
assert_equal('Hello, world!', GptTranslate::Plain.new("{:name='boom'}\nHello, world!").to_s)
|
45
|
+
assert_equal('Hello, world!', GptTranslate::Plain.new("Hello, world!\n{: .foo-class}").to_s)
|
46
|
+
end
|
47
|
+
|
43
48
|
def test_lists
|
44
49
|
assert_equal(
|
45
50
|
"* first\n\n* second\n\n* third",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-chatgpt-translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iri
|