jekyll-chatgpt-translate 0.0.45 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.0pdd.yml +2 -21
- data/.github/workflows/actionlint.yml +25 -0
- data/.github/workflows/copyrights.yml +19 -0
- data/.github/workflows/markdown-lint.yml +7 -24
- data/.github/workflows/pdd.yml +19 -0
- data/.github/workflows/rake.yml +10 -27
- data/.github/workflows/reuse.yml +19 -0
- data/.github/workflows/typos.yml +19 -0
- data/.github/workflows/xcop.yml +19 -0
- data/.github/workflows/yamllint.yml +6 -23
- data/.gitignore +9 -3
- data/.rubocop.yml +12 -22
- data/.rultor.yml +4 -22
- data/Gemfile +14 -29
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +5 -5
- data/REUSE.toml +35 -0
- data/Rakefile +3 -31
- data/features/cli.feature +2 -0
- data/features/gem_package.feature +2 -0
- data/features/step_definitions/steps.rb +2 -19
- data/features/support/env.rb +2 -19
- data/jekyll-chatgpt-translate.gemspec +12 -30
- data/lib/jekyll-chatgpt-translate/chatgpt.rb +5 -24
- data/lib/jekyll-chatgpt-translate/generator.rb +10 -23
- data/lib/jekyll-chatgpt-translate/pars.rb +3 -22
- data/lib/jekyll-chatgpt-translate/permalink.rb +3 -22
- data/lib/jekyll-chatgpt-translate/ping.rb +4 -23
- data/lib/jekyll-chatgpt-translate/plain.rb +3 -22
- data/lib/jekyll-chatgpt-translate/prompt.rb +3 -22
- data/lib/jekyll-chatgpt-translate/version.rb +3 -22
- data/lib/jekyll-chatgpt-translate.rb +2 -21
- data/logo.png +0 -0
- data/test/test__helper.rb +31 -24
- data/test/test_chatgpt.rb +4 -24
- data/test/test_generator.rb +3 -23
- data/test/test_pars.rb +3 -23
- data/test/test_permalink.rb +3 -23
- data/test/test_ping.rb +7 -27
- data/test/test_plain.rb +4 -24
- data/test/test_prompt.rb +5 -25
- metadata +56 -34
data/features/support/env.rb
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2023-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'simplecov'
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'English'
|
|
26
7
|
|
|
@@ -28,7 +9,7 @@ Gem::Specification.new do |s|
|
|
|
28
9
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
29
10
|
s.required_ruby_version = '>= 3.0'
|
|
30
11
|
s.name = 'jekyll-chatgpt-translate'
|
|
31
|
-
s.version = '0.0
|
|
12
|
+
s.version = '0.2.0'
|
|
32
13
|
s.license = 'MIT'
|
|
33
14
|
s.summary = 'Translate Jekyll Pages Through ChatGPT'
|
|
34
15
|
s.description = [
|
|
@@ -42,13 +23,14 @@ Gem::Specification.new do |s|
|
|
|
42
23
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
43
24
|
s.rdoc_options = ['--charset=UTF-8']
|
|
44
25
|
s.extra_rdoc_files = %w[README.md LICENSE.txt]
|
|
45
|
-
s.
|
|
46
|
-
s.
|
|
47
|
-
s.
|
|
48
|
-
s.
|
|
49
|
-
s.
|
|
50
|
-
s.
|
|
51
|
-
s.
|
|
52
|
-
s.
|
|
26
|
+
s.add_dependency 'base64', '~>0.3'
|
|
27
|
+
s.add_dependency 'humanize', '~>3.1'
|
|
28
|
+
s.add_dependency 'iri', '~>0.11'
|
|
29
|
+
s.add_dependency 'iso-639', '~>0.3'
|
|
30
|
+
s.add_dependency 'jekyll', '~>3.10'
|
|
31
|
+
s.add_dependency 'json', '~>2.18'
|
|
32
|
+
s.add_dependency 'redcarpet', '~>3.6'
|
|
33
|
+
s.add_dependency 'ruby-openai', '~>8.3'
|
|
34
|
+
s.add_dependency 'tiktoken_ruby', '~>0.0'
|
|
53
35
|
s.metadata['rubygems_mfa_required'] = 'true'
|
|
54
36
|
end
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'jekyll'
|
|
26
7
|
require 'json'
|
|
@@ -35,7 +16,7 @@ module GptTranslate; end
|
|
|
35
16
|
|
|
36
17
|
# Abstraction of ChatGPT.
|
|
37
18
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
38
|
-
# Copyright:: Copyright (c) 2023-
|
|
19
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
39
20
|
# License:: MIT
|
|
40
21
|
class GptTranslate::ChatGPT
|
|
41
22
|
# Is TRUE if we already shown to the user the available models.
|
|
@@ -89,9 +70,9 @@ class GptTranslate::ChatGPT
|
|
|
89
70
|
ready[i] = "> #{translate_par(par[2..])}"
|
|
90
71
|
elsif par.start_with?('* ')
|
|
91
72
|
ready[i] = "* #{translate_par(par[2..])}"
|
|
92
|
-
elsif
|
|
73
|
+
elsif /^[0-9]+\. /.match?(par)
|
|
93
74
|
ready[i] = "1. #{translate_par(par.split('.', 2)[1])}"
|
|
94
|
-
elsif
|
|
75
|
+
elsif /^[^\p{Alnum}*'"\[]/.match?(par)
|
|
95
76
|
Jekyll.logger.debug("Not translating this, b/c it's not a plain text: #{par.inspect}")
|
|
96
77
|
ready[i] = par
|
|
97
78
|
else
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'jekyll'
|
|
26
7
|
require 'fileutils'
|
|
@@ -36,7 +17,7 @@ module GptTranslate; end
|
|
|
36
17
|
|
|
37
18
|
# Pages generator.
|
|
38
19
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
39
|
-
# Copyright:: Copyright (c) 2023-
|
|
20
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
40
21
|
# License:: MIT
|
|
41
22
|
class GptTranslate::Generator < Jekyll::Generator
|
|
42
23
|
safe true
|
|
@@ -44,6 +25,10 @@ class GptTranslate::Generator < Jekyll::Generator
|
|
|
44
25
|
|
|
45
26
|
# Main plugin action, called by Jekyll-core
|
|
46
27
|
def generate(site)
|
|
28
|
+
if ARGV.include?('--offline')
|
|
29
|
+
Jekyll.logger.info("jekyll-chatgpt-translate #{GptTranslate::VERSION} skipped, due to the --offline option")
|
|
30
|
+
return
|
|
31
|
+
end
|
|
47
32
|
Jekyll.logger.info("jekyll-chatgpt-translate #{GptTranslate::VERSION} starting...")
|
|
48
33
|
config ||= site.config['chatgpt-translate'] || {}
|
|
49
34
|
home = config['tmpdir'] || '_chatgpt-translate'
|
|
@@ -60,7 +45,7 @@ class GptTranslate::Generator < Jekyll::Generator
|
|
|
60
45
|
translated = 0
|
|
61
46
|
copied = 0
|
|
62
47
|
model = config['model'] || 'gpt-3.5-turbo'
|
|
63
|
-
marker = "Translated by ChatGPT #{model}#{
|
|
48
|
+
marker = "Translated by ChatGPT #{model}#{"/#{version}" unless version.empty?}"
|
|
64
49
|
site.posts.docs.shuffle.each_with_index do |doc, pos|
|
|
65
50
|
plain = GptTranslate::Plain.new(doc.content).to_s
|
|
66
51
|
layout = doc['layout']
|
|
@@ -163,12 +148,14 @@ in #{(Time.now - pstart).round(2)}s: #{path} (#{File.size(path)} bytes)")
|
|
|
163
148
|
@link = link
|
|
164
149
|
end
|
|
165
150
|
|
|
151
|
+
# rubocop:disable Naming/PredicateMethod
|
|
166
152
|
def write(_dest)
|
|
167
153
|
FileUtils.mkdir_p(File.dirname(path))
|
|
168
154
|
File.write(path, @html)
|
|
169
155
|
Jekyll.logger.info("Saved #{@html.split.count} words to #{path.inspect}")
|
|
170
156
|
true
|
|
171
157
|
end
|
|
158
|
+
# rubocop:enable Naming/PredicateMethod
|
|
172
159
|
end
|
|
173
160
|
|
|
174
161
|
private
|
|
@@ -1,33 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
# The module we are in.
|
|
26
7
|
module GptTranslate; end
|
|
27
8
|
|
|
28
9
|
# Markdown broken down ito pars.
|
|
29
10
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
30
|
-
# Copyright:: Copyright (c) 2023-
|
|
11
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
31
12
|
# License:: MIT
|
|
32
13
|
class GptTranslate::Pars
|
|
33
14
|
# Ctor.
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'cgi'
|
|
26
7
|
|
|
@@ -29,7 +10,7 @@ module GptTranslate; end
|
|
|
29
10
|
|
|
30
11
|
# Permalink.
|
|
31
12
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
32
|
-
# Copyright:: Copyright (c) 2023-
|
|
13
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
33
14
|
# License:: MIT
|
|
34
15
|
class GptTranslate::Permalink
|
|
35
16
|
def initialize(doc, template)
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'iri'
|
|
26
7
|
require 'net/http'
|
|
@@ -29,14 +10,14 @@ require_relative 'version'
|
|
|
29
10
|
|
|
30
11
|
# see https://stackoverflow.com/a/6048451/187141
|
|
31
12
|
require 'openssl'
|
|
32
|
-
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
|
13
|
+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE unless defined?(OpenSSL::SSL::VERIFY_PEER)
|
|
33
14
|
|
|
34
15
|
# The module we are in.
|
|
35
16
|
module GptTranslate; end
|
|
36
17
|
|
|
37
18
|
# Ping one page of a site.
|
|
38
19
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
39
|
-
# Copyright:: Copyright (c) 2023-
|
|
20
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
40
21
|
# License:: MIT
|
|
41
22
|
class GptTranslate::Ping
|
|
42
23
|
# Ctor.
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'redcarpet'
|
|
26
7
|
|
|
@@ -29,7 +10,7 @@ module GptTranslate; end
|
|
|
29
10
|
|
|
30
11
|
# Markdown to plain text.
|
|
31
12
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
32
|
-
# Copyright:: Copyright (c) 2023-
|
|
13
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
33
14
|
# License:: MIT
|
|
34
15
|
class GptTranslate::Plain
|
|
35
16
|
# Ctor.
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'iso-639'
|
|
26
7
|
require 'humanize'
|
|
@@ -30,7 +11,7 @@ module GptTranslate; end
|
|
|
30
11
|
|
|
31
12
|
# Prompt for ChatGPT.
|
|
32
13
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
33
|
-
# Copyright:: Copyright (c) 2023-
|
|
14
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
34
15
|
# License:: MIT
|
|
35
16
|
class GptTranslate::Prompt
|
|
36
17
|
# Ctor.
|
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
module GptTranslate
|
|
26
|
-
VERSION = '0.0
|
|
7
|
+
VERSION = '0.2.0'
|
|
27
8
|
end
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'jekyll-chatgpt-translate/generator'
|
data/logo.png
CHANGED
|
Binary file
|
data/test/test__helper.rb
CHANGED
|
@@ -1,39 +1,46 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2023-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
$stdout.sync = true
|
|
24
7
|
|
|
25
8
|
require 'simplecov'
|
|
26
|
-
|
|
9
|
+
require 'simplecov-cobertura'
|
|
10
|
+
unless SimpleCov.running
|
|
11
|
+
SimpleCov.command_name('test')
|
|
12
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
|
13
|
+
[
|
|
14
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
15
|
+
SimpleCov::Formatter::CoberturaFormatter
|
|
16
|
+
]
|
|
17
|
+
)
|
|
18
|
+
SimpleCov.minimum_coverage 85
|
|
19
|
+
SimpleCov.minimum_coverage_by_file 80
|
|
20
|
+
SimpleCov.start do
|
|
21
|
+
add_filter 'test/'
|
|
22
|
+
add_filter 'vendor/'
|
|
23
|
+
add_filter 'target/'
|
|
24
|
+
track_files 'lib/**/*.rb'
|
|
25
|
+
track_files '*.rb'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
require 'minitest/reporters'
|
|
30
|
+
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
|
31
|
+
Minitest.load :minitest_reporter
|
|
32
|
+
|
|
33
|
+
require 'minitest/autorun'
|
|
27
34
|
|
|
28
35
|
require 'jekyll'
|
|
29
|
-
Jekyll.logger.adjust_verbosity(verbose:
|
|
36
|
+
Jekyll.logger.adjust_verbosity(verbose: false)
|
|
30
37
|
|
|
31
38
|
# The module we are in.
|
|
32
39
|
module GptTranslate; end
|
|
33
40
|
|
|
34
41
|
# Fake.
|
|
35
42
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
36
|
-
# Copyright:: Copyright (c) 2023-
|
|
43
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
37
44
|
# License:: MIT
|
|
38
45
|
class GptTranslate::FakeSite
|
|
39
46
|
attr_reader :config, :pages, :static_files
|
|
@@ -81,7 +88,7 @@ end
|
|
|
81
88
|
|
|
82
89
|
# Fake.
|
|
83
90
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
84
|
-
# Copyright:: Copyright (c) 2023-
|
|
91
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
85
92
|
# License:: MIT
|
|
86
93
|
class GptTranslate::FakeDocument
|
|
87
94
|
attr_reader :data
|
|
@@ -118,7 +125,7 @@ end
|
|
|
118
125
|
|
|
119
126
|
# Fake.
|
|
120
127
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
121
|
-
# Copyright:: Copyright (c) 2023-
|
|
128
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
122
129
|
# License:: MIT
|
|
123
130
|
class GptTranslate::FakePosts
|
|
124
131
|
attr_reader :config
|
data/test/test_chatgpt.rb
CHANGED
|
@@ -1,35 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
24
|
-
|
|
25
|
-
require 'minitest/autorun'
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
5
|
+
|
|
26
6
|
require 'webmock/minitest'
|
|
27
7
|
require_relative 'test__helper'
|
|
28
8
|
require_relative '../lib/jekyll-chatgpt-translate/chatgpt'
|
|
29
9
|
|
|
30
10
|
# ChatGPT test.
|
|
31
11
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
32
|
-
# Copyright:: Copyright (c) 2023-
|
|
12
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
33
13
|
# License:: MIT
|
|
34
14
|
class GptTranslate::ChatGPTTest < Minitest::Test
|
|
35
15
|
def test_short_text
|
data/test/test_generator.rb
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2023-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
|
-
require 'minitest/autorun'
|
|
26
6
|
require 'tmpdir'
|
|
27
7
|
require 'webmock/minitest'
|
|
28
8
|
require_relative 'test__helper'
|
|
@@ -30,7 +10,7 @@ require_relative '../lib/jekyll-chatgpt-translate/generator'
|
|
|
30
10
|
|
|
31
11
|
# Generator test.
|
|
32
12
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
33
|
-
# Copyright:: Copyright (c) 2023-
|
|
13
|
+
# Copyright:: Copyright (c) 2023-2026 Yegor Bugayenko
|
|
34
14
|
# License:: MIT
|
|
35
15
|
class GptTranslate::GeneratorTest < Minitest::Test
|
|
36
16
|
def test_simple_scenario
|