TTTrans 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +13 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +8 -0
- data/exe/ttt +18 -0
- data/lib/tttrans/version.rb +5 -0
- data/lib/tttrans.rb +24 -0
- data/sig/tttrans.rbs +4 -0
- data/tttrans.gemspec +42 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cb740e31cd3cfe831039fc5feebf5eb11e0030563a99b539126506b3d5534532
|
4
|
+
data.tar.gz: f89ff2acfdf21034d5ae8f5bd8bc1bec1399813b0f72c74cc0b3634183726668
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 489e8bcedf7eeeca73ac5fab3c248e815c86e712e4e71bfcd3b17fb4c7f2b86bf7af4f29a6c5daf1caf7e9bd8dee4e9d1cb387b038b77722ea98072392a1c83c
|
7
|
+
data.tar.gz: 870febae3298d27a50bdb4654ebfce90d30a42273ec6d53ae84a6d96783959c83f27f9bdcaa85b936363fe8d35a316da4b08071ed04f3e2de36b2c21aa0343ed
|
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
TTTrans (0.1.0)
|
5
|
+
oauth (~> 0.5.10)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
oauth (0.5.10)
|
12
|
+
parallel (1.22.1)
|
13
|
+
parser (3.1.2.0)
|
14
|
+
ast (~> 2.4.1)
|
15
|
+
rainbow (3.1.1)
|
16
|
+
rake (13.0.6)
|
17
|
+
regexp_parser (2.5.0)
|
18
|
+
rexml (3.2.5)
|
19
|
+
rubocop (1.30.1)
|
20
|
+
parallel (~> 1.10)
|
21
|
+
parser (>= 3.1.0.0)
|
22
|
+
rainbow (>= 2.2.2, < 4.0)
|
23
|
+
regexp_parser (>= 1.8, < 3.0)
|
24
|
+
rexml (>= 3.2.5, < 4.0)
|
25
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
26
|
+
ruby-progressbar (~> 1.7)
|
27
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
28
|
+
rubocop-ast (1.18.0)
|
29
|
+
parser (>= 3.1.1.0)
|
30
|
+
rubocop-rake (0.6.0)
|
31
|
+
rubocop (~> 1.0)
|
32
|
+
ruby-progressbar (1.11.0)
|
33
|
+
unicode-display_width (2.1.0)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
x86_64-linux
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
TTTrans!
|
40
|
+
rake (~> 13.0.6)
|
41
|
+
rubocop (~> 1.30.1)
|
42
|
+
rubocop-rake (~> 0.6.0)
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
2.3.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 MURATA Mitsuharu
|
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
|
13
|
+
all 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 NONINFRINGEMENT. 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# TTTrans
|
2
|
+
この Gem は「みんなの自動翻訳@TexTra®」に対し WebAPI を叩き、翻訳するアプリです。
|
3
|
+
|
4
|
+
![image](https://user-images.githubusercontent.com/39254183/175293482-2e432b0b-f52e-457c-bad1-e6e68d627fe1.png)
|
5
|
+
|
6
|
+
|機能|開発状況|
|
7
|
+
|:--:|:--:|
|
8
|
+
|英日翻訳|✅|
|
9
|
+
|日英翻訳||
|
10
|
+
|設定ファイルの読み込み||
|
11
|
+
|非対話モードによる翻訳||
|
12
|
+
|
13
|
+
## インストール
|
14
|
+
アプリケーションのGemfileに次の行を追加します:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'tttrans'
|
18
|
+
```
|
19
|
+
|
20
|
+
次のコマンドを実行します:
|
21
|
+
|
22
|
+
$ bundle install
|
23
|
+
|
24
|
+
または、次のようにインストールします:
|
25
|
+
|
26
|
+
$ gem install tttrans
|
27
|
+
|
28
|
+
### 環境変数設定
|
29
|
+
環境変数を設定する必要があるため、`~/.bashrc` などに環境変数を以下のように設定してください。
|
30
|
+
|
31
|
+
```bash
|
32
|
+
export TexTra_URI_EN_JA=https://mt-auto-minhon-mlt.ucri.jgn-x.jp/api/mt/generalNT_en_ja/
|
33
|
+
export TexTra_ID=【TexTra に登録した ID】
|
34
|
+
export TexTra_API_KEY=【API key】
|
35
|
+
export TexTra_API_SECRET=【API secret】
|
36
|
+
```
|
37
|
+
|
38
|
+
詳しくは、https://www.hikari-dev.com/2022/06/22/TexTra-ruby/ を参照してください。
|
39
|
+
|
40
|
+
## 使用方法
|
41
|
+
|
42
|
+
`gem install` によってインストールを行った場合は、以下のコマンドで対話型翻訳を実行できます。
|
43
|
+
|
44
|
+
```bash
|
45
|
+
$ ttt
|
46
|
+
```
|
47
|
+
|
48
|
+
プロジェクトがカレントディレクトリになっている場合は、以下のコマンドで対話型翻訳を実行できます。
|
49
|
+
|
50
|
+
```bash
|
51
|
+
$ bundle # 1 回だけ
|
52
|
+
$ bundle exec ttt
|
53
|
+
```
|
54
|
+
|
55
|
+
`:q` で対話を終了します。
|
56
|
+
|
57
|
+
## 開発について
|
58
|
+
|
59
|
+
リポジトリをチェックアウトした後、`bin/setup` を実行して依存関係をインストールします。
|
60
|
+
また、`bin/console` を実行してインタラクティブなプロンプトを表示し、実験を行うこともできます。
|
61
|
+
|
62
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
63
|
+
|
64
|
+
このgemをローカルマシンにインストールするには、`bundle exec rake install` を実行します。新しいバージョンをリリースするには、`version.rb` のバージョン番号を更新してから `bundle exec rake release` を実行します。
|
65
|
+
これによりそのバージョンの git タグが作成され、git コミットと作成されたタグがプッシュされ、
|
66
|
+
`.gem` ファイルが [rubygems.org](https://rubygems.org) に プッシュされます。
|
67
|
+
|
68
|
+
## ソフトウェアライセンス
|
69
|
+
|
70
|
+
この Gem は、[MITライセンス](https://opensource.org/licenses/MIT) の条件の下でオープンソースとして利用できます。
|
data/Rakefile
ADDED
data/exe/ttt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "oauth"
|
5
|
+
require "tttrans"
|
6
|
+
|
7
|
+
consumer = OAuth::Consumer.new(ENV["TexTra_API_KEY"], ENV["TexTra_API_SECRET"])
|
8
|
+
token = OAuth::AccessToken.new(consumer)
|
9
|
+
|
10
|
+
loop do
|
11
|
+
input = Readline.readline(" English: ", true)
|
12
|
+
next if input.eql?("")
|
13
|
+
|
14
|
+
break if input.eql?(":q")
|
15
|
+
|
16
|
+
puts("\033[32mJapanese: \033[1;32m#{TTTrans.translate(token, input)}\033[0m")
|
17
|
+
puts("-" * IO.console_size[1])
|
18
|
+
end
|
data/lib/tttrans.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "readline"
|
4
|
+
require "io/console/size"
|
5
|
+
require "json"
|
6
|
+
require_relative "tttrans/version"
|
7
|
+
|
8
|
+
# TTTrans module
|
9
|
+
module TTTrans
|
10
|
+
class Error < StandardError; end
|
11
|
+
# Your code goes here...
|
12
|
+
|
13
|
+
def self.translate(token, text)
|
14
|
+
response = token.post(
|
15
|
+
ENV["TexTra_URI_EN_JA"], {
|
16
|
+
key: ENV["TexTra_API_KEY"],
|
17
|
+
type: "json",
|
18
|
+
name: ENV["TexTra_ID"],
|
19
|
+
text: text
|
20
|
+
}
|
21
|
+
)
|
22
|
+
JSON.parse(response.body)["resultset"]["result"]["text"]
|
23
|
+
end
|
24
|
+
end
|
data/sig/tttrans.rbs
ADDED
data/tttrans.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/tttrans/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "TTTrans"
|
7
|
+
spec.version = TTTrans::VERSION
|
8
|
+
spec.authors = ["MURATA Mitsuharu"]
|
9
|
+
spec.email = ["hikari.photon+dev@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Interactive Translation App"
|
12
|
+
# spec.description =
|
13
|
+
spec.homepage = "https://github.com/himeyama/tttrans/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] =
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
spec.add_dependency "oauth", "~> 0.5.10"
|
36
|
+
spec.add_development_dependency "rubocop-rake", "~> 0.6.0"
|
37
|
+
spec.add_development_dependency "rake", "~> 13.0.6"
|
38
|
+
spec.add_development_dependency "rubocop", "~> 1.30.1"
|
39
|
+
|
40
|
+
# For more information and examples about making a new gem, check out our
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: TTTrans
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MURATA Mitsuharu
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: oauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.10
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.10
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop-rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.6.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.6.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 13.0.6
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 13.0.6
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.30.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.30.1
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- hikari.photon+dev@gmail.com
|
72
|
+
executables:
|
73
|
+
- ttt
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".rubocop.yml"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- exe/ttt
|
84
|
+
- lib/tttrans.rb
|
85
|
+
- lib/tttrans/version.rb
|
86
|
+
- sig/tttrans.rbs
|
87
|
+
- tttrans.gemspec
|
88
|
+
homepage: https://github.com/himeyama/tttrans/
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata:
|
92
|
+
homepage_uri: https://github.com/himeyama/tttrans/
|
93
|
+
source_code_uri: https://github.com/himeyama/tttrans/
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.6.0
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubygems_version: 3.3.7
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Interactive Translation App
|
113
|
+
test_files: []
|