papago 1.0.7 → 1.0.9
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/bin/papago +0 -24
- data/lib/papago/version.rb +1 -1
- metadata +12 -71
- data/lib/papago/configuration.rb +0 -22
- data/lib/papago/translator.rb +0 -35
- data/lib/papago.rb +0 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 89655ddfbce6f30231bc51303aa14f9f4fdacb5e150ebd1be3ca21a251519251
|
|
4
|
+
data.tar.gz: 68c281a7638c1b8bfae301e80297f28a2595b5822072002dfbf024fc0bfbd9e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7b25abab7dbfe25f0f048e43a7f84cb31133e3b66e5016034bd0ca7d390aa9754ace422a11f4de21e3cc73850dcb9da38b5cbc955f00ef39dd92d1918272543
|
|
7
|
+
data.tar.gz: 6992b0a1c641e99898a1b87d51df287e0927516b9d3077e60de4222d9a4af8dee9175c548613060049cb08d97b492fb6c70f5c2711015c743b48df9ff36a23ee
|
data/bin/papago
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
require 'papago'
|
|
4
|
-
require 'treely'
|
|
5
|
-
require 'lolcat/lol'
|
|
6
|
-
require 'active_support/core_ext/object/blank'
|
|
7
|
-
require 'active_support/core_ext/string/filters'
|
|
8
|
-
require 'mercenary'
|
|
9
|
-
|
|
10
|
-
Papago.configure do |config|
|
|
11
|
-
config.api_key = ENV['PAPAGO_API_KEY']
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
Mercenary.program(:papago) do |program|
|
|
15
|
-
program.version Papago::VERSION
|
|
16
|
-
program.syntax 'papago netease'
|
|
17
|
-
|
|
18
|
-
program.action do |args, options|
|
|
19
|
-
if args.present?
|
|
20
|
-
contents = Papago.translate(args.join(%{ })).contents
|
|
21
|
-
contents.then { |_| Treely.tree(_) }
|
|
22
|
-
.then { |_| StringIO.new(_.to_s.remove(' []')) }
|
|
23
|
-
.then { |_| Lol.cat(_, { freq: 0.25, spread: 8.0, os: rand(256) }) }
|
|
24
|
-
puts %{}
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
data/lib/papago/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,100 +1,41 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: papago
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- oneureka
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-10-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: tty-prompt
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '5.11'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: activesupport
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '5.2'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '5.2'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: mercenary
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.3.6
|
|
48
|
-
type: :runtime
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.3.6
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: lolcat
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '99.9'
|
|
62
|
-
type: :runtime
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '99.9'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: treely
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '1.0'
|
|
19
|
+
version: '0.23'
|
|
76
20
|
type: :runtime
|
|
77
21
|
prerelease: false
|
|
78
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
23
|
requirements:
|
|
80
24
|
- - "~>"
|
|
81
25
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
26
|
+
version: '0.23'
|
|
83
27
|
description:
|
|
84
|
-
email:
|
|
28
|
+
email: oneureka@github.io
|
|
85
29
|
executables:
|
|
86
30
|
- papago
|
|
87
31
|
extensions: []
|
|
88
32
|
extra_rdoc_files: []
|
|
89
33
|
files:
|
|
90
34
|
- bin/papago
|
|
91
|
-
- lib/papago.rb
|
|
92
|
-
- lib/papago/configuration.rb
|
|
93
|
-
- lib/papago/translator.rb
|
|
94
35
|
- lib/papago/version.rb
|
|
95
|
-
homepage: https://
|
|
36
|
+
homepage: https://dub.sh/papago
|
|
96
37
|
licenses:
|
|
97
|
-
-
|
|
38
|
+
- BSD-1-Clause
|
|
98
39
|
metadata: {}
|
|
99
40
|
post_install_message:
|
|
100
41
|
rdoc_options: []
|
|
@@ -104,15 +45,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
104
45
|
requirements:
|
|
105
46
|
- - ">="
|
|
106
47
|
- !ruby/object:Gem::Version
|
|
107
|
-
version: '0'
|
|
48
|
+
version: '3.0'
|
|
108
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
50
|
requirements:
|
|
110
51
|
- - ">="
|
|
111
52
|
- !ruby/object:Gem::Version
|
|
112
53
|
version: '0'
|
|
113
54
|
requirements: []
|
|
114
|
-
rubygems_version: 3.
|
|
55
|
+
rubygems_version: 3.5.22
|
|
115
56
|
signing_key:
|
|
116
57
|
specification_version: 4
|
|
117
|
-
summary: A
|
|
58
|
+
summary: A translation toolkit
|
|
118
59
|
test_files: []
|
data/lib/papago/configuration.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Papago
|
|
2
|
-
class Configuration
|
|
3
|
-
attr_accessor :key
|
|
4
|
-
attr_accessor :keyfrom
|
|
5
|
-
|
|
6
|
-
def api_key=(api_key)
|
|
7
|
-
@keyfrom, @key = api_key&.gsub(/[\w]+/).to_a
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.configuration
|
|
12
|
-
@configuration ||= Configuration.new
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.configuration=(config)
|
|
16
|
-
@configuration = config
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.configure
|
|
20
|
-
yield configuration
|
|
21
|
-
end
|
|
22
|
-
end
|
data/lib/papago/translator.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
module Papago
|
|
2
|
-
class Translator
|
|
3
|
-
def initialize(text)
|
|
4
|
-
@request = URI('https://fanyi.youdao.com/openapi.do')
|
|
5
|
-
@request.query = URI.encode_www_form({
|
|
6
|
-
:keyfrom => Papago[:keyfrom],
|
|
7
|
-
:key => Papago[:key],
|
|
8
|
-
:type => 'data',
|
|
9
|
-
:doctype => 'json',
|
|
10
|
-
:version => '1.1',
|
|
11
|
-
:q => text
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
build_context!
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def contents
|
|
18
|
-
[
|
|
19
|
-
{
|
|
20
|
-
name: "#{@context.fetch(:query)} [#{@context.dig(:basic, :phonetic)}]",
|
|
21
|
-
contents: [
|
|
22
|
-
{
|
|
23
|
-
name: @context.fetch(:translation).join(%{ }),
|
|
24
|
-
contents: (@context.dig(:basic, :explains) || []).map { |explain| { name: explain } }
|
|
25
|
-
}
|
|
26
|
-
] + @context.fetch(:web, []).map { |explain| { name: "#{explain.fetch(:key)}: #{explain.fetch(:value).join(%{ })}" } }
|
|
27
|
-
}
|
|
28
|
-
]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def build_context!
|
|
32
|
-
@context = JSON.parse(@request.read, symbolize_names: true)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
data/lib/papago.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'json'
|
|
2
|
-
require 'open-uri'
|
|
3
|
-
|
|
4
|
-
require 'papago/version'
|
|
5
|
-
require 'papago/translator'
|
|
6
|
-
require 'papago/configuration'
|
|
7
|
-
|
|
8
|
-
module Papago
|
|
9
|
-
module_function
|
|
10
|
-
|
|
11
|
-
def translate(text)
|
|
12
|
-
Translator.new(text)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def [](name)
|
|
16
|
-
configuration.send(name)
|
|
17
|
-
end
|
|
18
|
-
end
|