jekyll-chatgpt-translate 0.0.27 → 0.0.29

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: 416596f5103bd30f33ffd088c1da48fd422e9ed90be9a89de3874aa8fc95d26a
4
- data.tar.gz: 0b091f92583d249630aace8b8e46246178469680ea35fe74b546fae1e97a2c3c
3
+ metadata.gz: dc3e9a30a7d065c15ac18a15b5047f94881809857f65ed77330351f95a129d18
4
+ data.tar.gz: f6254349103e49e105451d773ac459be452027a5bdafc5a7a004a1d926e7203e
5
5
  SHA512:
6
- metadata.gz: be86868fafea658f8cdf68344923a9f1b137893678254e899709407fc7146293d43baa9e73e448d3dd23f0a9c57605e62aa20132ce03cb9a15182c4c59828a7a
7
- data.tar.gz: 27eddf1b7a551d5c998b1cbcd781709ca9c02b0975d216f31ff431d2c79dbf2b86ad2ad0c96805cf1b5d810d3e6d6581c30269b1ddc6170e4146de23f2a89779
6
+ metadata.gz: 15a82d1c87dda2069162db76f00c3a0ade671a76806eeefeeef0239ba3dff9c62c109a1b5772e2fa002ee8da13c26ac8a0b8466235c32a88df557f5896008329
7
+ data.tar.gz: 61637d5cd8a3ce93f8e10b5df542b6a3319d23ddd168a3293df44e062a95b000b0137cc1d6e336ef24cc4cc7b4025ec095dbea3960d2099cbdfc517016efc921
data/.rubocop.yml CHANGED
@@ -20,9 +20,9 @@ Metrics/AbcSize:
20
20
  Metrics/BlockLength:
21
21
  Max: 100
22
22
  Metrics/CyclomaticComplexity:
23
- Max: 20
23
+ Max: 30
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,43 @@ 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 "boom.html" file with content:
107
+ """
108
+ Boom!
109
+ """
110
+ And I have a "_layouts/default.html" file with content:
111
+ """
112
+ {{ content }}
113
+ """
114
+ And I have a "_posts/2023-01-01-hello.md" file with content:
115
+ """
116
+ ---
117
+ title: foo
118
+ ---
119
+ foo-file-foo
120
+ """
121
+ Then I build Jekyll site
122
+ And Exit code is zero
123
+ And Stdout contains "Re-translation required for"
124
+ And File "_site/2023/01/01/hello.html" exists
125
+ And File "_site/about-me.html" exists
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.27'
31
+ s.version = '0.0.29'
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| f.is_a?(GptTranslate::Ping::DownloadedFile) && 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)")
@@ -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.27'
26
+ VERSION = '0.0.29'
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.27
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko