jekyll-chatgpt-translate 0.0.4 → 0.0.6

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: a4a911c9ca494d5175e1e16240912894aa7fb42225a6fc02ff1a4550fbc2cfcd
4
- data.tar.gz: 4ed03539027a1aa9d21d6def567ad60daf6e495edd4b85ec1903f866dde0262a
3
+ metadata.gz: 3b2375ac0c0ab9bc728d9e1d6684b4cb1f1424ae5718095a8644a447b91487e8
4
+ data.tar.gz: bf13ed8a50dad4ca6f4cdd1d719728a57e0c7081a16eda4d56bb6dbbcae5bb3d
5
5
  SHA512:
6
- metadata.gz: d86c34428bc11ccbbc95fd6deebbdcc14f03d195f1883abfcdf8c699d79cec0a12f089adbb38685dcc25c272480a3a3752d620275501bb41ef89c0973dbb4a4a
7
- data.tar.gz: d3d32a7fb2c971e3a8750ab23d0359988b99bcefcfe74763d35251feb748446d004ef0ab953a8957be80bef9b60d84f497cb2a4d2f1ca8e49440def149cd31b8
6
+ metadata.gz: 26dbc8403f36f4bfb8c127efac666dd8884823be38b9fda7a7c92800c50f6805cfe7aa8b04251830412025ae3582a799331fdff0e8336507a6c2004fbbbbf49c
7
+ data.tar.gz: 5f5cd81fd192d7945f57b23148df57ebd95f09ff8b917190ffd89cb2a8dc4d44f49afffc78d7032c0194a6a0e0aa25ce95b80d97a210cfd1cbfe9965e0a44f6c
data/README.md CHANGED
@@ -42,22 +42,22 @@ The plugin is compatible with
42
42
 
43
43
  Full list of options available to specify in `_config.yml`:
44
44
 
45
- * `model` (optional) --- specifies the model to use by ChatGPT.
45
+ * `model` (optional) specifies the model to use by ChatGPT.
46
46
 
47
- * `source` (optional) --- is the ISO-839-1 code of the source language.
47
+ * `source` (optional) is the ISO-839-1 code of the source language.
48
48
 
49
- * `layout` (optional) --- is name of the file in `_layouts` directory, without the extension.
49
+ * `layout` (optional) is name of the file in `_layouts` directory, without the extension.
50
50
  This layout will be specified for the pages generated by this plugin.
51
51
 
52
- * `targets` (mandatory) --- an array of target languages, each of which has the following attributes
52
+ * `targets` (mandatory) an array of target languages, each of which has the following attributes
53
53
 
54
- * `language` (mandatory) --- ISO-839-1 code of the target language
54
+ * `language` (mandatory) ISO-839-1 code of the target language
55
55
 
56
- * `permalink` (mandatory) --- template to use for newly generated pages
56
+ * `permalink` (mandatory) template to use for newly generated pages
57
57
 
58
- * `layout` (optional) --- the name of the file in the `_layouts` directory
58
+ * `layout` (optional) the name of the file in the `_layouts` directory
59
59
 
60
- * `threshold` (optional) --- maximum number of pages to generate in one build cycle.
60
+ * `threshold` (optional) maximum number of pages to generate in one build cycle.
61
61
 
62
62
  ## How to Contribute
63
63
 
@@ -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.4'
31
+ s.version = '0.0.6'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Translate Jekyll Pages Through ChatGPT'
34
34
  s.description = [
@@ -42,11 +42,11 @@ Gem::Specification.new do |s|
42
42
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
43
43
  s.rdoc_options = ['--charset=UTF-8']
44
44
  s.extra_rdoc_files = %w[README.md LICENSE.txt]
45
- s.add_runtime_dependency 'iri', '~> 0'
46
- s.add_runtime_dependency 'iso-639', '~> 0'
47
- s.add_runtime_dependency 'jekyll', '~> 3'
48
- s.add_runtime_dependency 'liquid', '~> 4'
49
- s.add_runtime_dependency 'redcarpet', '~> 3'
50
- s.add_runtime_dependency 'ruby-openai', '~> 5'
45
+ s.add_runtime_dependency 'iri', '>= 0'
46
+ s.add_runtime_dependency 'iso-639', '>= 0'
47
+ s.add_runtime_dependency 'jekyll', '>= 3'
48
+ s.add_runtime_dependency 'liquid', '>= 4'
49
+ s.add_runtime_dependency 'redcarpet', '>= 3'
50
+ s.add_runtime_dependency 'ruby-openai', '>= 5'
51
51
  s.metadata['rubygems_mfa_required'] = 'true'
52
52
  end
@@ -24,6 +24,7 @@
24
24
 
25
25
  require 'jekyll'
26
26
  require_relative 'chatgpt'
27
+ require_relative 'permalink'
27
28
  require_relative 'ping'
28
29
  require_relative 'plain'
29
30
  require_relative 'version'
@@ -60,7 +61,7 @@ but pages will be generated')
60
61
  site.posts.docs.each do |doc|
61
62
  plain = GptTranslate::Plain.new(doc.content).to_s
62
63
  config['targets'].each do |target|
63
- link = permalink(doc, target['permalink'])
64
+ link = GptTranslate::Permalink.new(doc, target['permalink']).to_s
64
65
  next if GptTranslate::Ping.new(site, link).exists?
65
66
  lang = target['language']
66
67
  raise 'Language must be defined for each target' if target.nil?
@@ -106,13 +107,4 @@ but pages will be generated')
106
107
  def config
107
108
  @config ||= @site.config['chatgpt-translate'] || {}
108
109
  end
109
-
110
- def permalink(doc, template)
111
- raise 'permalink must be defined for each target' if template.nil?
112
- template
113
- .gsub(':year', format('%04d', doc['date'].year))
114
- .gsub(':month', format('%02d', doc['date'].month))
115
- .gsub(':day', format('%02d', doc['date'].day))
116
- .gsub(':title', doc['title'])
117
- end
118
110
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # (The MIT License)
4
+ #
5
+ # Copyright (c) 2023 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.
24
+
25
+ require 'cgi'
26
+
27
+ # The module we are in.
28
+ module GptTranslate; end
29
+
30
+ # Permalink.
31
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
32
+ # Copyright:: Copyright (c) 2023 Yegor Bugayenko
33
+ # License:: MIT
34
+ class GptTranslate::Permalink
35
+ def initialize(doc, template)
36
+ @doc = doc
37
+ raise 'permalink must be defined for each target' if template.nil?
38
+ @template = template
39
+ end
40
+
41
+ def to_s
42
+ @template
43
+ .gsub(':year', format('%04d', @doc['date'].year))
44
+ .gsub(':month', format('%02d', @doc['date'].month))
45
+ .gsub(':day', format('%02d', @doc['date'].day))
46
+ .gsub(':title', CGI.escape(@doc['title']))
47
+ end
48
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # (The MIT License)
4
+ #
5
+ # Copyright (c) 2023 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.
24
+
25
+ require 'minitest/autorun'
26
+ require_relative '../lib/jekyll-chatgpt-translate/permalink'
27
+
28
+ # Permalink test.
29
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
+ # Copyright:: Copyright (c) 2023 Yegor Bugayenko
31
+ # License:: MIT
32
+ class GptTranslate::PermalinkTest < Minitest::Test
33
+ def test_simple_link
34
+ assert_equal(
35
+ '/2023.html',
36
+ GptTranslate::Permalink.new(
37
+ { 'date' => Time.parse('2023-01-01'), 'title' => 'Hello' },
38
+ '/:year.html'
39
+ ).to_s
40
+ )
41
+ end
42
+
43
+ def test_unicode_link
44
+ assert_equal(
45
+ '/2023-%23%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82.html',
46
+ GptTranslate::Permalink.new(
47
+ { 'date' => Time.parse('2023-01-01'), 'title' => '#привет' },
48
+ '/:year-:title.html'
49
+ ).to_s
50
+ )
51
+ end
52
+ 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.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -14,84 +14,84 @@ dependencies:
14
14
  name: iri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: iso-639
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jekyll
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: liquid
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redcarpet
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '3'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: ruby-openai
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '5'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '5'
97
97
  description: Add this plugin to your Jekyll site and all posts will be automatically
@@ -121,6 +121,7 @@ files:
121
121
  - lib/jekyll-chatgpt-translate.rb
122
122
  - lib/jekyll-chatgpt-translate/chatgpt.rb
123
123
  - lib/jekyll-chatgpt-translate/generator.rb
124
+ - lib/jekyll-chatgpt-translate/permalink.rb
124
125
  - lib/jekyll-chatgpt-translate/ping.rb
125
126
  - lib/jekyll-chatgpt-translate/plain.rb
126
127
  - lib/jekyll-chatgpt-translate/version.rb
@@ -128,6 +129,7 @@ files:
128
129
  - test/test__helper.rb
129
130
  - test/test_chatgpt.rb
130
131
  - test/test_generator.rb
132
+ - test/test_permalink.rb
131
133
  - test/test_ping.rb
132
134
  - test/test_plain.rb
133
135
  homepage: https://github.com/yegor256/jekyll-chatgpt-translate