dezo 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6d8b88885a97ab629501cbc440247d90ea930e5f8ef5dc888bbb60ff2fac2f9a
4
+ data.tar.gz: f8e5f058796d23638fbe71711cd1a2b1735a592bb90dd88fb7d28025f021db03
5
+ SHA512:
6
+ metadata.gz: 02a72a347e739a929c92f24978ee687ce939bf9aee26adacf91acdf0cd6adb99568f910b3d1e56c8fb11c3f98a4d6af4ba024d7b0a48bc5ff00bed8c7d1f2cab
7
+ data.tar.gz: 308e93de2ce815c16b6d00032f34b657c0fb68cfee8614e87b12f0052d8eba7453eb77315c156be41b908761665dc4a557ba2775743020f972757aafcedf14aa
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in dezo.gemspec
6
+ gemspec
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dezo (0.1.0)
5
+ activesupport
6
+ thor
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (6.0.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2)
17
+ concurrent-ruby (1.1.5)
18
+ i18n (1.7.0)
19
+ concurrent-ruby (~> 1.0)
20
+ minitest (5.13.0)
21
+ rake (10.5.0)
22
+ thor (0.20.3)
23
+ thread_safe (0.3.6)
24
+ tzinfo (1.2.5)
25
+ thread_safe (~> 0.1)
26
+ zeitwerk (2.2.1)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ bundler (~> 1.17)
33
+ dezo!
34
+ rake (~> 10.0)
35
+
36
+ BUNDLED WITH
37
+ 1.17.3
@@ -0,0 +1,25 @@
1
+ # Dezo
2
+ Dezo is a cli tool that transrate Japanese between English.
3
+
4
+
5
+ ## Installation
6
+
7
+ $ gem install dezo
8
+
9
+ ## Usage
10
+
11
+ `$ dezo`
12
+
13
+
14
+ and then type a word which you wanna transrate,
15
+
16
+
17
+ ## Thanks to
18
+ Dezo depends on デ辞蔵Webサービス
19
+
20
+ - デ辞蔵Webサービス
21
+ https://www.est.co.jp/dev/dict/REST
22
+
23
+ ## Contributing
24
+
25
+ Bug reports and pull requests are welcome on GitHub at https://github.com/YumaFuu/dezo.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dezo"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "dezo/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dezo"
8
+ spec.version = Dezo::VERSION
9
+ spec.authors = ["Yuma Ishikawa"]
10
+ spec.email = ["yuma.fuu05@gmail.com"]
11
+
12
+ spec.summary = "dezo can transrate tool on cli."
13
+ spec.description = "dezo can transrate japanese and english."
14
+ spec.homepage = "https://github.com/YumaFuu/dezo"
15
+
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.17"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_dependency "thor"
29
+ spec.add_dependency "activesupport"
30
+ end
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "dezo"
4
+
5
+ loop do
6
+ print "word> "
7
+ word = gets.chomp
8
+ #word = Word.new
9
+
10
+ break if word === "Q"
11
+ next if word == ""
12
+ Dezo.search(word)
13
+ end
@@ -0,0 +1,59 @@
1
+ require "dezo/version"
2
+
3
+ module Dezo
4
+ class Error < StandardError; end
5
+ require 'net/http'
6
+ require 'uri'
7
+ require 'active_support/core_ext'
8
+
9
+ GET_ID_ENDPOINT = "http://public.dejizo.jp/NetDicV09.asmx/SearchDicItemLite"
10
+ GET_ITEM_ENDPOINT = "http://public.dejizo.jp/NetDicV09.asmx/GetDicItemLite"
11
+
12
+ class << self
13
+ def search(word)
14
+ is_japanese = word =~ /(?:\p{Hiragana}|\p{Katakana}|[一-龠々])/
15
+ dic_type = is_japanese ? "EdictJE" : "EJdict"
16
+ search_service(dic_type, word)
17
+ end
18
+
19
+ def search_service(dic_type, word)
20
+ id_url = GET_ID_ENDPOINT + id_params(dic_type, word)
21
+ id_uri = URI.parse(URI.encode(id_url))
22
+ id_response = Net::HTTP.get_response(id_uri)
23
+ item_id = id_response.body.match(/<ItemID>(.+)<\/ItemID>/)[1] rescue return
24
+
25
+ item_url = GET_ITEM_ENDPOINT + item_params(dic_type, item_id)
26
+ item_uri = URI.parse(URI.encode(item_url))
27
+ item_response = Net::HTTP.get_response(item_uri)
28
+
29
+ words = CGI.unescape(item_response.body).match(/<div>(.+)<\/div>/)[1] rescue return
30
+
31
+ list = words.tr("0-9A-Za-z", "0-9A-Za-z").split("\t")
32
+ puts list.map{|item| "- #{item}"}
33
+ puts ""
34
+ return list
35
+ end
36
+
37
+ private
38
+
39
+ def id_params(dic_type, word)
40
+ { Dic: "#{dic_type}",
41
+ Word: word,
42
+ Scope: "HEADWORD",
43
+ Match: "EXACT",
44
+ Merge: "OR",
45
+ Prof: "XHTML",
46
+ PageSize: "20",
47
+ PageIndex: "0",
48
+ }.each_with_object("?"){|(k, v), url| url << "#{k}=#{v}&"}.chop
49
+ end
50
+
51
+ def item_params(dic_type, id)
52
+ { Dic: "#{dic_type}",
53
+ Item: id,
54
+ Loc: "",
55
+ Prof: "XHTML",
56
+ }.each_with_object("?"){|(k, v), url| url << "#{k}=#{v}&"}.chop
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,3 @@
1
+ module Dezo
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dezo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuma Ishikawa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: dezo can transrate japanese and english.
70
+ email:
71
+ - yuma.fuu05@gmail.com
72
+ executables:
73
+ - dezo
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - dezo.gemspec
85
+ - exe/dezo
86
+ - lib/dezo.rb
87
+ - lib/dezo/version.rb
88
+ homepage: https://github.com/YumaFuu/dezo
89
+ licenses: []
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.0.4
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: dezo can transrate tool on cli.
110
+ test_files: []