wwwjdic 15.0.0 → 16.0.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/CHANGELOG +13 -0
- data/Gemfile +4 -0
- data/README.md +6 -7
- data/Rakefile +4 -0
- data/examples/basics.rb +4 -0
- data/examples/translate.rb +26 -0
- data/examples/uri.rb +16 -0
- data/html/CHANGELOG.html +37 -30
- data/html/COPYING_md.html +22 -30
- data/html/Gemfile.html +25 -31
- data/html/Object.html +825 -63
- data/html/README_md.html +27 -33
- data/html/Rakefile.html +25 -31
- data/html/WWWJDic.html +42 -124
- data/html/WWWJDic/ParsableDuckType.html +35 -57
- data/html/WWWJDic/Parser.html +48 -90
- data/html/WWWJDic/Parsers.html +28 -36
- data/html/WWWJDic/Parsers/Dict.html +47 -73
- data/html/WWWJDic/Parsers/Display.html +42 -68
- data/html/WWWJDic/Parsers/Key.html +42 -68
- data/html/WWWJDic/Parsers/Search.html +38 -61
- data/html/WWWJDic/Parsers/Server.html +42 -68
- data/html/WWWJDic/Splitter.html +76 -173
- data/html/WWWJDic/Utils.html +28 -36
- data/html/WWWJDic/Utils/Downloader.html +28 -36
- data/html/WWWJDic/Utils/Downloader/Downloader.html +41 -80
- data/html/WWWJDic/Utils/Raisers.html +42 -96
- data/html/WWWJDic/WWWJDic.html +160 -342
- data/html/copyright_md.html +22 -30
- data/html/created.rid +32 -54
- data/html/css/rdoc.css +1 -1
- data/html/index.html +26 -51
- data/html/js/darkfish.js +84 -84
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +110 -110
- data/html/js/search_index.js +1 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +229 -229
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +153 -161
- data/lib/wwwjdic.rb +7 -4
- data/lib/wwwjdic/application.rb +52 -25
- data/lib/wwwjdic/constants.rb +33 -3
- data/lib/wwwjdic/locales/de.yml +2 -0
- data/lib/wwwjdic/locales/en.yml +2 -0
- data/lib/wwwjdic/locales/es.yml +2 -0
- data/lib/wwwjdic/locales/fr.yml +2 -0
- data/lib/wwwjdic/locales/hu.yml +2 -0
- data/lib/wwwjdic/locales/it.yml +2 -0
- data/lib/wwwjdic/locales/ja.yml +3 -1
- data/lib/wwwjdic/locales/nl.yml +2 -0
- data/lib/wwwjdic/locales/ru.yml +2 -0
- data/lib/wwwjdic/locales/sl.yml +2 -0
- data/lib/wwwjdic/locales/sv.yml +2 -0
- data/lib/wwwjdic/parser.rb +7 -4
- data/lib/wwwjdic/parsers/dict.rb +4 -1
- data/lib/wwwjdic/parsers/display.rb +4 -1
- data/lib/wwwjdic/parsers/key.rb +4 -1
- data/lib/wwwjdic/parsers/search.rb +4 -0
- data/lib/wwwjdic/parsers/server.rb +4 -1
- data/lib/wwwjdic/utils/downloader.rb +7 -8
- data/lib/wwwjdic/utils/raisers.rb +7 -13
- data/lib/wwwjdic/utils/splitter.rb +18 -9
- data/lib/wwwjdic/version.rb +5 -1
- data/test/test_helper.rb +4 -0
- data/test/test_wwwjdic.rb +4 -0
- data/test/wwwjdic/locales/de.yml +2 -0
- data/test/wwwjdic/locales/en.yml +2 -0
- data/test/wwwjdic/locales/es.yml +2 -0
- data/test/wwwjdic/locales/fr.yml +2 -0
- data/test/wwwjdic/locales/hu.yml +2 -0
- data/test/wwwjdic/locales/it.yml +2 -0
- data/test/wwwjdic/locales/ja.yml +2 -0
- data/test/wwwjdic/locales/nl.yml +2 -0
- data/test/wwwjdic/locales/ru.yml +2 -0
- data/test/wwwjdic/locales/sl.yml +2 -0
- data/test/wwwjdic/locales/sv.yml +2 -0
- data/test/wwwjdic/locales/test_locales.rb +35 -19
- data/test/wwwjdic/parsers/test_dict.rb +62 -36
- data/test/wwwjdic/parsers/test_display.rb +4 -0
- data/test/wwwjdic/parsers/test_key.rb +4 -0
- data/test/wwwjdic/parsers/test_server.rb +4 -0
- data/test/wwwjdic/test_application.rb +196 -148
- data/test/wwwjdic/test_parsable_duck_type.rb +4 -3
- data/test/wwwjdic/utils/test_downloader.rb +4 -0
- data/test/wwwjdic/utils/test_raisers.rb +42 -27
- data/wwwjdic.gemspec +14 -11
- metadata +19 -33
data/lib/wwwjdic.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# wwwjdic
|
5
|
+
# rubocop:disable Style/AsciiComments
|
3
6
|
# © 2014 Marco Bresciani
|
7
|
+
# rubocop:enable Style/AsciiComments
|
4
8
|
#
|
5
9
|
# This file is part of wwwjdic.
|
6
10
|
#
|
@@ -34,7 +38,6 @@ require_relative 'wwwjdic/parsers/server'
|
|
34
38
|
# Copyright:: (C) 2014 Marco Bresciani
|
35
39
|
# License:: GNU General Public License version 3
|
36
40
|
module WWWJDic
|
37
|
-
|
38
41
|
# Creates a new WWWJDic object (from the verb 'to Breen'... :) ).
|
39
42
|
#
|
40
43
|
# Usage::
|
@@ -46,9 +49,9 @@ module WWWJDic
|
|
46
49
|
|
47
50
|
# Provides the parameters' parsers object.
|
48
51
|
def self.parser
|
49
|
-
parsers = {dict: Parsers::Dict.new, display: Parsers::Display.new,
|
50
|
-
|
51
|
-
|
52
|
+
parsers = { dict: Parsers::Dict.new, display: Parsers::Display.new,
|
53
|
+
key: Parsers::Key.new, search: Parsers::Search.new,
|
54
|
+
server: Parsers::Server.new }
|
52
55
|
|
53
56
|
Parser.new parsers
|
54
57
|
end
|
data/lib/wwwjdic/application.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# wwwjdic
|
5
|
+
# rubocop:disable Style/AsciiComments
|
3
6
|
# © 2014 Marco Bresciani
|
7
|
+
# rubocop:enable Style/AsciiComments
|
4
8
|
#
|
5
9
|
# This file is part of wwwjdic.
|
6
10
|
#
|
@@ -36,7 +40,6 @@ module WWWJDic
|
|
36
40
|
# Copyright:: (C) 2014 Marco Bresciani
|
37
41
|
# License:: GNU General Public License version 3
|
38
42
|
class WWWJDic
|
39
|
-
|
40
43
|
# Creates a +WWWJDic+ object. This constructor should be used
|
41
44
|
# through the WWWJDic::breener method only.
|
42
45
|
#
|
@@ -57,20 +60,15 @@ module WWWJDic
|
|
57
60
|
def uri(word = nil, args = {})
|
58
61
|
raise ArgumentError, I18n.t('error.nil') if word.nil?
|
59
62
|
raise ArgumentError, I18n.t('error.param', value: word) if word.empty?
|
60
|
-
raise ArgumentError, I18n.t('error.param', value: args) unless args.keys.to_set.proper_subset? Set.new(ALLOWED_PARAMS)
|
61
|
-
|
62
|
-
params = {}
|
63
|
-
params[:search] = word
|
64
|
-
@defaults[:search] = word
|
65
63
|
|
66
|
-
unless args.
|
67
|
-
|
68
|
-
|
69
|
-
end
|
64
|
+
unless args.keys.to_set.proper_subset? Set.new(ALLOWED_PARAMS)
|
65
|
+
raise ArgumentError,
|
66
|
+
I18n.t('error.param', value: args)
|
70
67
|
end
|
71
68
|
|
72
|
-
|
73
|
-
|
69
|
+
params = parse_params(args, word)
|
70
|
+
|
71
|
+
build_uri(params, word)
|
74
72
|
end
|
75
73
|
|
76
74
|
# Create the reference uri for a +word+ translation, according to
|
@@ -123,19 +121,7 @@ module WWWJDic
|
|
123
121
|
def json_translate(word = nil, args = {}, filename = nil)
|
124
122
|
translation = translate(word, args)
|
125
123
|
|
126
|
-
a_hash =
|
127
|
-
a_hash[word.to_sym] = raw_uri(word, args)
|
128
|
-
|
129
|
-
the_splitter = Splitter.new translation
|
130
|
-
|
131
|
-
a_hash[:title] = the_splitter.title
|
132
|
-
a_hash[:translation] = the_splitter.translation
|
133
|
-
a_hash[:message] = the_splitter.message
|
134
|
-
|
135
|
-
unless a_hash[:translation].nil?
|
136
|
-
a_hash[:lines] = the_splitter.lines
|
137
|
-
a_hash[:content] = the_splitter.content
|
138
|
-
end
|
124
|
+
a_hash = build_hash(args, translation, word)
|
139
125
|
|
140
126
|
result = a_hash.to_json
|
141
127
|
|
@@ -207,7 +193,9 @@ module WWWJDic
|
|
207
193
|
# romaji conversion if the key is not in Japanese coding (UTF-8,
|
208
194
|
# EUC or Shift_JIS.) If you want to look up using "sensei" it has
|
209
195
|
# to be a J. For anything else the value of J doesn't matter much.
|
196
|
+
# rubocop:disable Style/AsciiComments
|
210
197
|
# 1MUJ齧歯 and 1MUE齧歯 will both find 齧歯. 1MUJgesshi does too,
|
198
|
+
# rubocop:enable Style/AsciiComments
|
211
199
|
# but 1MUEgesshi won't.
|
212
200
|
#
|
213
201
|
# I think you have missed a key point I made in my previous email:
|
@@ -235,5 +223,44 @@ module WWWJDic
|
|
235
223
|
def to_s
|
236
224
|
@wwwjdic.to_s
|
237
225
|
end
|
226
|
+
|
227
|
+
private
|
228
|
+
|
229
|
+
def build_hash(args, translation, word)
|
230
|
+
the_splitter = Splitter.new translation
|
231
|
+
|
232
|
+
a_hash = { word.to_sym => raw_uri(word, args),
|
233
|
+
title: the_splitter.title,
|
234
|
+
translation: the_splitter.translation,
|
235
|
+
message: the_splitter.message }
|
236
|
+
|
237
|
+
unless a_hash[:translation].nil?
|
238
|
+
a_hash[:lines] = the_splitter.lines
|
239
|
+
a_hash[:content] = the_splitter.content
|
240
|
+
end
|
241
|
+
a_hash
|
242
|
+
end
|
243
|
+
|
244
|
+
def build_uri(params, word)
|
245
|
+
a_wwwjdic = URIS[params[:server]] +
|
246
|
+
params[:dict] +
|
247
|
+
DISPLAY[params[:display]] +
|
248
|
+
params[:search] +
|
249
|
+
KEYS[params[:key]]
|
250
|
+
a_wwwjdic + CGI.escape(word).to_s
|
251
|
+
end
|
252
|
+
|
253
|
+
def parse_params(args, word)
|
254
|
+
params = {}
|
255
|
+
params[:search] = word
|
256
|
+
@defaults[:search] = word
|
257
|
+
|
258
|
+
unless args.nil?
|
259
|
+
ALL_PARAMS.each do |param_name|
|
260
|
+
params[param_name] = @parser.parse(param_name.to_s, args.fetch(param_name, @defaults[param_name]))
|
261
|
+
end
|
262
|
+
end
|
263
|
+
params
|
264
|
+
end
|
238
265
|
end
|
239
266
|
end
|
data/lib/wwwjdic/constants.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# wwwjdic
|
5
|
+
# rubocop:disable Style/AsciiComments
|
3
6
|
# © 2014 Marco Bresciani
|
7
|
+
# rubocop:enable Style/AsciiComments
|
4
8
|
#
|
5
9
|
# This file is part of wwwjdic.
|
6
10
|
#
|
@@ -32,7 +36,33 @@ module WWWJDic
|
|
32
36
|
DICTIONARY_CODES = [('1'..'9').to_a, ('A'..'R').to_a].flatten
|
33
37
|
|
34
38
|
# Naming for all supported dictionaries
|
35
|
-
DICTIONARY_NAMES = ['Jpn-Eng General (EDICT)',
|
39
|
+
DICTIONARY_NAMES = ['Jpn-Eng General (EDICT)',
|
40
|
+
'Japanese Names (ENAMDICT)',
|
41
|
+
'Computing/Telecomms',
|
42
|
+
'Life Sciences/Bio-Med',
|
43
|
+
'Legal Terms',
|
44
|
+
'Finance/Marketing',
|
45
|
+
'Buddhism',
|
46
|
+
'Miscellaneous',
|
47
|
+
'Special Text-glossing',
|
48
|
+
'Engineering/Science',
|
49
|
+
'Linguistics',
|
50
|
+
'River & Water Systems',
|
51
|
+
'Automobile Industry',
|
52
|
+
'Japanese Wordnet',
|
53
|
+
'Work-in-progress File',
|
54
|
+
'Japanese-German (WaDoku)',
|
55
|
+
'Japanese-French',
|
56
|
+
'Japanese-Russian',
|
57
|
+
'Japanese-Swedish',
|
58
|
+
'Japanese-Hungarian',
|
59
|
+
'Japanese-Spanish',
|
60
|
+
'Japanese-Dutch',
|
61
|
+
'Japanese-Slovenian',
|
62
|
+
'Japanese-Italian',
|
63
|
+
'Untranslated',
|
64
|
+
'Combined Jpn-Eng',
|
65
|
+
'Expanded Text-glossing'].freeze
|
36
66
|
|
37
67
|
# Mapping between dictionaries names with codes
|
38
68
|
DICTS_BY_CODES = Hash[DICTIONARY_CODES.zip(DICTIONARY_NAMES)]
|
@@ -111,10 +141,10 @@ module WWWJDic
|
|
111
141
|
henshall: 'E', pinyin: 'Y' }.freeze
|
112
142
|
|
113
143
|
# Reference URI for Backdoor Entry/API
|
114
|
-
URI_DEFAULT = 'http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?'
|
144
|
+
URI_DEFAULT = 'http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?'
|
115
145
|
|
116
146
|
# Monash URI for Backdoor Entry/API
|
117
|
-
URI_OLD = 'http://nihongo.monash.edu/cgi-bin/wwwjdic?'
|
147
|
+
URI_OLD = 'http://nihongo.monash.edu/cgi-bin/wwwjdic?'
|
118
148
|
|
119
149
|
# URIs for Backdoor Entry/API
|
120
150
|
URIS = { edrdg: URI_DEFAULT, monash: URI_OLD }.freeze
|
data/lib/wwwjdic/locales/de.yml
CHANGED
data/lib/wwwjdic/locales/en.yml
CHANGED
data/lib/wwwjdic/locales/es.yml
CHANGED
data/lib/wwwjdic/locales/fr.yml
CHANGED
data/lib/wwwjdic/locales/hu.yml
CHANGED
data/lib/wwwjdic/locales/it.yml
CHANGED
data/lib/wwwjdic/locales/ja.yml
CHANGED
data/lib/wwwjdic/locales/nl.yml
CHANGED
data/lib/wwwjdic/locales/ru.yml
CHANGED
data/lib/wwwjdic/locales/sl.yml
CHANGED
data/lib/wwwjdic/locales/sv.yml
CHANGED
data/lib/wwwjdic/parser.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# wwwjdic
|
5
|
+
# rubocop:disable Style/AsciiComments
|
3
6
|
# © 2014 Marco Bresciani
|
7
|
+
# rubocop:enable Style/AsciiComments
|
4
8
|
#
|
5
9
|
# This file is part of wwwjdic.
|
6
10
|
#
|
@@ -25,7 +29,6 @@
|
|
25
29
|
require_relative 'constants'
|
26
30
|
|
27
31
|
module WWWJDic
|
28
|
-
|
29
32
|
# This class is a simple utility that is used to parse and filter
|
30
33
|
# parameters for wwwjdic.
|
31
34
|
#
|
@@ -41,10 +44,10 @@ module WWWJDic
|
|
41
44
|
end
|
42
45
|
|
43
46
|
# Provides the duck type for a generic parsing object.
|
44
|
-
def parse(method = nil,
|
47
|
+
def parse(method = nil, params = nil)
|
45
48
|
a_parser = nil
|
46
|
-
a_parser = parsers[method.to_sym] unless method.nil?
|
47
|
-
a_parser&.parse
|
49
|
+
a_parser = parsers[method.to_sym] unless method.nil? || parsers.nil?
|
50
|
+
a_parser&.parse params
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
data/lib/wwwjdic/parsers/dict.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# wwwjdic
|
5
|
+
# rubocop:disable Style/AsciiComments
|
3
6
|
# © 2014 Marco Bresciani
|
7
|
+
# rubocop:enable Style/AsciiComments
|
4
8
|
#
|
5
9
|
# This file is part of wwwjdic.
|
6
10
|
#
|
@@ -27,7 +31,6 @@ require_relative '../utils/raisers'
|
|
27
31
|
|
28
32
|
module WWWJDic
|
29
33
|
module Parsers
|
30
|
-
|
31
34
|
# This class is an implementation of the Parsable duck type that
|
32
35
|
# checks the dictionary type. The only needed parameter is a valid
|
33
36
|
# dictionary.
|
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# wwwjdic
|
5
|
+
# rubocop:disable Style/AsciiComments
|
3
6
|
# © 2014 Marco Bresciani
|
7
|
+
# rubocop:enable Style/AsciiComments
|
4
8
|
#
|
5
9
|
# This file is part of wwwjdic.
|
6
10
|
#
|
@@ -26,7 +30,6 @@ require_relative '../constants'
|
|
26
30
|
|
27
31
|
module WWWJDic
|
28
32
|
module Parsers
|
29
|
-
|
30
33
|
# This class is an implementation of the Parsable duck type that
|
31
34
|
# checks the display type. The only needed parameter is a boolean,
|
32
35
|
# with +true+ for regular.
|
data/lib/wwwjdic/parsers/key.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# wwwjdic
|
5
|
+
# rubocop:disable Style/AsciiComments
|
3
6
|
# © 2014 Marco Bresciani
|
7
|
+
# rubocop:enable Style/AsciiComments
|
4
8
|
#
|
5
9
|
# This file is part of wwwjdic.
|
6
10
|
#
|
@@ -26,7 +30,6 @@ require_relative '../constants'
|
|
26
30
|
|
27
31
|
module WWWJDic
|
28
32
|
module Parsers
|
29
|
-
|
30
33
|
# This class is an implementation of the Parsable duck type that
|
31
34
|
# checks the display type. The only needed parameter is the word to
|
32
35
|
# translate.
|
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# wwwjdic
|
5
|
+
# rubocop:disable Style/AsciiComments
|
3
6
|
# © 2014 Marco Bresciani
|
7
|
+
# rubocop:enable Style/AsciiComments
|
4
8
|
#
|
5
9
|
# This file is part of wwwjdic.
|
6
10
|
#
|
@@ -26,7 +30,6 @@ require_relative '../constants'
|
|
26
30
|
|
27
31
|
module WWWJDic
|
28
32
|
module Parsers
|
29
|
-
|
30
33
|
# This class is an implementation of the Parsable duck type that
|
31
34
|
# checks the display type. The only needed parameter is a boolean,
|
32
35
|
# with +true+ for regular.
|