gravaty 10.0.0 → 11.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +7 -0
  3. data/Gemfile +5 -1
  4. data/README.md +219 -212
  5. data/Rakefile +9 -3
  6. data/copyright.md +33 -136
  7. data/examples/avatar.rb +70 -43
  8. data/examples/basics.rb +30 -20
  9. data/examples/profile.rb +77 -50
  10. data/examples/xmlrpc.rb +24 -10
  11. data/gravaty.gemspec +46 -25
  12. data/html/CHANGELOG.html +13 -20
  13. data/html/COPYING_md.html +8 -24
  14. data/html/Gemfile.html +7 -21
  15. data/html/Gravaty.html +49 -113
  16. data/html/Gravaty/Gravaty.html +138 -343
  17. data/html/Gravaty/ParsableDuckType.html +14 -33
  18. data/html/Gravaty/Parser.html +27 -66
  19. data/html/Gravaty/Parsers.html +3 -11
  20. data/html/Gravaty/Parsers/Avatar.html +19 -36
  21. data/html/Gravaty/Parsers/Callback.html +21 -37
  22. data/html/Gravaty/Parsers/Default.html +28 -45
  23. data/html/Gravaty/Parsers/Force.html +21 -37
  24. data/html/Gravaty/Parsers/Format.html +22 -42
  25. data/html/Gravaty/Parsers/Pixelsize.html +22 -42
  26. data/html/Gravaty/Parsers/Rating.html +22 -42
  27. data/html/Gravaty/Parsers/Secure.html +19 -36
  28. data/html/Gravaty/Parsers/Type.html +22 -42
  29. data/html/Gravaty/Utils.html +11 -13
  30. data/html/Gravaty/Utils/Downloader.html +3 -11
  31. data/html/Gravaty/Utils/Downloader/Downloader.html +25 -59
  32. data/html/Gravaty/Utils/Raisers.html +24 -55
  33. data/html/Gravaty/Utils/Rfc5322.html +12 -19
  34. data/html/Gravaty/Utils/RpcConnector.html +11 -13
  35. data/html/Gravaty/Utils/RpcConnector/RpcConnector.html +33 -73
  36. data/html/Object.html +728 -57
  37. data/html/README_md.html +105 -100
  38. data/html/Rakefile.html +9 -23
  39. data/html/copyright_md.html +17 -119
  40. data/html/created.rid +48 -55
  41. data/html/css/rdoc.css +1 -1
  42. data/html/index.html +97 -114
  43. data/html/js/navigation.js.gz +0 -0
  44. data/html/js/search_index.js +1 -1
  45. data/html/js/search_index.js.gz +0 -0
  46. data/html/js/searcher.js.gz +0 -0
  47. data/html/table_of_contents.html +219 -651
  48. data/lib/gravaty.rb +22 -15
  49. data/lib/gravaty/application.rb +40 -25
  50. data/lib/gravaty/constants.rb +20 -11
  51. data/lib/gravaty/locales/en.yml +9 -3
  52. data/lib/gravaty/locales/it.yml +9 -3
  53. data/lib/gravaty/locales/ja.yml +7 -4
  54. data/lib/gravaty/parser.rb +16 -10
  55. data/lib/gravaty/parsers/avatar.rb +11 -3
  56. data/lib/gravaty/parsers/callback.rb +13 -4
  57. data/lib/gravaty/parsers/default.rb +24 -16
  58. data/lib/gravaty/parsers/force.rb +12 -2
  59. data/lib/gravaty/parsers/format.rb +11 -2
  60. data/lib/gravaty/parsers/pixelsize.rb +12 -3
  61. data/lib/gravaty/parsers/rating.rb +12 -3
  62. data/lib/gravaty/parsers/secure.rb +11 -2
  63. data/lib/gravaty/parsers/type.rb +11 -2
  64. data/lib/gravaty/utils/downloader.rb +98 -96
  65. data/lib/gravaty/utils/raisers.rb +19 -12
  66. data/lib/gravaty/utils/rfc5322.rb +54 -41
  67. data/lib/gravaty/utils/rpc_connector.rb +19 -11
  68. data/lib/gravaty/version.rb +10 -2
  69. data/test/gravaty/locales/en.yml +29 -0
  70. data/test/gravaty/locales/it.yml +29 -0
  71. data/test/gravaty/locales/ja.yml +27 -0
  72. data/test/gravaty/locales/test_locales.rb +17 -13
  73. data/test/gravaty/parsers/test_avatar.rb +9 -1
  74. data/test/gravaty/parsers/test_callback.rb +12 -4
  75. data/test/gravaty/parsers/test_default.rb +25 -21
  76. data/test/gravaty/parsers/test_force.rb +9 -1
  77. data/test/gravaty/parsers/test_format.rb +18 -11
  78. data/test/gravaty/parsers/test_pixelsize.rb +19 -12
  79. data/test/gravaty/parsers/test_rating.rb +18 -11
  80. data/test/gravaty/parsers/test_secure.rb +9 -1
  81. data/test/gravaty/parsers/test_type.rb +14 -5
  82. data/test/gravaty/test_application.rb +14 -6
  83. data/test/gravaty/test_avatar.rb +94 -59
  84. data/test/gravaty/test_parser.rb +11 -5
  85. data/test/gravaty/test_profile.rb +47 -25
  86. data/test/gravaty/utils/test_downloader.rb +43 -28
  87. data/test/gravaty/utils/test_raisers.rb +42 -26
  88. data/test/gravaty/utils/test_rfc5322.rb +35 -13
  89. data/test/gravaty/utils/test_rpc_connector.rb +83 -39
  90. data/test/test_gravaty.rb +12 -4
  91. data/test/test_helper.rb +15 -9
  92. metadata +54 -40
  93. data/ISSUES.md +0 -62
  94. data/acknowledgements.md +0 -66
  95. data/authors.md +0 -63
  96. data/examples/cacert.pem +0 -3466
  97. data/html/ISSUES_md.html +0 -166
  98. data/html/acknowledgements_md.html +0 -161
  99. data/html/authors_md.html +0 -174
  100. data/html/examples/cacert_pem.html +0 -1078
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Marco Bresciani
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,45 +20,48 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
25
+ #
26
+ # SPDX-License-Identifier: GPL-3.0-or-later
19
27
  #++
20
28
 
21
29
  require 'i18n'
22
30
 
23
31
  module Gravaty
24
-
25
32
  # This module is a simple collection of useful things and methods that
26
33
  # I prefer to keep as DRYer as possible. Just include it and use the
27
34
  # methods...
28
35
  #
29
36
  # Author:: {Marco Bresciani}[mailto:marcobresciani_1974@libero.it]
37
+ # rubocop:disable Style/AsciiComments
30
38
  # Copyright:: Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
39
+ # rubocop:enable Style/AsciiComments
31
40
  # License:: GNU General Public License version 3
32
41
  module Utils
33
-
34
42
  # This module contains some utility method to raise errors according
35
43
  # to (possibly) common conditions.
36
44
  #
37
45
  # Author:: {Marco Bresciani}[mailto:marcobresciani_1974@libero.it]
46
+ # rubocop:disable Style/AsciiComments
38
47
  # Copyright:: Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
48
+ # rubocop:enable Style/AsciiComments
39
49
  # License:: GNU General Public License version 3
40
50
  module Raisers
41
-
42
51
  # Raises an +ArgumentError+ according to parameters, unless the
43
52
  # +array+ contains a downcased +value+.
44
53
  def raiser_downcase(name = 'error.value', value = nil, array = nil)
45
- unless value.nil?
46
- raise ArgumentError,
47
- I18n.t(name, value: value) unless array.include? value.downcase
48
- end
54
+ raise ArgumentError, I18n.t(name, value: value) if !value.nil? &&
55
+ !(array.include? value.downcase) &&
56
+ !(array.include? value.downcase)
49
57
  end
50
58
 
51
59
  # Raises an +ArgumentError+ according to parameters, unless the
52
60
  # +array+ contains the number of the +value+.
53
61
  def raiser_to_i(name = 'error.value', value = nil, array = nil)
54
- unless value.nil?
55
- raise ArgumentError,
56
- I18n.t(name, value: value) unless array.include? value.to_i
57
- end
62
+ raise ArgumentError, I18n.t(name, value: value) if !value.nil? &&
63
+ !(array.include? value.to_i) &&
64
+ !(array.include? value.to_i)
58
65
  end
59
66
  end
60
67
  end
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Peter R. Marreck
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,6 +20,10 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Peter R. Marreck
25
+ #
26
+ # SPDX-License-Identifier: BSD-3-Clause
19
27
  #++
20
28
 
21
29
  module Gravaty
@@ -23,51 +31,56 @@ module Gravaty
23
31
  # This module is a simple wrapper container for Peter R. Marreck's gist.
24
32
  #
25
33
  # Author:: {Peter R. Marreck}[mailto:lumbergh@gmail.com]
34
+ # rubocop:disable Style/AsciiComments
26
35
  # Copyright:: Copyleft (©) 2013, Peter R. Marreck
36
+ # rubocop:enable Style/AsciiComments
27
37
  # License:: This work is released under the BSD 3-Clause License
28
38
  # http://choosealicense.com/licenses/bsd-3-clause/
29
39
  module Rfc5322
40
+ # Author:: {Peter R. Marreck}[mailto:lumbergh@gmail.com]
41
+ # rubocop:disable Style/AsciiComments
42
+ # Copyright:: Copyleft (©) 2013, Peter R. Marreck
43
+ # rubocop:enable Style/AsciiComments
44
+ # License:: This work is released under the BSD 3-Clause License
45
+ # http://choosealicense.com/licenses/bsd-3-clause/
30
46
 
31
- # Author:: {Peter R. Marreck}[mailto:lumbergh@gmail.com]
32
- # Copyright:: Copyleft (©) 2013, Peter R. Marreck
33
- # License:: This work is released under the BSD 3-Clause License
34
- # http://choosealicense.com/licenses/bsd-3-clause/
47
+ # RFC 5322 Email Validation Regex in Ruby
35
48
 
36
- # RFC 5322 Email Validation Regex in Ruby
37
-
38
- # This work is released under the BSD 3-Clause License
39
- # http://choosealicense.com/licenses/bsd-3-clause/
40
- # Copyleft (©) 2013, Peter R. Marreck
41
- # All rights reserved.
42
- #
43
- # Redistribution and use in source and binary forms, with or without
44
- # modification, are permitted provided that the following conditions are
45
- # met:
46
- #
47
- # Redistributions of source code must retain the above copyright
48
- # notice, this list of conditions and the following disclaimer.
49
- #
50
- # Redistributions in binary form must reproduce the above copyright
51
- # notice, this list of conditions and the following disclaimer in the
52
- # documentation and/or other materials provided with the distribution.
53
- #
54
- # Neither the name of the {organization} nor the names of its
55
- # contributors may be used to endorse or promote products derived from
56
- # this software without specific prior written permission.
57
- #
58
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
59
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
60
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
61
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
62
- # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
63
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
64
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
65
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
66
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
67
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
68
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49
+ # This work is released under the BSD 3-Clause License
50
+ # http://choosealicense.com/licenses/bsd-3-clause/
51
+ # rubocop:disable Style/AsciiComments
52
+ # Copyleft (©) 2013, Peter R. Marreck
53
+ # rubocop:enable Style/AsciiComments
54
+ # All rights reserved.
55
+ #
56
+ # Redistribution and use in source and binary forms, with or without
57
+ # modification, are permitted provided that the following conditions are
58
+ # met:
59
+ #
60
+ # Redistributions of source code must retain the above copyright
61
+ # notice, this list of conditions and the following disclaimer.
62
+ #
63
+ # Redistributions in binary form must reproduce the above copyright
64
+ # notice, this list of conditions and the following disclaimer in the
65
+ # documentation and/or other materials provided with the distribution.
66
+ #
67
+ # Neither the name of the {organization} nor the names of its
68
+ # contributors may be used to endorse or promote products derived from
69
+ # this software without specific prior written permission.
70
+ #
71
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
72
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
73
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
74
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
75
+ # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
76
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
77
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
78
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
79
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
80
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
81
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69
82
 
70
- EMAIL = /
83
+ EMAIL = %r{
71
84
  (?<addr_spec> (?> \g<local_part> @ \g<domain> ) ){0}
72
85
  (?<local_part> (?> \g<dot_atom> | \g<quoted_string> | \g<obs_local_part> ) ){0}
73
86
  (?<domain> (?> \g<dot_atom> | \g<domain_literal> | \g<obs_domain> ) ){0}
@@ -76,7 +89,7 @@ module Gravaty
76
89
  (?<quoted_pair> (?> \\ (?: \g<VCHAR> | \g<WSP> ) | \g<obs_qp> ) ){0}
77
90
  (?<dot_atom> (?> \g<CFWS>? \g<dot_atom_text> \g<CFWS>? ) ){0}
78
91
  (?<dot_atom_text> (?> \g<atext> (?: \. \g<atext> )* ) ){0}
79
- (?<atext> (?> [a-zA-Z0-9!\#\$%&'*\+\/\=\?\^_`{\|}~\-]+ ) ){0}
92
+ (?<atext> (?> [a-zA-Z0-9!\#\$%&'*\+/\=\?\^_`{\|}~\-]+ ) ){0}
80
93
  (?<atom> (?> \g<CFWS>? \g<atext> \g<CFWS>? ) ){0}
81
94
  (?<word> (?> \g<atom> | \g<quoted_string> ) ){0}
82
95
  (?<quoted_string> (?> \g<CFWS>? " (?: \g<FWS>? \g<qcontent> )* \g<FWS>? " \g<CFWS>? ) ){0}
@@ -104,7 +117,7 @@ module Gravaty
104
117
  (?<VCHAR> (?> [\x21-\x7E] ) ){0}
105
118
  (?<WSP> [ \t] ){0}
106
119
  \g<addr_spec>
107
- /uix
120
+ }uix
108
121
  end
109
122
  end
110
123
  end
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Marco Bresciani
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,6 +20,10 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
25
+ #
26
+ # SPDX-License-Identifier: GPL-3.0-or-later
19
27
  #++
20
28
 
21
29
  require 'i18n'
@@ -24,14 +32,14 @@ require_relative 'raisers'
24
32
 
25
33
  module Gravaty
26
34
  module Utils
27
-
28
35
  # This module contains the XML-RPC connector class.
29
36
  #
30
37
  # Author:: {Marco Bresciani}[mailto:marcobresciani_1974@libero.it]
38
+ # rubocop:disable Style/AsciiComments
31
39
  # Copyright:: Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
40
+ # rubocop:enable Style/AsciiComments
32
41
  # License:: GNU General Public License version 3
33
42
  module RpcConnector
34
-
35
43
  # Creates a +RpcConnector+ described by the user's email +digest+
36
44
  # and a +password+. Throws a +ArgumentError+ if the supplied
37
45
  # +digest+ or the +password+ are not valid.
@@ -50,19 +58,19 @@ module Gravaty
50
58
 
51
59
  def initialize(digest, password = nil)
52
60
  I18n.load_path =
53
- Dir[File.join(File.dirname(__FILE__),
54
- '/../locales/', '*.yml')]
61
+ Dir[File.join(File.dirname(__FILE__),
62
+ '/../locales/', '*.yml')]
55
63
 
56
- raise ArgumentError, I18n.t('error.nil') if digest.nil? or
57
- digest.empty?
58
- raise ArgumentError, I18n.t('error.nil') if password.nil? or
59
- password.empty?
64
+ raise ArgumentError, I18n.t('error.nil') if digest.nil? ||
65
+ digest.empty?
66
+ raise ArgumentError, I18n.t('error.nil') if password.nil? ||
67
+ password.empty?
60
68
 
61
69
  @digest = digest
62
70
  @connector = XMLRPC::Client.new(RPC_URI, build_rpc_path, 443,
63
71
  nil, nil, nil, nil, true)
64
72
 
65
- @params = Hash.new
73
+ @params = {}
66
74
  @params[:password] = password
67
75
  end
68
76
 
@@ -72,7 +80,7 @@ module Gravaty
72
80
  @connector.call a_method, @params.merge(params)
73
81
  end
74
82
 
75
- # ------------------------------ here starts the list of private methods
83
+ # ------------------------------ here starts the list of private methods
76
84
 
77
85
  private
78
86
 
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Marco Bresciani
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,9 +20,13 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
25
+ #
26
+ # SPDX-License-Identifier: GPL-3.0-or-later
19
27
  #++
20
28
 
21
29
  module Gravaty
22
30
  # Current version number for Gravaty gem.
23
- VERSION = '10.0.0'
31
+ VERSION = '11.0.1'
24
32
  end
@@ -0,0 +1,29 @@
1
+ #--
2
+ # gravaty
3
+ # rubocop:disable Style/AsciiComments
4
+ # © 2013 Marco Bresciani
5
+ # rubocop:enable Style/AsciiComments
6
+ #
7
+ # This file is part of gravaty.
8
+ #
9
+ # gravaty is free software: you can redistribute it and/or modify it
10
+ # under the terms of the GNU General Public License as published by the
11
+ # Free Software Foundation, either version 3 of the License, or (at your
12
+ # option) any later version.
13
+ #
14
+ # gravaty is distributed in the hope that it will be useful, but WITHOUT
15
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17
+ # for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
23
+ #
24
+ # SPDX-License-Identifier: GPL-3.0-or-later
25
+ #++
26
+
27
+ en:
28
+ test:
29
+ test: test data
@@ -0,0 +1,29 @@
1
+ #--
2
+ # gravaty
3
+ # rubocop:disable Style/AsciiComments
4
+ # © 2013 Marco Bresciani
5
+ # rubocop:enable Style/AsciiComments
6
+ #
7
+ # This file is part of gravaty.
8
+ #
9
+ # gravaty is free software: you can redistribute it and/or modify it
10
+ # under the terms of the GNU General Public License as published by the
11
+ # Free Software Foundation, either version 3 of the License, or (at your
12
+ # option) any later version.
13
+ #
14
+ # gravaty is distributed in the hope that it will be useful, but WITHOUT
15
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17
+ # for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
23
+ #
24
+ # SPDX-License-Identifier: GPL-3.0-or-later
25
+ #++
26
+
27
+ it:
28
+ test:
29
+ test: dato di prova
@@ -0,0 +1,27 @@
1
+ #--
2
+ # gravaty
3
+ # © 2013 新部裕, Marco Bresciani
4
+ #
5
+ # This file is part of gravaty.
6
+ #
7
+ # gravaty is free software: you can redistribute it and/or modify it
8
+ # under the terms of the GNU General Public License as published by the
9
+ # Free Software Foundation, either version 3 of the License, or (at your
10
+ # option) any later version.
11
+ #
12
+ # gravaty is distributed in the hope that it will be useful, but WITHOUT
13
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
+ # for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
19
+ #
20
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
21
+ #
22
+ # SPDX-License-Identifier: GPL-3.0-or-later
23
+ #++
24
+
25
+ ja:
26
+ test:
27
+ test: 試験データ
@@ -1,6 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # gravaty
3
- # Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani
5
+ # rubocop:disable Style/AsciiComments
6
+ # © 2013 Marco Bresciani
7
+ # rubocop:enable Style/AsciiComments
4
8
  #
5
9
  # This file is part of gravaty.
6
10
  #
@@ -16,19 +20,20 @@
16
20
  #
17
21
  # You should have received a copy of the GNU General Public License
18
22
  # along with gravaty. If not, see <http://www.gnu.org/licenses/>.
23
+ #
24
+ # SPDX-FileCopyrightText: 2013 Marco Bresciani
25
+ #
26
+ # SPDX-License-Identifier: GPL-3.0-or-later
19
27
  #++
20
28
 
21
29
  require_relative '../../test_helper'
22
30
 
23
31
  describe Gravaty::Gravaty do
24
32
  describe 'when using I18N' do
25
-
26
- RELATIVE_PATH = '/../../../lib/gravaty/locales/'
27
-
28
33
  before do
29
34
  I18n.load_path = Dir[File.join(File
30
- .dirname(__FILE__),
31
- RELATIVE_PATH, '*.yml')]
35
+ .dirname(__FILE__),
36
+ '.', '*.yml')]
32
37
  end
33
38
 
34
39
  subject { I18n.available_locales }
@@ -45,24 +50,23 @@ describe Gravaty::Gravaty do
45
50
 
46
51
  it 'shall contain a test.test signpost for each available locale' do
47
52
  def load_yaml_file(locale)
48
- filename = File::join(File::dirname(__FILE__),
49
- RELATIVE_PATH, "#{locale}" +
50
- '.yml')
51
- filename = File::expand_path filename
52
- YAML::load(File::open "#{filename}")
53
+ filename = File.join(File.dirname(__FILE__),
54
+ '.', "#{locale}.yml")
55
+ filename = File.expand_path filename
56
+ YAML.safe_load(File.open(filename.to_s))
53
57
  end
54
58
 
55
59
  subject.each do |locale|
56
60
  I18n.locale = locale
57
61
 
58
62
  translation = load_yaml_file(locale)
59
- _(translation["#{locale}"]['test']['test']).wont_be_nil
63
+ _(translation[locale.to_s]['test']['test']).wont_be_nil
60
64
 
61
65
  a_string = I18n.t('test.test')
62
66
  _(a_string).wont_be_nil
63
67
  _(a_string).wont_be_empty
64
68
  _(a_string).wont_include 'translation missing'
65
- _(a_string).must_equal translation["#{locale}"]['test']['test']
69
+ _(a_string).must_equal translation[locale.to_s]['test']['test']
66
70
  end
67
71
  end
68
72
  end