jekyll-chatgpt-translate 0.0.23 → 0.0.24

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: 245b89b06aae1508c1fd00fa9575ba342ac7340212946f92308307da1e01de1e
4
- data.tar.gz: 62a7ba956bc489efe84cf119457ffd181208882dd0c1939242df08a123c11b10
3
+ metadata.gz: 496c59378248bd1973071e0ed6d01d0e55253cf0c47dce9f72b2704ba315e9e3
4
+ data.tar.gz: 13905a9d5f52ed1558f1e0679af7ec236936b4d77eb97d0c8e63ce3e0cb72ac7
5
5
  SHA512:
6
- metadata.gz: 8516fa43643cd48288761e4fbe4afdb628dab9281482ce6e486b05e33d214c610604958d70810ce6ba61918956952fadeadfa4397ffa0e0079d671bc379c01e9
7
- data.tar.gz: f962f34852a2184821635ed8683f0cdcd3373934f185a716f5f1e4e20c8bacd8b671746209ce829fd241da5a61dffe52e2eae74187b957c245e64783b049d86c
6
+ metadata.gz: 63e2c67379437c2f6aa20cff512452fcb2d2237b1e5d8a1d8bb0155c67a4ee044bfb4957765bff3daab4d24fdb875779ec9bffd8419e1331f0efd3667ee19d38
7
+ data.tar.gz: 84ab3c8daa5173849cbcaeeb067ddf7470fa04b099c1793582c99f44f4a64e0fbf65b842817e0c489996cd742d8335de3f4fc62576aaede50212aeb4ff7d7c22
@@ -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.23'
31
+ s.version = '0.0.24'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Translate Jekyll Pages Through ChatGPT'
34
34
  s.description = [
@@ -59,7 +59,7 @@ class GptTranslate::ChatGPT
59
59
  elsif par.start_with?('```') || par.end_with?('```')
60
60
  Jekyll.logger.debug("Not translating this code block: #{par.inspect}")
61
61
  par
62
- elsif par =~ /^[^\p{Alnum}\*'"]/
62
+ elsif par =~ /^[^\p{Alnum}\*'"\[]/
63
63
  Jekyll.logger.debug("Not translating this, b/c it's not a plain text: #{par.inspect}")
64
64
  par
65
65
  elsif @key.empty?
@@ -62,6 +62,7 @@ class GptTranslate::Generator < Jekyll::Generator
62
62
  site.posts.docs.shuffle.each do |doc|
63
63
  plain = GptTranslate::Plain.new(doc.content).to_s
64
64
  config['targets'].each do |target|
65
+ start = Time.now
65
66
  link = GptTranslate::Permalink.new(doc, target['permalink']).to_path
66
67
  lang = target['language']
67
68
  raise 'Language must be defined for each target' if target.nil?
@@ -106,7 +107,8 @@ class GptTranslate::Generator < Jekyll::Generator
106
107
  )
107
108
  site.pages << Jekyll::Page.new(site, site.source, File.dirname(path), File.basename(path))
108
109
  translated += 1
109
- Jekyll.logger.info("Translated via ChatGPT: #{path} (#{File.size(path)} bytes)")
110
+ Jekyll.logger.info("Translated via ChatGPT \
111
+ in #{(Time.now - start).round(2)}s: #{path} (#{File.size(path)} bytes)")
110
112
  end
111
113
  doc.data["translated-#{lang}-url"] = link
112
114
  doc.data['chatgpt-model'] = model
@@ -23,5 +23,5 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  module GptTranslate
26
- VERSION = '0.0.23'
26
+ VERSION = '0.0.24'
27
27
  end
data/test/test_chatgpt.rb CHANGED
@@ -37,6 +37,13 @@ class GptTranslate::ChatGPTTest < Minitest::Test
37
37
  assert_equal('Hello, world!', chat.translate('Hello, world!'))
38
38
  end
39
39
 
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!"}}]}')
43
+ chat = GptTranslate::ChatGPT.new('fake-key', 'gpt-3.5-turbo', 'en', 'ru')
44
+ assert_equal('done!', chat.translate('[OpenAI](https://openai.com) is the creator of ChatGPT', min: 10))
45
+ end
46
+
40
47
  def test_dry_mode
41
48
  chat = GptTranslate::ChatGPT.new('', 'foo', 'xx', 'xx')
42
49
  assert_equal(38, chat.translate('This text should not be sent to OpenAI', min: 100).length)
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.23
4
+ version: 0.0.24
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-23 00:00:00.000000000 Z
11
+ date: 2023-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iri