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
data/examples/basics.rb CHANGED
@@ -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_relative '../lib/gravaty'
@@ -23,53 +31,55 @@ require_relative '../lib/gravaty'
23
31
  i = 0
24
32
 
25
33
  # Raises ArgumentError when email address is nil
26
- puts "------------------------------------------"
27
- puts "Basics: '#{i}'. Raises ArgumentError when email address is nil."
28
- puts "------------------------------------------"
34
+ puts '=========================================='
35
+ puts "BASICS '#{i}': Raises ArgumentError when email address is nil."
29
36
  puts 'irb(main):001:0> Gravaty::gravatize nil'
30
37
  begin
31
- Gravaty::gravatize(nil)
32
- rescue ArgumentError => aErr
33
- puts aErr.message
38
+ Gravaty.gravatize(nil)
39
+ rescue ArgumentError => e
40
+ puts e.message
34
41
  end
42
+ puts '------------------------------------------'
35
43
  puts
36
44
  i += 1
37
45
 
38
46
  # Creates the Gravaty object with an (example) email
39
- puts "------------------------------------------"
40
- puts "Basics: '#{i}'. Creates the Gravaty object with an (example) email."
41
- puts "------------------------------------------"
47
+ puts '=========================================='
48
+ puts "BASICS '#{i}': Creates the Gravaty object with an (example) email."
42
49
  puts "irb(main):001:0> a_gravaty = Gravaty::gravatize 'user@example.com'"
43
- a_gravaty = Gravaty::gravatize 'user@example.com'
50
+ a_gravaty = Gravaty.gravatize 'user@example.com'
51
+ puts '------------------------------------------'
44
52
  puts
45
53
  i += 1
46
54
 
47
55
  # Prints the email
48
56
  # (user@example.com)
49
- puts "------------------------------------------"
50
- puts "Basics: '#{i}'. Prints the email (user@example.com)."
51
- puts "------------------------------------------"
57
+ puts '=========================================='
58
+ puts "BASICS '#{i}': Prints the email (user@example.com)."
52
59
  puts 'irb(main):001:0> puts a_gravaty.email'
53
60
  puts a_gravaty.email
61
+ puts '------------------------------------------'
54
62
  puts
55
63
  i += 1
56
64
 
57
65
  # Prints the MD5 digest of the downcased email address
58
66
  # (b58996c504c5638798eb6b511e6f49af)
59
- puts "------------------------------------------"
60
- puts "Basics: '#{i}'. Prints the MD5 digest of the downcased email address (b58996c504c5638798eb6b511e6f49af)."
61
- puts "------------------------------------------"
67
+ puts '=========================================='
68
+ puts "BASICS '#{i}': Prints the MD5 digest of the downcased email address (b58996c504c5638798eb6b511e6f49af)."
62
69
  puts 'irb(main):001:0> puts a_gravaty.digest'
63
70
  puts a_gravaty.digest
71
+ puts '------------------------------------------'
64
72
  puts
65
73
  i += 1
66
74
 
67
75
  # Prints the current gravaty according to previously done ! operations.
68
76
  # Email address if no operation has been done (user@example.com)
69
77
  # (b58996c504c5638798eb6b511e6f49af)
70
- puts "------------------------------------------"
71
- puts "Basics: '#{i}'. Prints the current gravaty according to previously done ! operations. Email address if no operation has been done (user@example.com)."
72
- puts "------------------------------------------"
78
+ puts '=========================================='
79
+ # rubocop:disable Layout/LineLength
80
+ puts "BASICS '#{i}': Prints the current gravaty according to previously done ! operations. Email address if no operation has been done (user@example.com)."
81
+ # rubocop:enable Layout/LineLength
73
82
  puts 'irb(main):001:0> puts a_gravaty'
74
83
  puts a_gravaty
84
+ puts '------------------------------------------'
75
85
  puts
data/examples/profile.rb CHANGED
@@ -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,172 +20,195 @@
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 '../lib/gravaty'
30
+ require 'open-uri'
31
+
32
+ def internet_connection?
33
+ true if URI.open('http://secure.gravatar.com')
34
+ rescue StandardError
35
+ false
36
+ end
22
37
 
23
38
  i = 0
24
39
 
25
40
  # Creates the Gravaty object with an (example) email
26
- puts "------------------------------------------"
27
- puts "Profile: '#{i}'. Creates the Gravaty object with an (example) email."
28
- puts "------------------------------------------"
41
+ puts '=========================================='
42
+ puts "PROFILE '#{i}': Creates the Gravaty object with an (example) email."
29
43
  puts "irb(main):001:0> a_gravaty = Gravaty::gravatize 'user@example.com'"
30
- a_gravaty = Gravaty::gravatize 'user@example.com'
44
+ a_gravaty = Gravaty.gravatize 'user@example.com'
45
+ puts '------------------------------------------'
31
46
  puts
32
47
  i += 1
33
48
 
34
49
  # Prints the basic URL for profile retrieval, with no frills
35
50
  # (https://www.gravatar.com/b58996c504c5638798eb6b511e6f49af)
36
- puts "------------------------------------------"
37
- puts "Profile: '#{i}'. Prints the basic URL for profile retrieval, with no frills (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af)."
38
- puts "------------------------------------------"
51
+ puts '=========================================='
52
+ puts "PROFILE '#{i}': Prints the basic URL for profile retrieval, with no frills (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af)."
39
53
  puts 'irb(main):001:0> a_gravaty.profile'
40
54
  puts a_gravaty.profile
55
+ puts '------------------------------------------'
41
56
  puts
42
57
  i += 1
43
58
 
44
59
  # Prints the basic URL for profile retrieval, with no frills, in json
45
60
  # format through json-specific method
46
61
  # (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.json)
47
- puts "------------------------------------------"
48
- puts "Profile: '#{i}'. Prints the basic URL for profile retrieval, with no frills, in json format through json-specific method (http://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.json)."
49
- puts "------------------------------------------"
62
+ puts '=========================================='
63
+ # rubocop:disable Layout/LineLength
64
+ puts "PROFILE '#{i}': Prints the basic URL for profile retrieval, with no frills, in json format through json-specific method (http://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.json)."
65
+ # rubocop:enable Layout/LineLength
50
66
  puts 'irb(main):001:0> a_gravaty.json'
51
67
  puts a_gravaty.json
68
+ puts '------------------------------------------'
52
69
  puts
53
70
  i += 1
54
71
 
55
72
  # Prints the basic URL for profile retrieval, in JSON format, with
56
73
  # callback string
57
74
  # (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.json?callback=my_callback)
58
- puts "------------------------------------------"
59
- puts "Profile: '#{i}'. Prints the basic URL for profile retrieval, in JSON format, with callback string (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.json?callback=my_callback)."
60
- puts "------------------------------------------"
75
+ puts '=========================================='
76
+ puts "PROFILE '#{i}': Prints the basic URL for profile retrieval, in JSON format, with callback string (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.json?callback=my_callback)."
61
77
  puts "irb(main):001:0> a_gravaty.json callback: 'my_callback'"
62
78
  puts a_gravaty.json callback: 'my_callback'
79
+ puts '------------------------------------------'
63
80
  puts
64
81
  i += 1
65
82
 
66
83
  # Prints the basic URL for profile retrieval, in PHP format
67
84
  # (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.php)
68
- puts "------------------------------------------"
69
- puts "Profile: '#{i}'. Prints the basic URL for profile retrieval, in PHP format (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.php)."
70
- puts "------------------------------------------"
85
+ puts '=========================================='
86
+ puts "PROFILE '#{i}': Prints the basic URL for profile retrieval, in PHP format (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.php)."
71
87
  puts "irb(main):001:0> a_gravaty.profile format: 'php'"
72
88
  puts a_gravaty.profile format: 'php'
89
+ puts '------------------------------------------'
73
90
  puts
74
91
  i += 1
75
92
 
76
93
  # Prints the basic URL for profile retrieval, with no frills, in QR code
77
94
  # format through QR code-specific method
78
95
  # (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)
79
- puts "------------------------------------------"
80
- puts "Profile: '#{i}'. Prints the basic URL for profile retrieval, with no frills, in QR code format through QR code-specific method (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)."
81
- puts "------------------------------------------"
96
+ puts '=========================================='
97
+ # rubocop:disable Layout/LineLength
98
+ puts "PROFILE '#{i}': Prints the basic URL for profile retrieval, with no frills, in QR code format through QR code-specific method (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)."
99
+ # rubocop:enable Layout/LineLength
82
100
  puts 'irb(main):001:0> a_gravaty.qrcode'
83
101
  puts a_gravaty.qrcode
102
+ puts '------------------------------------------'
84
103
  puts
85
104
  i += 1
86
105
 
87
106
  # Prints and saves the basic URL for profile retrieval, with no frills,
88
107
  # in QR code format
89
108
  # (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)
90
- puts "------------------------------------------"
91
- puts "Profile: '#{i}'. Prints and saves the basic URL for profile retrieval, with no frills, in QR code format (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)."
92
- puts "------------------------------------------"
109
+ puts '=========================================='
110
+ puts "PROFILE '#{i}': Prints and saves the basic URL for profile retrieval, with no frills, in QR code format (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)."
93
111
  puts "irb(main):001:0> a_gravaty.profile! format: 'qr'"
94
112
  puts a_gravaty.profile! format: 'qr'
113
+ puts '------------------------------------------'
95
114
  puts
96
115
  i += 1
97
116
 
98
117
  # Retrieves the latest saved operation (email address, if none saved)
99
118
  # (user@example.com)
100
- puts "------------------------------------------"
101
- puts "Profile: '#{i}'. Retrieves the latest saved operation (email address, if none saved) (user@example.com)."
102
- puts "------------------------------------------"
119
+ puts '=========================================='
120
+ puts "PROFILE '#{i}': Retrieves the latest saved operation (email address, if none saved) (user@example.com)."
103
121
  puts 'irb(main):001:0> puts a_gravaty'
104
122
  puts a_gravaty
123
+ puts '------------------------------------------'
105
124
  puts
106
125
  i += 1
107
126
 
108
127
  # Prints and save the basic URL for profile and later retrieval, in QR
109
128
  # code format
110
129
  # (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)
111
- puts "------------------------------------------"
112
- puts "Profile: '#{i}'. Prints and save the basic URL for profile and later retrieval, in QR code format (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)."
113
- puts "------------------------------------------"
130
+ puts '=========================================='
131
+ puts "PROFILE '#{i}': Prints and save the basic URL for profile and later retrieval, in QR code format (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)."
114
132
  puts "irb(main):001:0> a_gravaty.profile! format: 'qr'"
115
133
  puts a_gravaty.profile! format: 'qr'
134
+ puts '------------------------------------------'
116
135
  puts
117
136
 
118
137
  # Downloads the previously saved gravaty configuration with the default
119
138
  # name of the file according to saved URI
120
139
  # (saves b58996c504c5638798eb6b511e6f49af.qr file via HTTPS)
121
- puts "------------------------------------------"
122
- puts "Profile: '#{i}'. Downloads the previously saved gravaty configuration with the default name of the file according to saved URI. (saves b58996c504c5638798eb6b511e6f49af.qr file via HTTPS)"
123
- puts "------------------------------------------"
140
+ puts '=========================================='
141
+ # rubocop:disable Layout/LineLength
142
+ puts "PROFILE '#{i}': Downloads the previously saved gravaty configuration with the default name of the file according to saved URI. (saves b58996c504c5638798eb6b511e6f49af.qr file via HTTPS)"
143
+ # rubocop:enable Layout/LineLength
124
144
  puts 'irb(main):001:0> a_gravaty.download'
125
- a_gravaty.download
145
+ a_gravaty.download if internet_connection? && !ENV['SSL_CERT_FILE'].nil?
146
+ File.delete('b58996c504c5638798eb6b511e6f49af.qr') if File.exist?('bb58996c504c5638798eb6b511e6f49af.qr')
147
+ puts '------------------------------------------'
126
148
  puts
127
149
  i += 1
128
150
 
129
151
  # Prints the basic URL for profile retrieval in QR code format
130
152
  # (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)
131
- puts "------------------------------------------"
153
+ puts '=========================================='
132
154
  puts "Profile: '#{i}'a. Prints the basic URL for profile retrieval in QR code format (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr)."
133
- puts "------------------------------------------"
134
155
  puts 'irb(main):001:0> a_gravaty.qrcode'
135
156
  puts a_gravaty.qrcode
157
+ puts '------------------------------------------'
136
158
  puts
137
159
 
138
160
  # Prints the unsecure URL for profile retrieval in QR code format with
139
161
  # specified image size (in pixels)
140
162
  # (http://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr?s=42)
141
- puts "------------------------------------------"
163
+ puts '=========================================='
164
+ # rubocop:disable Layout/LineLength
142
165
  puts "Profile: '#{i}'b. prints the unsecure URL for profile retrieval in QR code format with specified image size (in pixels) (http://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr?s=42)."
143
- puts "------------------------------------------"
166
+ # rubocop:enable Layout/LineLength
144
167
  puts 'irb(main):001:0> a_gravaty.qrcode pixelsize: 42, secure: false'
145
168
  puts a_gravaty.qrcode! pixelsize: 42, secure: false
169
+ puts '------------------------------------------'
146
170
  puts
147
171
  i += 1
148
172
 
149
173
  # Retrieves the latest saved operation (email address, if none saved)
150
174
  # (user@example.com)
151
- puts "------------------------------------------"
152
- puts "Profile: '#{i}'. Retrieves the latest saved operation (email address, if none saved) (user@example.com)."
153
- puts "------------------------------------------"
175
+ puts '=========================================='
176
+ puts "PROFILE '#{i}': Retrieves the latest saved operation (email address, if none saved) (user@example.com)."
154
177
  puts 'irb(main):001:0> puts a_gravaty'
155
178
  puts a_gravaty
179
+ puts '------------------------------------------'
156
180
  puts
157
181
  i += 1
158
182
 
159
183
  # Prints and saves the unsecure URL for profile retrieval, in VFC/vCard
160
184
  # format (http://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.vcf)
161
- puts "------------------------------------------"
162
- puts "Profile: '#{i}'. Prints and saves the unsecure URL for profile retrieval, in VFC/vCard format (http://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.vcf)."
163
- puts "------------------------------------------"
185
+ puts '=========================================='
186
+ puts "PROFILE '#{i}': Prints and saves the unsecure URL for profile retrieval, in VFC/vCard format (http://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.vcf)."
164
187
  puts "irb(main):001:0> a_gravaty.profile format: 'vcf', secure: false"
165
188
  puts a_gravaty.profile! format: 'vcf', secure: false
189
+ puts '------------------------------------------'
166
190
  puts
167
191
  i += 1
168
192
 
169
193
  # Downloads the previously saved gravaty configuration with the default
170
194
  # name of the file according to saved URI
171
195
  # (saves b58996c504c5638798eb6b511e6f49af.vcf file via HTTP)
172
- puts "------------------------------------------"
173
- puts "Profile: '#{i}'. Downloads the previously saved gravaty configuration with the default name of the file according to saved URI. (saves b58996c504c5638798eb6b511e6f49af.vcf file via HTTP)"
174
- puts "------------------------------------------"
196
+ puts '=========================================='
197
+ # rubocop:disable Layout/LineLength
198
+ puts "PROFILE '#{i}': Downloads the previously saved gravaty configuration with the default name of the file according to saved URI. (saves b58996c504c5638798eb6b511e6f49af.vcf file via HTTP)"
199
+ # rubocop:enable Layout/LineLength
175
200
  puts 'irb(main):001:0> a_gravaty.download'
176
- a_gravaty.download
201
+ a_gravaty.download if internet_connection? && !ENV['SSL_CERT_FILE'].nil?
202
+ File.delete('b58996c504c5638798eb6b511e6f49af.vcf') if File.exist?('b58996c504c5638798eb6b511e6f49af.vcf')
203
+ puts '------------------------------------------'
177
204
  puts
178
205
  i += 1
179
206
 
180
207
  # Prints the basic URL for profile retrieval, in XML format
181
208
  # (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.xml)
182
- puts "------------------------------------------"
183
- puts "Profile: '#{i}'. Prints the basic URL for profile retrieval, in XML format (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.xml)."
184
- puts "------------------------------------------"
209
+ puts '=========================================='
210
+ puts "PROFILE '#{i}': Prints the basic URL for profile retrieval, in XML format (https://secure.gravatar.com/b58996c504c5638798eb6b511e6f49af.xml)."
185
211
  puts "irb(main):001:0> a_gravaty.profile format: 'xml'"
186
212
  puts a_gravaty.profile format: 'xml'
213
+ puts '------------------------------------------'
187
214
  puts
data/examples/xmlrpc.rb CHANGED
@@ -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,26 +20,36 @@
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 '../lib/gravaty'
30
+ require 'open-uri'
31
+
32
+ def internet_connection?
33
+ true if URI.open('http://secure.gravatar.com')
34
+ rescue StandardError
35
+ false
36
+ end
22
37
 
23
38
  i = 0
24
39
 
25
40
  # Creates the Gravaty object with an (example) email
26
- puts "------------------------------------------"
27
- puts "XML-RPC: '#{i}'. Creates the Gravaty object with an (example) email."
28
- puts "------------------------------------------"
41
+ puts '=========================================='
42
+ puts "XML-RPC '#{i}': Creates the Gravaty object with an (example) email."
29
43
  puts "irb(main):001:0> a_gravaty = Gravaty::gravatize 'user@example.com'"
30
- a_gravaty = Gravaty::gravatize 'user@example.com'
44
+ a_gravaty = Gravaty.gravatize 'user@example.com'
45
+ puts '------------------------------------------'
31
46
  puts
32
47
  i += 1
33
48
 
34
49
  # Calls the test method of the XML-RPC API
35
- puts "------------------------------------------"
36
- puts "XML-RPC: '#{i}'. Calls the test method of the XML-RPC API with password 'password'."
37
- puts "------------------------------------------"
50
+ puts '=========================================='
51
+ puts "XML-RPC '#{i}': Calls the test method of the XML-RPC API with password 'password'."
38
52
  puts 'irb(main):001:0> a_gravaty.xmlrpc Gravaty::RPC_TEST_METHOD'
39
- a_gravaty.xmlrpc Gravaty::RPC_TEST_METHOD, 'password'
53
+ a_gravaty.xmlrpc Gravaty::RPC_TEST_METHOD, 'password' if internet_connection? && !ENV['SSL_CERT_FILE'].nil?
54
+ puts '------------------------------------------'
40
55
  puts
41
- i += 1
data/gravaty.gemspec CHANGED
@@ -1,5 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
1
4
  # gravaty
2
- # 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
3
8
  #
4
9
  # This file is part of gravaty.
5
10
  #
@@ -15,6 +20,11 @@
15
20
  #
16
21
  # You should have received a copy of the GNU General Public License
17
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
27
+ #++
18
28
 
19
29
  require_relative 'lib/gravaty/version'
20
30
 
@@ -23,56 +33,67 @@ SUMMARY = 'This gem automagically prepares complete URIs for Gravatar,
23
33
  included the XML-RPC API, as of 2014-04-30, starting from a single
24
34
  email address!'
25
35
 
36
+ COMMON_FILES = %w[CHANGELOG COPYING.md copyright.md Gemfile
37
+ gravaty.gemspec gravaty.odp gravaty.pdf Rakefile README.md]
38
+
26
39
  Gem::Specification.new do |a_gem|
27
40
  a_gem.name = 'gravaty'
28
41
  a_gem.version = Gravaty::VERSION
29
42
  a_gem.license = 'GPL-3.0'
30
- a_gem.licenses = %w(GPL-3.0 BSD-3-Clause)
43
+ a_gem.licenses = %w[GPL-3.0 BSD-3-Clause]
31
44
  a_gem.author = 'Marco Bresciani'
32
45
  a_gem.authors = ['Marco Bresciani', '新部裕', 'Peter R. Marreck',
33
46
  'Jon Maken', 'Łukasz Niemier']
34
47
  a_gem.email = 'marcobresciani_1974@libero.it'
35
- a_gem.homepage = 'https://savannah.nongnu.org/projects/gravaty/'
48
+ a_gem.homepage = "https://savannah.nongnu.org/projects/#{a_gem.name}/"
36
49
  a_gem.summary = SUMMARY
37
- a_gem.description = "#{SUMMARY} It's my first 'real' Ruby gem, hoping
38
- it will be useful for someone (let me know if you use it, please!).
39
- GNU GPLv3 license; source code available through anonymous checkout:
40
- hg clone http://hg.savannah.nongnu.org/hgweb/gravaty/ or write me and
41
- I'll send it. You can even decide to contribute to this little free
42
- software project by registering to Savannah and ask to be part of the
43
- 'gravaty' project! With contributions from: 新部裕, Peter R. Marreck,
44
- Jon Maken, Łukasz Niemier."
45
-
46
- COMMON_FILES = %w(acknowledgements.md authors.md CHANGELOG COPYING.md
47
- copyright.md Gemfile gravaty.gemspec gravaty.odp gravaty.pdf ISSUES.md
48
- Rakefile README.md)
50
+ a_gem.description = "#{SUMMARY} It's my first Ruby gem, hoping it will
51
+ be useful for someone (let me know if you use it, please!).
52
+ GNU GPLv3 license; source code available through anonymous checkout: `hg
53
+ clone http://hg.savannah.nongnu.org/hgweb/#{a_gem.name}/` or write me
54
+ and I'll send it.
55
+ You can even decide to contribute to this little free software project
56
+ by registering to Savannah and ask to be part of the '#{a_gem.name}'
57
+ project!
58
+ With contributions from: 新部裕, Peter R. Marreck, Jon Maken, Łukasz
59
+ Niemier."
60
+ a_gem.metadata = {
61
+ 'homepage_uri' => "https://savannah.nongnu.org/projects/#{a_gem.name}",
62
+ 'changelog_uri' => "http://hg.savannah.nongnu.org/hgweb/#{a_gem.name}/file/tip/CHANGELOG",
63
+ 'source_code_uri' => "http://hg.savannah.nongnu.org/hgweb/#{a_gem.name}/file/",
64
+ 'bug_tracker_uri' => "https://savannah.nongnu.org/bugs/?group=#{a_gem.name}",
65
+ 'documentation_uri' => "http://hg.savannah.nongnu.org/hgweb/#{a_gem.name}/tag/#{a_gem.version}/"
66
+ # 'mailing_list_uri' => 'https://groups.example.com/bestgemever',
67
+ # 'wiki_uri' => 'https://example.com/user/bestgemever/wiki'
68
+ }
49
69
 
50
70
  a_gem.files = Dir.glob('{examples,html,lib,test}/**/*') + COMMON_FILES
51
71
  a_gem.test_files = Dir.glob('test/**/test_*.rb')
52
72
  a_gem.require_path = 'lib'
53
- a_gem.require_paths = %w(lib)
73
+ a_gem.require_paths = %w[lib]
54
74
  a_gem.extra_rdoc_files = COMMON_FILES
55
75
 
56
- a_gem.required_ruby_version = '~> 2.7'
76
+ a_gem.required_ruby_version = '~> 3.0'
57
77
  a_gem.rubygems_version = '~> 3.0'
58
78
 
59
79
  a_gem.add_runtime_dependency 'i18n', '~>1.8'
60
- a_gem.add_runtime_dependency 'json', '~>2.3'
61
- a_gem.add_runtime_dependency 'xmlrpc', '~>0.3.0'
80
+ a_gem.add_runtime_dependency 'json', '~>2.5'
81
+ a_gem.add_runtime_dependency 'xmlrpc', '~>0.3.1'
62
82
 
63
83
  a_gem.add_development_dependency 'bundler', '~>2.1'
64
84
  a_gem.add_development_dependency 'minitest', '~>5.14'
65
85
  a_gem.add_development_dependency 'rake', '~>13.0'
66
- a_gem.add_development_dependency 'rdoc', '~>6.2'
67
- a_gem.add_development_dependency 'simplecov', '~>0.18'
86
+ a_gem.add_development_dependency 'rdoc', '~>6.3'
87
+ a_gem.add_development_dependency 'rubocop', '~>1.8'
88
+ a_gem.add_development_dependency 'simplecov', '~>0.21'
68
89
 
69
90
  a_gem.requirements = a_gem.required_ruby_version.to_s, a_gem.dependencies.to_s
70
91
 
71
- begin
92
+ a_gem.post_install_message = begin
72
93
  require 'changelog'
73
94
  rescue LoadError
74
- a_gem.post_install_message = "Thank you for using #{a_gem.name} version #{a_gem.version}."
75
- else
76
- a_gem.post_install_message = CHANGELOG.new.version_changes
95
+ "Thank you for using #{a_gem.name} version #{a_gem.version}."
96
+ else
97
+ CHANGELOG.new.version_changes
77
98
  end
78
99
  end