jekyll-chatgpt-translate 0.0.29 → 0.0.30

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: dc3e9a30a7d065c15ac18a15b5047f94881809857f65ed77330351f95a129d18
4
- data.tar.gz: f6254349103e49e105451d773ac459be452027a5bdafc5a7a004a1d926e7203e
3
+ metadata.gz: 5ac852a5c56511f0e7500c8d907058b3b90f94a976446603fe852ba57132253e
4
+ data.tar.gz: da8e37f819dcbbf5d907bf343d8dee167b36aedeef3863f68ca18bacf0783f11
5
5
  SHA512:
6
- metadata.gz: 15a82d1c87dda2069162db76f00c3a0ade671a76806eeefeeef0239ba3dff9c62c109a1b5772e2fa002ee8da13c26ac8a0b8466235c32a88df557f5896008329
7
- data.tar.gz: 61637d5cd8a3ce93f8e10b5df542b6a3319d23ddd168a3293df44e062a95b000b0137cc1d6e336ef24cc4cc7b4025ec095dbea3960d2099cbdfc517016efc921
6
+ metadata.gz: 43e2cf29a74222c71c645323fbce0fe9ab5f2a27198c558bc0aa3bbab8620c48d794beb97f7e6a7e5898daf47227ab2ed0ea31b4bf92c098334a082d9c6d2f1f
7
+ data.tar.gz: e14939086f28a2a1d865e3332e738f274f2ea18d673599509b5288558ad3856a5e1f67f9787ad4ac57d388854519adf9e125b2583bb5017e55304a2334480324
@@ -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.29'
31
+ s.version = '0.0.30'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Translate Jekyll Pages Through ChatGPT'
34
34
  s.description = [
@@ -46,6 +46,8 @@ class GptTranslate::Plain
46
46
  .gsub(/<!--.+?-->/m, '')
47
47
  .gsub(/{{[^}]+}}/, '')
48
48
  .gsub(/{%.+?%}/, '')
49
+ .gsub(/^\{.+?\}\n/, '')
50
+ .gsub(/\n\{.+?\}$/, '')
49
51
  ).strip
50
52
  end
51
53
 
@@ -23,5 +23,5 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  module GptTranslate
26
- VERSION = '0.0.29'
26
+ VERSION = '0.0.30'
27
27
  end
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
- stub_request(:any, 'https://api.openai.com/v1/chat/completions')
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
- stub_request(:any, 'https://api.openai.com/v1/chat/completions')
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
- stub_request(:any, 'https://api.openai.com/v1/chat/completions')
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
- stub_request(:any, 'https://api.openai.com/v1/chat/completions')
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('boom!', chat.translate('This is the text to send to OpenAI'))
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.29
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-24 00:00:00.000000000 Z
11
+ date: 2023-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iri