wwwjdic 14.0.0 → 15.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +19 -0
- data/Gemfile +5 -1
- data/README.md +461 -192
- data/Rakefile +7 -2
- data/copyright.md +17 -29
- data/examples/basics.rb +51 -45
- data/examples/translate.rb +135 -86
- data/examples/uri.rb +34 -78
- data/html/CHANGELOG.html +48 -31
- data/html/COPYING_md.html +31 -35
- data/html/Gemfile.html +28 -32
- data/html/Object.html +71 -71
- data/html/README_md.html +326 -159
- data/html/Rakefile.html +29 -33
- data/html/WWWJDic.html +137 -98
- data/html/WWWJDic/ParsableDuckType.html +55 -55
- data/html/WWWJDic/Parser.html +88 -88
- data/html/WWWJDic/Parsers.html +33 -33
- data/html/WWWJDic/Parsers/Dict.html +71 -73
- data/html/WWWJDic/Parsers/Display.html +66 -66
- data/html/WWWJDic/Parsers/Key.html +67 -67
- data/html/WWWJDic/Parsers/Search.html +59 -58
- data/html/WWWJDic/Parsers/Server.html +66 -66
- data/html/WWWJDic/Splitter.html +173 -172
- data/html/WWWJDic/Utils.html +34 -34
- data/html/WWWJDic/Utils/Downloader.html +33 -33
- data/html/WWWJDic/Utils/Downloader/Downloader.html +91 -89
- data/html/WWWJDic/Utils/Raisers.html +95 -95
- data/html/WWWJDic/WWWJDic.html +343 -345
- data/html/copyright_md.html +37 -51
- data/html/created.rid +55 -57
- data/html/index.html +334 -164
- 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 +44 -75
- data/lib/wwwjdic.rb +7 -11
- data/lib/wwwjdic/application.rb +13 -7
- data/lib/wwwjdic/constants.rb +16 -8
- data/lib/wwwjdic/locales/de.yml +5 -4
- data/lib/wwwjdic/locales/en.yml +5 -4
- data/lib/wwwjdic/locales/es.yml +5 -4
- data/lib/wwwjdic/locales/fr.yml +6 -4
- data/lib/wwwjdic/locales/hu.yml +6 -4
- data/lib/wwwjdic/locales/it.yml +6 -4
- data/lib/wwwjdic/locales/ja.yml +8 -4
- data/lib/wwwjdic/locales/nl.yml +5 -4
- data/lib/wwwjdic/locales/ru.yml +5 -4
- data/lib/wwwjdic/locales/sl.yml +5 -4
- data/lib/wwwjdic/locales/sv.yml +5 -4
- data/lib/wwwjdic/parser.rb +8 -4
- data/lib/wwwjdic/parsers/dict.rb +9 -7
- data/lib/wwwjdic/parsers/display.rb +6 -2
- data/lib/wwwjdic/parsers/key.rb +8 -3
- data/lib/wwwjdic/parsers/search.rb +8 -3
- data/lib/wwwjdic/parsers/server.rb +6 -2
- data/lib/wwwjdic/utils/downloader.rb +21 -23
- data/lib/wwwjdic/utils/raisers.rb +7 -3
- data/lib/wwwjdic/utils/splitter.rb +20 -14
- data/lib/wwwjdic/version.rb +2 -6
- data/test/test_helper.rb +5 -1
- data/test/test_wwwjdic.rb +6 -2
- data/test/wwwjdic/locales/de.yml +7 -1
- data/test/wwwjdic/locales/en.yml +7 -1
- data/test/wwwjdic/locales/es.yml +7 -1
- data/test/wwwjdic/locales/fr.yml +7 -1
- data/test/wwwjdic/locales/hu.yml +7 -1
- data/test/wwwjdic/locales/it.yml +10 -3
- data/test/wwwjdic/locales/ja.yml +9 -2
- data/test/wwwjdic/locales/nl.yml +7 -1
- data/test/wwwjdic/locales/ru.yml +7 -1
- data/test/wwwjdic/locales/sl.yml +7 -1
- data/test/wwwjdic/locales/sv.yml +7 -1
- data/test/wwwjdic/locales/test_locales.rb +12 -9
- data/test/wwwjdic/parsers/test_dict.rb +6 -2
- data/test/wwwjdic/parsers/test_display.rb +6 -2
- data/test/wwwjdic/parsers/test_key.rb +6 -2
- data/test/wwwjdic/parsers/test_server.rb +6 -2
- data/test/wwwjdic/test_application.rb +12 -8
- data/test/wwwjdic/test_parsable_duck_type.rb +6 -2
- data/test/wwwjdic/utils/test_downloader.rb +5 -1
- data/test/wwwjdic/utils/test_raisers.rb +10 -6
- data/wwwjdic.gemspec +30 -14
- metadata +50 -22
- data/acknowledgements.md +0 -55
- data/authors.md +0 -67
- data/html/acknowledgements_md.html +0 -150
- data/html/authors_md.html +0 -182
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# wwwjdic
|
3
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of wwwjdic.
|
6
6
|
#
|
@@ -16,6 +16,10 @@
|
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
19
23
|
#++
|
20
24
|
|
21
25
|
|
@@ -28,7 +32,7 @@ module WWWJDic
|
|
28
32
|
# methods...
|
29
33
|
#
|
30
34
|
# Author:: {Marco Bresciani}[mailto:marcobresciani_1974@libero.it]
|
31
|
-
# Copyright::
|
35
|
+
# Copyright:: (C) 2014 Marco Bresciani
|
32
36
|
# License:: GNU General Public License version 3
|
33
37
|
module Utils
|
34
38
|
|
@@ -36,7 +40,7 @@ module WWWJDic
|
|
36
40
|
# to (possibly) common conditions.
|
37
41
|
#
|
38
42
|
# Author:: {Marco Bresciani}[mailto:marcobresciani_1974@libero.it]
|
39
|
-
# Copyright::
|
43
|
+
# Copyright:: (C) 2014 Marco Bresciani
|
40
44
|
# License:: GNU General Public License version 3
|
41
45
|
module Raisers
|
42
46
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# wwwjdic
|
3
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of wwwjdic.
|
6
6
|
#
|
@@ -16,6 +16,10 @@
|
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
19
23
|
#++
|
20
24
|
|
21
25
|
require 'i18n'
|
@@ -27,7 +31,7 @@ module WWWJDic
|
|
27
31
|
# This class is a simple API to interact with WWWJDic Backboor
|
28
32
|
# Entry/API.
|
29
33
|
# Author:: {Marco Bresciani}[mailto:marcobresciani_1974@libero.it]
|
30
|
-
# Copyright::
|
34
|
+
# Copyright:: (C) 2014 Marco Bresciani
|
31
35
|
# License:: GNU General Public License version 3
|
32
36
|
class Splitter
|
33
37
|
# Creates a +Splitter+ object.
|
@@ -39,20 +43,21 @@ module WWWJDic
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def title
|
42
|
-
|
46
|
+
Regexp.last_match(1) if %r{<TITLE>(.*)</TITLE>}.match @translation
|
43
47
|
end
|
44
48
|
|
45
49
|
def translation
|
46
|
-
|
50
|
+
Regexp.last_match(1).strip if %r{<pre>(.*)</pre>}m.match @translation
|
47
51
|
end
|
48
52
|
|
49
53
|
def message
|
50
|
-
return
|
51
|
-
|
54
|
+
return Regexp.last_match(1).strip unless @translation.nil? || !/<p>(.*)<p>/m.match(@translation)
|
55
|
+
|
56
|
+
Regexp.last_match(1) if @translation.nil? && /<p>(.*)<pre>/m.match(@translation)
|
52
57
|
end
|
53
58
|
|
54
59
|
def lines
|
55
|
-
result =
|
60
|
+
result = []
|
56
61
|
translation.each_line do |a_line|
|
57
62
|
stripped_line = a_line.strip
|
58
63
|
result.push stripped_line unless stripped_line.empty?
|
@@ -60,18 +65,19 @@ module WWWJDic
|
|
60
65
|
result unless result.empty?
|
61
66
|
end
|
62
67
|
|
68
|
+
# @return [Array] the arrays of elements containing the answer
|
63
69
|
def content
|
64
|
-
result =
|
70
|
+
result = []
|
65
71
|
lines.each do |a_line|
|
66
|
-
inner =
|
72
|
+
inner = {}
|
67
73
|
if /(.*)\[/m.match a_line
|
68
|
-
inner[:word] =
|
69
|
-
inner[:kana] =
|
70
|
-
inner[:text] =
|
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
|
71
77
|
else
|
72
|
-
inner[:kana] =
|
78
|
+
inner[:kana] = Regexp.last_match(1).strip if %r{^(.*)(\s)/}m.match a_line
|
73
79
|
inner[:word] = inner[:kana]
|
74
|
-
inner[:text] =
|
80
|
+
inner[:text] = Regexp.last_match(1).strip if %r{/(.*)/}m.match a_line
|
75
81
|
end
|
76
82
|
inner[:meanings] = inner[:text].split('/') if inner[:text].include? '/'
|
77
83
|
result.push inner unless inner.empty?
|
data/lib/wwwjdic/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# wwwjdic
|
3
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of wwwjdic.
|
6
6
|
#
|
@@ -18,11 +18,7 @@
|
|
18
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
#++
|
20
20
|
|
21
|
-
require 'digest/md5'
|
22
|
-
require 'i18n'
|
23
|
-
require 'uri'
|
24
|
-
|
25
21
|
module WWWJDic
|
26
22
|
# Current version number for WWWJDic gem.
|
27
|
-
VERSION = '
|
23
|
+
VERSION = '15.0.0'.freeze
|
28
24
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# wwwjdic
|
3
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of wwwjdic.
|
6
6
|
#
|
@@ -16,6 +16,10 @@
|
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
19
23
|
#++
|
20
24
|
|
21
25
|
require 'simplecov'
|
data/test/test_wwwjdic.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# wwwjdic
|
3
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of wwwjdic.
|
6
6
|
#
|
@@ -16,13 +16,17 @@
|
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
19
23
|
#++
|
20
24
|
|
21
25
|
require_relative 'test_helper'
|
22
26
|
|
23
27
|
describe WWWJDic::WWWJDic do
|
24
28
|
describe 'when created' do
|
25
|
-
subject { WWWJDic
|
29
|
+
subject { WWWJDic.breener }
|
26
30
|
|
27
31
|
it 'must create a wwwjdic object' do
|
28
32
|
_(subject).wont_be_nil
|
data/test/wwwjdic/locales/de.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,6 +16,11 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
de:
|
20
26
|
test:
|
data/test/wwwjdic/locales/en.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,6 +16,11 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
en:
|
20
26
|
test:
|
data/test/wwwjdic/locales/es.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,6 +16,11 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
es:
|
20
26
|
test:
|
data/test/wwwjdic/locales/fr.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,6 +16,11 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
fr:
|
20
26
|
test:
|
data/test/wwwjdic/locales/hu.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,6 +16,11 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
hu:
|
20
26
|
test:
|
data/test/wwwjdic/locales/it.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,7 +16,13 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
it:
|
20
|
-
|
21
|
-
|
26
|
+
test:
|
27
|
+
kotoba: parola
|
28
|
+
test: dato di prova
|
data/test/wwwjdic/locales/ja.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
-
#
|
3
|
+
# © 2013 新部裕
|
4
|
+
# © 2014 Marco Bresciani
|
4
5
|
#
|
5
6
|
# This file is part of wwwjdic.
|
6
7
|
#
|
@@ -16,6 +17,12 @@
|
|
16
17
|
#
|
17
18
|
# You should have received a copy of the GNU General Public License
|
18
19
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
#
|
21
|
+
# SPDX-FileCopyrightText: 2013 新部裕
|
22
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
23
|
+
#
|
24
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
25
|
+
#++
|
19
26
|
|
20
27
|
ja:
|
21
28
|
test:
|
data/test/wwwjdic/locales/nl.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,6 +16,11 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
nl:
|
20
26
|
test:
|
data/test/wwwjdic/locales/ru.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,6 +16,11 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
ru:
|
20
26
|
test:
|
data/test/wwwjdic/locales/sl.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,6 +16,11 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
sl:
|
20
26
|
test:
|
data/test/wwwjdic/locales/sv.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
#--
|
1
2
|
# wwwjdic
|
2
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
3
4
|
#
|
4
5
|
# This file is part of wwwjdic.
|
5
6
|
#
|
@@ -15,6 +16,11 @@
|
|
15
16
|
#
|
16
17
|
# You should have received a copy of the GNU General Public License
|
17
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
23
|
+
#++
|
18
24
|
|
19
25
|
sv:
|
20
26
|
test:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#--
|
2
2
|
# wwwjdic
|
3
|
-
#
|
3
|
+
# © 2014 Marco Bresciani
|
4
4
|
#
|
5
5
|
# This file is part of wwwjdic.
|
6
6
|
#
|
@@ -16,15 +16,18 @@
|
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
# SPDX-FileCopyrightText: 2014 Marco Bresciani
|
21
|
+
#
|
22
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
19
23
|
#++
|
20
24
|
|
21
25
|
require_relative '../../test_helper'
|
22
26
|
|
27
|
+
RELATIVE_PATH = './'.freeze
|
28
|
+
|
23
29
|
describe WWWJDic::WWWJDic do
|
24
30
|
describe 'when using I18N' do
|
25
|
-
|
26
|
-
RELATIVE_PATH = '/../../../lib/wwwjdic/locales/'
|
27
|
-
|
28
31
|
before do
|
29
32
|
I18n.load_path = Dir[File.join(File.dirname(__FILE__), RELATIVE_PATH, '*.yml')]
|
30
33
|
end
|
@@ -43,22 +46,22 @@ describe WWWJDic::WWWJDic do
|
|
43
46
|
|
44
47
|
it 'shall contain a test.test signpost for each available locale' do
|
45
48
|
def load_yaml_file(locale)
|
46
|
-
filename = File
|
47
|
-
filename = File
|
48
|
-
YAML
|
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))
|
49
52
|
end
|
50
53
|
|
51
54
|
subject.each do |locale|
|
52
55
|
I18n.locale = locale
|
53
56
|
|
54
57
|
translation = load_yaml_file(locale)
|
55
|
-
_(translation[
|
58
|
+
_(translation[locale.to_s]['test']['test']).wont_be_nil
|
56
59
|
|
57
60
|
a_string = I18n.t('test.test')
|
58
61
|
_(a_string).wont_be_nil
|
59
62
|
_(a_string).wont_be_empty
|
60
63
|
_(a_string).wont_include 'translation missing'
|
61
|
-
_(a_string).must_equal translation[
|
64
|
+
_(a_string).must_equal translation[locale.to_s]['test']['test']
|
62
65
|
end
|
63
66
|
end
|
64
67
|
end
|