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
@@ -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
|
#
|
@@ -24,7 +28,6 @@
|
|
24
28
|
|
25
29
|
module WWWJDic
|
26
30
|
module Utils
|
27
|
-
|
28
31
|
# This module is a simple wrapper container for Peter R. Marreck's
|
29
32
|
# gist.
|
30
33
|
#
|
@@ -32,7 +35,6 @@ module WWWJDic
|
|
32
35
|
# License:: 3-clause BSD
|
33
36
|
# Revision:: 2012-03-25 23:01:19 -0600
|
34
37
|
module Downloader
|
35
|
-
|
36
38
|
require 'net/http'
|
37
39
|
require 'net/ftp'
|
38
40
|
require 'openssl'
|
@@ -46,8 +48,7 @@ module WWWJDic
|
|
46
48
|
# License:: 3-clause BSD
|
47
49
|
# Revision:: 2012-03-25 23:01:19 -0600
|
48
50
|
class Downloader
|
49
|
-
|
50
|
-
VERSION = '0.1.0'.freeze
|
51
|
+
VERSION = '0.1.0'
|
51
52
|
|
52
53
|
class << self
|
53
54
|
attr_accessor :logger, :max_ca_verify_depth, :ftp_data_chunk_size
|
@@ -57,7 +58,6 @@ module WWWJDic
|
|
57
58
|
@max_ca_verify_depth = 5
|
58
59
|
@ftp_data_chunk_size = 8192
|
59
60
|
|
60
|
-
|
61
61
|
def self.download_file(url, full_path, count = 3)
|
62
62
|
raise I18n.t('error.nil') if url.nil?
|
63
63
|
|
@@ -120,11 +120,10 @@ module WWWJDic
|
|
120
120
|
puts response
|
121
121
|
end
|
122
122
|
end
|
123
|
-
|
124
123
|
rescue StandardError => e
|
125
|
-
File.unlink full_path if File.exist?(full_path)
|
124
|
+
File.unlink full_path if !full_path.nil? && File.exist?(full_path)
|
126
125
|
output "ERROR: #{e.message}"
|
127
|
-
raise
|
126
|
+
raise "Failed to download file: #{e.message}"
|
128
127
|
end
|
129
128
|
end
|
130
129
|
end
|
@@ -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
|
#
|
@@ -22,11 +26,9 @@
|
|
22
26
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
27
|
#++
|
24
28
|
|
25
|
-
|
26
29
|
require 'i18n'
|
27
30
|
|
28
31
|
module WWWJDic
|
29
|
-
|
30
32
|
# This module is a simple collection of useful things and methods that
|
31
33
|
# I prefer to keep as DRYer as possible. Just include it and use the
|
32
34
|
# methods...
|
@@ -35,7 +37,6 @@ module WWWJDic
|
|
35
37
|
# Copyright:: (C) 2014 Marco Bresciani
|
36
38
|
# License:: GNU General Public License version 3
|
37
39
|
module Utils
|
38
|
-
|
39
40
|
# This module contains some utility method to raise errors according
|
40
41
|
# to (possibly) common conditions.
|
41
42
|
#
|
@@ -43,29 +44,22 @@ module WWWJDic
|
|
43
44
|
# Copyright:: (C) 2014 Marco Bresciani
|
44
45
|
# License:: GNU General Public License version 3
|
45
46
|
module Raisers
|
46
|
-
|
47
47
|
# Raises an +ArgumentError+ according to parameters, unless the
|
48
48
|
# +array+ contains the exact +value+.
|
49
49
|
def raiser_array(name = 'error.value', value = nil, array = nil)
|
50
|
-
|
51
|
-
raise ArgumentError, I18n.t(name, value: value) unless array.include? value
|
52
|
-
end
|
50
|
+
raise ArgumentError, I18n.t(name, value: value) if !value.nil? && !(array.include? value)
|
53
51
|
end
|
54
52
|
|
55
53
|
# Raises an +ArgumentError+ according to parameters, unless the
|
56
54
|
# +array+ contains a downcased +value+.
|
57
55
|
def raiser_downcase(name = 'error.value', value = nil, array = nil)
|
58
|
-
|
59
|
-
raise ArgumentError, I18n.t(name, value: value) unless array.include? value.downcase
|
60
|
-
end
|
56
|
+
raise ArgumentError, I18n.t(name, value: value) if !value.nil? && !(array.include? value.downcase)
|
61
57
|
end
|
62
58
|
|
63
59
|
# Raises an +ArgumentError+ according to parameters, unless the
|
64
60
|
# +array+ contains the number of the +value+.
|
65
61
|
def raiser_to_i(name = 'error.value', value = nil, array = nil)
|
66
|
-
|
67
|
-
raise ArgumentError, I18n.t(name, value: value) unless array.include? value.to_i
|
68
|
-
end
|
62
|
+
raise ArgumentError, I18n.t(name, value: value) if !value.nil? && !(array.include? value.to_i)
|
69
63
|
end
|
70
64
|
end
|
71
65
|
end
|
@@ -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
|
#
|
@@ -70,15 +74,7 @@ module WWWJDic
|
|
70
74
|
result = []
|
71
75
|
lines.each do |a_line|
|
72
76
|
inner = {}
|
73
|
-
|
74
|
-
inner[:word] = Regexp.last_match(1).strip
|
75
|
-
inner[:kana] = Regexp.last_match(1).strip if /\[(.*)\]/m.match a_line
|
76
|
-
inner[:text] = Regexp.last_match(1).strip if %r{\] /(.*)/}m.match a_line
|
77
|
-
else
|
78
|
-
inner[:kana] = Regexp.last_match(1).strip if %r{^(.*)(\s)/}m.match a_line
|
79
|
-
inner[:word] = inner[:kana]
|
80
|
-
inner[:text] = Regexp.last_match(1).strip if %r{/(.*)/}m.match a_line
|
81
|
-
end
|
77
|
+
fill_inner_data(a_line, inner)
|
82
78
|
inner[:meanings] = inner[:text].split('/') if inner[:text].include? '/'
|
83
79
|
result.push inner unless inner.empty?
|
84
80
|
end
|
@@ -86,5 +82,18 @@ module WWWJDic
|
|
86
82
|
result unless result.empty?
|
87
83
|
end
|
88
84
|
|
85
|
+
private
|
86
|
+
|
87
|
+
def fill_inner_data(a_line, inner)
|
88
|
+
if /(.*)\[/m.match a_line
|
89
|
+
inner[:word] = Regexp.last_match(1).strip
|
90
|
+
inner[:kana] = Regexp.last_match(1).strip if /\[(.*)\]/m.match a_line
|
91
|
+
inner[:text] = Regexp.last_match(1).strip if %r{\] /(.*)/}m.match a_line
|
92
|
+
else
|
93
|
+
inner[:kana] = Regexp.last_match(1).strip if %r{^(.*)(\s)/}m.match a_line
|
94
|
+
inner[:word] = inner[:kana]
|
95
|
+
inner[:text] = Regexp.last_match(1).strip if %r{/(.*)/}m.match a_line
|
96
|
+
end
|
97
|
+
end
|
89
98
|
end
|
90
99
|
end
|
data/lib/wwwjdic/version.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
|
#
|
@@ -20,5 +24,5 @@
|
|
20
24
|
|
21
25
|
module WWWJDic
|
22
26
|
# Current version number for WWWJDic gem.
|
23
|
-
VERSION = '
|
27
|
+
VERSION = '16.0.0'
|
24
28
|
end
|
data/test/test_helper.rb
CHANGED
data/test/test_wwwjdic.rb
CHANGED
data/test/wwwjdic/locales/de.yml
CHANGED
data/test/wwwjdic/locales/en.yml
CHANGED
data/test/wwwjdic/locales/es.yml
CHANGED
data/test/wwwjdic/locales/fr.yml
CHANGED
data/test/wwwjdic/locales/hu.yml
CHANGED
data/test/wwwjdic/locales/it.yml
CHANGED
data/test/wwwjdic/locales/ja.yml
CHANGED
data/test/wwwjdic/locales/nl.yml
CHANGED
data/test/wwwjdic/locales/ru.yml
CHANGED
data/test/wwwjdic/locales/sl.yml
CHANGED
data/test/wwwjdic/locales/sv.yml
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
|
#
|
@@ -24,7 +28,29 @@
|
|
24
28
|
|
25
29
|
require_relative '../../test_helper'
|
26
30
|
|
27
|
-
RELATIVE_PATH = './'
|
31
|
+
RELATIVE_PATH = './'
|
32
|
+
|
33
|
+
def test_one_locale
|
34
|
+
it 'shall return at least one available locale' do
|
35
|
+
_(subject).wont_be_nil
|
36
|
+
_(subject).wont_be_empty
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_en_it
|
41
|
+
it 'shall contain at least English and Italiano' do
|
42
|
+
_(subject).must_include :en
|
43
|
+
_(subject).must_include :it
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_translation(locale, translation)
|
48
|
+
a_string = I18n.t('test.test')
|
49
|
+
_(a_string).wont_be_nil
|
50
|
+
_(a_string).wont_be_empty
|
51
|
+
_(a_string).wont_include 'translation missing'
|
52
|
+
_(a_string).must_equal translation[locale.to_s]['test']['test']
|
53
|
+
end
|
28
54
|
|
29
55
|
describe WWWJDic::WWWJDic do
|
30
56
|
describe 'when using I18N' do
|
@@ -34,34 +60,24 @@ describe WWWJDic::WWWJDic do
|
|
34
60
|
|
35
61
|
subject { I18n.available_locales }
|
36
62
|
|
37
|
-
|
38
|
-
_(subject).wont_be_nil
|
39
|
-
_(subject).wont_be_empty
|
40
|
-
end
|
63
|
+
test_one_locale
|
41
64
|
|
42
|
-
|
43
|
-
|
44
|
-
|
65
|
+
test_en_it
|
66
|
+
|
67
|
+
def load_yaml_file(locale)
|
68
|
+
filename = File.join(File.dirname(__FILE__), RELATIVE_PATH, "#{locale}.yml")
|
69
|
+
filename = File.expand_path filename
|
70
|
+
YAML.safe_load(File.open(filename.to_s))
|
45
71
|
end
|
46
72
|
|
47
73
|
it 'shall contain a test.test signpost for each available locale' do
|
48
|
-
def load_yaml_file(locale)
|
49
|
-
filename = File.join(File.dirname(__FILE__), RELATIVE_PATH, "#{locale}.yml")
|
50
|
-
filename = File.expand_path filename
|
51
|
-
YAML.safe_load(File.open(filename.to_s))
|
52
|
-
end
|
53
|
-
|
54
74
|
subject.each do |locale|
|
55
75
|
I18n.locale = locale
|
56
76
|
|
57
77
|
translation = load_yaml_file(locale)
|
58
78
|
_(translation[locale.to_s]['test']['test']).wont_be_nil
|
59
79
|
|
60
|
-
|
61
|
-
_(a_string).wont_be_nil
|
62
|
-
_(a_string).wont_be_empty
|
63
|
-
_(a_string).wont_include 'translation missing'
|
64
|
-
_(a_string).must_equal translation[locale.to_s]['test']['test']
|
80
|
+
test_translation(locale, translation)
|
65
81
|
end
|
66
82
|
end
|
67
83
|
end
|
@@ -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
|
#
|
@@ -24,54 +28,76 @@
|
|
24
28
|
|
25
29
|
require_relative '../../test_helper'
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
def test_raise_error_param(param)
|
32
|
+
it "shall raise and error for parameter '#{param}'" do
|
33
|
+
assert_raises ArgumentError do
|
34
|
+
subject.parse param
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
30
38
|
|
31
|
-
|
32
|
-
|
33
|
-
|
39
|
+
def test_wrong_name
|
40
|
+
it 'shall raise an error when wrong dictionary name' do
|
41
|
+
assert_raises ArgumentError do
|
42
|
+
subject.parse 'test'
|
34
43
|
end
|
44
|
+
end
|
45
|
+
end
|
35
46
|
|
36
|
-
|
47
|
+
def test_wrong_code
|
48
|
+
it 'shall raise an error when wrong dictionary code' do
|
49
|
+
assert_raises ArgumentError do
|
50
|
+
subject.parse 'Z'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
37
54
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
assert_raises ArgumentError do
|
42
|
-
subject.parse param
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
55
|
+
def test_invalid_param
|
56
|
+
describe 'when provided and invalid parameter' do
|
57
|
+
[nil, '', 42].each(&method(:test_raise_error_param))
|
46
58
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
59
|
+
test_wrong_name
|
60
|
+
|
61
|
+
test_wrong_code
|
62
|
+
end
|
63
|
+
end
|
52
64
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
65
|
+
def test_dictionary_code
|
66
|
+
describe 'when using the dictionary code/number' do
|
67
|
+
WWWJDic::DICTIONARY_CODES.each do |value|
|
68
|
+
it "shall return '#{value}' when parameter is '#{value}'" do
|
69
|
+
_(subject.parse(value)).must_equal value
|
57
70
|
end
|
58
71
|
end
|
72
|
+
end
|
73
|
+
end
|
59
74
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
75
|
+
def test_dictionary_name
|
76
|
+
describe 'when using the dictionary name' do
|
77
|
+
WWWJDic::DICTIONARY_NAMES.each do |value|
|
78
|
+
translated = WWWJDic::DICTS_BY_NAMES[value]
|
79
|
+
it "shall return '#{translated}' when parameter is '#{value}'" do
|
80
|
+
_(subject.parse(value)).must_equal translated
|
65
81
|
end
|
66
82
|
end
|
83
|
+
end
|
84
|
+
end
|
67
85
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
86
|
+
describe WWWJDic::WWWJDic do
|
87
|
+
describe 'when using a parser' do
|
88
|
+
include WWWJDic::ParsableDuckType
|
89
|
+
|
90
|
+
before do
|
91
|
+
@parser = subject
|
92
|
+
I18n.load_path = Dir[File.join(File.dirname(__FILE__), '../locales/', '*.yml')]
|
75
93
|
end
|
94
|
+
|
95
|
+
subject { WWWJDic::Parsers::Dict.new }
|
96
|
+
|
97
|
+
test_invalid_param
|
98
|
+
|
99
|
+
test_dictionary_code
|
100
|
+
|
101
|
+
test_dictionary_name
|
76
102
|
end
|
77
103
|
end
|