jekyll-chatgpt-translate 0.0.12 → 0.0.13

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: ed6617e3b8bf46db264f484e1286ea1f91295f4fb47512cb983a6fc59c7922df
4
- data.tar.gz: a0f6c744cd4bf2b2558d7b5568f1ca961a3f854e5264b9d64bb8b24249f03e3a
3
+ metadata.gz: 864696015c8e2b7ee1abba3e5bd8aee3310d7d9d3d85721b5a082b45eef6cd0b
4
+ data.tar.gz: cfc8b8d09865af57aea8202be714c0ee7211da0fc2121873b8004f37cf40a507
5
5
  SHA512:
6
- metadata.gz: 2d58f41b76840e524e9f1d72c2a4816b33d9e57ad6b207f54baa226abf68ae6cca848cb8cce80cf1f4502a3ad9b52871db7f7708463bf4101fdbf8c21e5f99bb
7
- data.tar.gz: f85b41ad75176c9989a8a3715fd84485b3a2fcbe03e6cca879b7a201ac4b5745dda0aa16695f26cbaad1ec901b84c6837f983f7a04cee94aa26752d13ef41593
6
+ metadata.gz: 83cbb3ae370b246351ce64302e48b0d5c4b94fcc985fb7c239f36f7c2767e5779fa45998ae6b808b8c8e973369ee6d6f21c9a62b241cb5459fb235eb9a424d01
7
+ data.tar.gz: 9400ee361c82cf27582e416a607d292f16850269fa204a837ff40f052917692dbb0a8d9f3aade9d21d0c2d74870028d6c8c4aec50b4b0efd177f6efc6a220e5c
@@ -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.12'
31
+ s.version = '0.0.13'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Translate Jekyll Pages Through ChatGPT'
34
34
  s.description = [
@@ -51,21 +51,25 @@ class GptTranslate::Ping
51
51
  home = @site.config['url']
52
52
  return false if home.nil?
53
53
  uri = Iri.new(home).path(@path)
54
- before = Net::HTTP.get_response(URI(uri.to_s))
55
- if before.is_a?(Net::HTTPSuccess)
56
- html = before.body
57
- if html.include?(marker)
58
- Jekyll.logger.info("No need to translate, the page exists at \
59
- #{uri} (#{html.split.count} words), saved to #{file}")
60
- FileUtils.mkdir_p(File.dirname(file))
61
- File.write(file, html)
62
- return true
54
+ begin
55
+ before = Net::HTTP.get_response(URI(uri.to_s))
56
+ if before.is_a?(Net::HTTPSuccess)
57
+ html = before.body
58
+ if html.include?(marker)
59
+ Jekyll.logger.info("No need to translate, the page exists at \
60
+ #{uri} (#{html.split.count} words), saved to #{file}")
61
+ FileUtils.mkdir_p(File.dirname(file))
62
+ File.write(file, html)
63
+ return true
64
+ end
65
+ Jekyll.logger.info("Re-translation required for \"#{uri}\"")
66
+ else
67
+ Jekyll.logger.info("The page is absent, will translate \"#{uri}\"")
63
68
  end
64
- Jekyll.logger.info("Re-translation required for #{uri}")
65
- else
66
- Jekyll.logger.info("The page is absent, will translate: #{uri}")
69
+ Jekyll.logger.debug("GET \"#{uri}\": #{before.code}")
70
+ rescue StandardError => e
71
+ Jekyll.logger.info("Failed to ping \"#{uri}\": #{e.message}")
67
72
  end
68
- Jekyll.logger.debug("GET #{uri}: #{before.code}")
69
73
  false
70
74
  end
71
75
  end
@@ -23,5 +23,5 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  module GptTranslate
26
- VERSION = '0.0.12'
26
+ VERSION = '0.0.13'
27
27
  end
data/test/test_ping.rb CHANGED
@@ -59,6 +59,15 @@ class GptTranslate::PingTest < Minitest::Test
59
59
  end
60
60
  end
61
61
 
62
+ def test_wrong_address
63
+ WebMock.allow_net_connect!
64
+ site = FakeSite.new({ 'url' => 'https://localhost:1/' })
65
+ ping = GptTranslate::Ping.new(site, '/boom.html')
66
+ Tempfile.open do |f|
67
+ assert(!ping.found?(f, ''))
68
+ end
69
+ end
70
+
62
71
  def test_relative_path
63
72
  assert_raises do
64
73
  GptTranslate::Ping.new({}, '404.html')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-chatgpt-translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko