jekyll-chatgpt-translate 0.0.26 → 0.0.28

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: 9f480f74d9f096d1b24d516f05c1c24a27cefe7e87cc9db917d2fffe727646fe
4
- data.tar.gz: 0dd088c831b8a3d9685bf4363ea7821d83d8602767fb933740b938552475d98e
3
+ metadata.gz: 47dd2b65d590842eeb70cba01d693890760c0c4035ca984d3ccabca7167feeff
4
+ data.tar.gz: 1c2f8d6e3eac9ad4ccaae305cdefd032fa894d080305ccbbebef619dbe5a353c
5
5
  SHA512:
6
- metadata.gz: c286215fa7b40fab206be74d7f03d02963f307009ba6d91c0f1ff7ce06795eb29be1588c022a994696755677e6640fb595aca7246474d8a1bc9072f38f5458a1
7
- data.tar.gz: af831575ce9749aada2c42ad5c4d8798890490e5e0795cd87f70cce9a2d8b7bbaa3d7dfba9b95e9b5f81eaef2e9f9513ca1542341e1393bc4878c6ee257911af
6
+ metadata.gz: 531429f2e20fe185d257a0f6ace1b58b4b5b1bc7b69b055eab9d44bcd50b4edfc363a43248548b81ddf3f7ae56627e738e003b6fdb14573cf12f45b03f9a1f19
7
+ data.tar.gz: 6a7608330ad32747f3108409578aa26bffe357a60d11677a487371da924fb62a1c89d1d3a2a0fae69953d715857051c3ba7988ba2ce85dcf14a6d55bea4ad8ec
data/.rubocop.yml CHANGED
@@ -22,7 +22,7 @@ Metrics/BlockLength:
22
22
  Metrics/CyclomaticComplexity:
23
23
  Max: 20
24
24
  Metrics/PerceivedComplexity:
25
- Max: 20
25
+ Max: 30
26
26
  Layout/EmptyLineAfterGuardClause:
27
27
  Enabled: false
28
28
  Naming/FileName:
data/features/cli.feature CHANGED
@@ -85,3 +85,38 @@ Feature: Simple site building
85
85
  And File "_site/2023/01/01/hello.html" exists
86
86
  And File "_site/about-me.html" exists
87
87
  And File "_site/about-me.html" contains "Yegor Bugayenko"
88
+
89
+ Scenario: Simple download of existing page, but with re-translation
90
+ Given I have a "_config.yml" file with content:
91
+ """
92
+ url: https://www.yegor256.com
93
+ markdown: kramdown
94
+ plugins:
95
+ - jekyll-chatgpt-translate
96
+ chatgpt-translate:
97
+ source: en
98
+ version: "my-own-version"
99
+ api_key: "it-is-not-used, because EN to EN translation"
100
+ layout: default
101
+ targets:
102
+ -
103
+ language: en
104
+ permalink: about-me.html
105
+ """
106
+ And I have a "_layouts/default.html" file with content:
107
+ """
108
+ {{ content }}
109
+ """
110
+ And I have a "_posts/2023-01-01-hello.md" file with content:
111
+ """
112
+ ---
113
+ title: foo
114
+ ---
115
+ foo-file-foo
116
+ """
117
+ Then I build Jekyll site
118
+ And Exit code is zero
119
+ And Stdout contains "Re-translation required for"
120
+ And File "_site/2023/01/01/hello.html" exists
121
+ And File "_site/about-me.html" exists
122
+ And File "_site/about-me.html" contains "foo-file-foo"
@@ -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.26'
31
+ s.version = '0.0.28'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Translate Jekyll Pages Through ChatGPT'
34
34
  s.description = [
@@ -106,6 +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| p f.link == link }
109
110
  translated += 1
110
111
  Jekyll.logger.info("Translated via ChatGPT \
111
112
  in #{(Time.now - start).round(2)}s: #{path} (#{File.size(path)} bytes)")
@@ -56,10 +56,10 @@ class GptTranslate::Ping
56
56
  before = Net::HTTP.get_response(URI(uri))
57
57
  if before.is_a?(Net::HTTPSuccess)
58
58
  html = before.body
59
+ @site.static_files << DownloadedFile.new(@site, @path, html)
59
60
  if html.include?(marker)
60
61
  Jekyll.logger.info("No need to translate, the page exists at \
61
62
  #{uri.inspect} (#{html.split.count} words)")
62
- @site.static_files << DownloadedFile.new(@site, @path, html)
63
63
  return true
64
64
  end
65
65
  Jekyll.logger.info("Re-translation required for #{uri.inspect}")
@@ -76,9 +76,12 @@ class GptTranslate::Ping
76
76
 
77
77
  # The file we just downloaded.
78
78
  class DownloadedFile < Jekyll::StaticFile
79
- def initialize(site, path, html)
80
- super(site, site.dest, '', path)
79
+ attr_reader :link
80
+
81
+ def initialize(site, link, html)
82
+ super(site, site.dest, '', link)
81
83
  @html = html
84
+ @link = link
82
85
  end
83
86
 
84
87
  def write(_dest)
@@ -23,5 +23,5 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  module GptTranslate
26
- VERSION = '0.0.26'
26
+ VERSION = '0.0.28'
27
27
  end
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.26
4
+ version: 0.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko