gravaty 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gravaty might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG +587 -0
- data/COPYING.md +234 -0
- data/Gemfile +17 -0
- data/ISSUES.md +40 -0
- data/README.md +128 -0
- data/Rakefile +48 -0
- data/acknowledgements.md +40 -0
- data/authors.md +44 -0
- data/copyright.md +339 -0
- data/examples/avatar.rb +121 -0
- data/examples/basics.rb +60 -0
- data/examples/profile.rb +143 -0
- data/examples/xmlrpc.rb +33 -0
- data/gravaty.gemspec +59 -0
- data/gravaty.odp +0 -0
- data/gravaty.pdf +0 -0
- data/html/CHANGELOG.html +876 -0
- data/html/COPYING_md.html +803 -0
- data/html/Gemfile.html +114 -0
- data/html/Gravaty.html +322 -0
- data/html/Gravaty/Gravaty.html +997 -0
- data/html/Gravaty/ParsableDuckType.html +158 -0
- data/html/Gravaty/Parser.html +233 -0
- data/html/Gravaty/Parsers.html +94 -0
- data/html/Gravaty/Parsers/Avatar.html +166 -0
- data/html/Gravaty/Parsers/Callback.html +167 -0
- data/html/Gravaty/Parsers/Default.html +174 -0
- data/html/Gravaty/Parsers/Force.html +167 -0
- data/html/Gravaty/Parsers/Format.html +177 -0
- data/html/Gravaty/Parsers/Pixelsize.html +177 -0
- data/html/Gravaty/Parsers/Rating.html +177 -0
- data/html/Gravaty/Parsers/Secure.html +166 -0
- data/html/Gravaty/Parsers/Type.html +177 -0
- data/html/Gravaty/Utils.html +107 -0
- data/html/Gravaty/Utils/Downloader.html +106 -0
- data/html/Gravaty/Utils/Downloader/Downloader.html +224 -0
- data/html/Gravaty/Utils/Raisers.html +199 -0
- data/html/Gravaty/Utils/Rfc5322.html +149 -0
- data/html/Gravaty/Utils/RpcConnector.html +106 -0
- data/html/Gravaty/Utils/RpcConnector/RpcConnector.html +241 -0
- data/html/ISSUES_md.html +165 -0
- data/html/Object.html +183 -0
- data/html/README_md.html +436 -0
- data/html/Rakefile.html +152 -0
- data/html/acknowledgements_md.html +172 -0
- data/html/authors_md.html +178 -0
- data/html/copyright_md.html +553 -0
- data/html/created.rid +59 -0
- data/html/css/fonts.css +167 -0
- data/html/css/rdoc.css +590 -0
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/gravaty_gemspec.html +162 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +467 -0
- data/html/js/darkfish.js +161 -0
- data/html/js/jquery.js +4 -0
- data/html/js/navigation.js +142 -0
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +109 -0
- data/html/js/search_index.js +1 -0
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +229 -0
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +479 -0
- data/lib/gravaty.rb +59 -0
- data/lib/gravaty/application.rb +272 -0
- data/lib/gravaty/constants.rb +53 -0
- data/lib/gravaty/locales/en.yml +34 -0
- data/lib/gravaty/locales/it.yml +34 -0
- data/lib/gravaty/locales/ja.yml +35 -0
- data/lib/gravaty/parser.rb +41 -0
- data/lib/gravaty/parsers/avatar.rb +33 -0
- data/lib/gravaty/parsers/callback.rb +34 -0
- data/lib/gravaty/parsers/default.rb +79 -0
- data/lib/gravaty/parsers/force.rb +33 -0
- data/lib/gravaty/parsers/format.rb +38 -0
- data/lib/gravaty/parsers/pixelsize.rb +38 -0
- data/lib/gravaty/parsers/rating.rb +38 -0
- data/lib/gravaty/parsers/secure.rb +32 -0
- data/lib/gravaty/parsers/type.rb +38 -0
- data/lib/gravaty/utils/downloader.rb +150 -0
- data/lib/gravaty/utils/raisers.rb +50 -0
- data/lib/gravaty/utils/rfc5322.rb +102 -0
- data/lib/gravaty/utils/rpc_connector.rb +71 -0
- data/lib/gravaty/version.rb +20 -0
- data/test/gravaty/locales/test_locales.rb +61 -0
- data/test/gravaty/parsers/test_avatar.rb +35 -0
- data/test/gravaty/parsers/test_callback.rb +37 -0
- data/test/gravaty/parsers/test_default.rb +69 -0
- data/test/gravaty/parsers/test_force.rb +35 -0
- data/test/gravaty/parsers/test_format.rb +48 -0
- data/test/gravaty/parsers/test_pixelsize.rb +50 -0
- data/test/gravaty/parsers/test_rating.rb +48 -0
- data/test/gravaty/parsers/test_secure.rb +35 -0
- data/test/gravaty/parsers/test_type.rb +37 -0
- data/test/gravaty/test_application.rb +111 -0
- data/test/gravaty/test_avatar.rb +115 -0
- data/test/gravaty/test_parsable_duck_type.rb +31 -0
- data/test/gravaty/test_parser.rb +55 -0
- data/test/gravaty/test_profile.rb +63 -0
- data/test/gravaty/utils/test_downloader.rb +43 -0
- data/test/gravaty/utils/test_raisers.rb +55 -0
- data/test/gravaty/utils/test_rfc5322.rb +58 -0
- data/test/gravaty/utils/test_rpc_connector.rb +74 -0
- data/test/test_gravaty.rb +44 -0
- data/test/test_helper.rb +77 -0
- metadata +315 -0
@@ -0,0 +1,150 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
module Gravaty
|
18
|
+
module Utils
|
19
|
+
|
20
|
+
# This module is a simple wrapper container for Peter R. Marreck's gist.
|
21
|
+
#
|
22
|
+
# Author:: {Jon Maken}[mailto:jon.forums@gmail.com]
|
23
|
+
# License:: 3-clause BSD
|
24
|
+
# Revision:: 2012-03-25 23:01:19 -0600
|
25
|
+
module Downloader
|
26
|
+
|
27
|
+
require 'net/http'
|
28
|
+
require 'net/https' if RUBY_VERSION < '1.9'
|
29
|
+
require 'net/ftp'
|
30
|
+
require 'openssl'
|
31
|
+
require 'fileutils'
|
32
|
+
require 'tempfile'
|
33
|
+
|
34
|
+
#!/usr/bin/env ruby
|
35
|
+
#
|
36
|
+
# An HTTP/HTTPS/FTP file downloader library/CLI based upon MiniPortile's HTTP implementation.
|
37
|
+
#
|
38
|
+
# Author:: Jon Maken
|
39
|
+
# License:: 3-clause BSD
|
40
|
+
# Revision:: 2012-03-25 23:01:19 -0600
|
41
|
+
class Downloader
|
42
|
+
|
43
|
+
VERSION = '0.1.0'
|
44
|
+
|
45
|
+
class << self
|
46
|
+
attr_accessor :logger, :max_ca_verify_depth, :ftp_data_chunk_size
|
47
|
+
end
|
48
|
+
|
49
|
+
@logger = STDOUT.binmode
|
50
|
+
@max_ca_verify_depth = 5
|
51
|
+
@ftp_data_chunk_size = 8192
|
52
|
+
|
53
|
+
|
54
|
+
def self.download_file(url, full_path, count = 3)
|
55
|
+
raise RuntimeError, I18n.t('error.nil') if url.nil?
|
56
|
+
return if File.exist?(full_path)
|
57
|
+
|
58
|
+
http_download(url, full_path, count)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def self.message(text)
|
64
|
+
@logger.print text
|
65
|
+
@logger.flush
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.output(text = '')
|
69
|
+
@logger.puts text
|
70
|
+
@logger.flush
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.http_download(url, full_path, count)
|
74
|
+
uri = URI.parse(url)
|
75
|
+
|
76
|
+
begin
|
77
|
+
filename = File.basename(uri.path)
|
78
|
+
|
79
|
+
if ENV['HTTP_PROXY']
|
80
|
+
#protocol,
|
81
|
+
userinfo, proxy_host, proxy_port = URI::split(ENV['HTTP_PROXY'])
|
82
|
+
proxy_user, proxy_pass = userinfo.split(/:/) if userinfo
|
83
|
+
http = Net::HTTP.new(uri.host, uri.port, proxy_host, proxy_port, proxy_user, proxy_pass)
|
84
|
+
else
|
85
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
86
|
+
end
|
87
|
+
|
88
|
+
if uri.scheme.downcase == 'https'
|
89
|
+
http.use_ssl = true
|
90
|
+
if ENV['SSL_CERT_FILE']
|
91
|
+
cert_file = ENV['SSL_CERT_FILE'].dup
|
92
|
+
cert_file.gsub!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
|
93
|
+
end
|
94
|
+
if cert_file && File.exists?(cert_file)
|
95
|
+
http.ca_file = cert_file
|
96
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
97
|
+
http.verify_depth = @max_ca_verify_depth
|
98
|
+
else
|
99
|
+
raise <<-EOT
|
100
|
+
To download using HTTPS you must first set the SSL_CERT_FILE
|
101
|
+
environment variable to the path of a valid CA certificate file.
|
102
|
+
A file of bundled public CA certs may be downloaded from:
|
103
|
+
|
104
|
+
http://curl.haxx.se/ca/cacert.pem
|
105
|
+
|
106
|
+
EOT
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
http.request_get(uri) do |response|
|
111
|
+
case response
|
112
|
+
when Net::HTTPNotFound
|
113
|
+
output '404 - Not Found'
|
114
|
+
return false
|
115
|
+
|
116
|
+
when Net::HTTPClientError
|
117
|
+
output "Error: Client Error: #{response.inspect}"
|
118
|
+
return false
|
119
|
+
|
120
|
+
when Net::HTTPRedirection
|
121
|
+
raise 'Too many redirections for the original URL, halting.' if count <= 0
|
122
|
+
url = response['location']
|
123
|
+
return http_download(url, full_path, count - 1)
|
124
|
+
|
125
|
+
when Net::HTTPOK
|
126
|
+
temp_file = Tempfile.new("download-#{filename}")
|
127
|
+
temp_file.binmode
|
128
|
+
temp_file << response.body
|
129
|
+
|
130
|
+
output
|
131
|
+
|
132
|
+
temp_file.close
|
133
|
+
File.unlink full_path if File.exists?(full_path)
|
134
|
+
FileUtils.mkdir_p File.dirname(full_path)
|
135
|
+
FileUtils.mv temp_file.path, full_path, :force => true
|
136
|
+
else
|
137
|
+
puts response
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
rescue Exception => e
|
142
|
+
File.unlink full_path if File.exists?(full_path)
|
143
|
+
output "ERROR: #{e.message}"
|
144
|
+
raise 'Failed to download file'
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end # Downloader
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require 'i18n'
|
18
|
+
|
19
|
+
module Gravaty
|
20
|
+
|
21
|
+
# This module is a simple collection of useful things and methods that I prefer to keep as DRYer as possible. Just include it and use the methods...
|
22
|
+
#
|
23
|
+
# Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
|
24
|
+
# Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
25
|
+
# License:: GNU General Public License version 3
|
26
|
+
module Utils
|
27
|
+
|
28
|
+
# This module contains some utility method to raise errors according to (possibly) common conditions.
|
29
|
+
#
|
30
|
+
# Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
|
31
|
+
# Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
32
|
+
# License:: GNU General Public License version 3
|
33
|
+
module Raisers
|
34
|
+
|
35
|
+
# Raises an +ArgumentError+ according to parameters, unless the +array+ contains a downcased +value+.
|
36
|
+
def raiser_downcase(name = 'error.value', value = nil, array = nil)
|
37
|
+
unless value.nil?
|
38
|
+
raise ArgumentError, I18n.t(name, value: value) unless array.include? value.downcase
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Raises an +ArgumentError+ according to parameters, unless the +array+ contains the number of the +value+.
|
43
|
+
def raiser_to_i(name = 'error.value', value = nil, array = nil)
|
44
|
+
unless value.nil?
|
45
|
+
raise ArgumentError, I18n.t(name, value: value) unless array.include? value.to_i
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
module Gravaty
|
18
|
+
module Utils
|
19
|
+
# This module is a simple wrapper container for Peter R. Marreck's gist.
|
20
|
+
#
|
21
|
+
# Author:: {Peter R. Marreck}[mailto:lumbergh@gmail.com]
|
22
|
+
# Copyright:: Copyleft (©) 2013, Peter R. Marreck
|
23
|
+
# License:: This work is released under the BSD 3-Clause License http://choosealicense.com/licenses/bsd-3-clause/
|
24
|
+
module Rfc5322
|
25
|
+
|
26
|
+
# Author:: {Peter R. Marreck}[mailto:lumbergh@gmail.com]
|
27
|
+
# Copyright:: Copyleft (©) 2013, Peter R. Marreck
|
28
|
+
# License:: This work is released under the BSD 3-Clause License http://choosealicense.com/licenses/bsd-3-clause/
|
29
|
+
|
30
|
+
# RFC 5322 Email Validation Regex in Ruby
|
31
|
+
|
32
|
+
# This work is released under the BSD 3-Clause License
|
33
|
+
# http://choosealicense.com/licenses/bsd-3-clause/
|
34
|
+
# Copyleft (©) 2013, Peter R. Marreck
|
35
|
+
# All rights reserved.
|
36
|
+
#
|
37
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
38
|
+
# are permitted provided that the following conditions are met:
|
39
|
+
#
|
40
|
+
# Redistributions of source code must retain the above copyright notice, this
|
41
|
+
# list of conditions and the following disclaimer.
|
42
|
+
#
|
43
|
+
# Redistributions in binary form must reproduce the above copyright notice, this
|
44
|
+
# list of conditions and the following disclaimer in the documentation and/or
|
45
|
+
# other materials provided with the distribution.
|
46
|
+
#
|
47
|
+
# Neither the name of the {organization} nor the names of its
|
48
|
+
# contributors may be used to endorse or promote products derived from
|
49
|
+
# this software without specific prior written permission.
|
50
|
+
#
|
51
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
52
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
53
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
54
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
55
|
+
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
56
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
57
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
58
|
+
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
59
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
60
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
61
|
+
|
62
|
+
EMAIL = /
|
63
|
+
(?<addr_spec> (?> \g<local_part> @ \g<domain> ) ){0}
|
64
|
+
(?<local_part> (?> \g<dot_atom> | \g<quoted_string> | \g<obs_local_part> ) ){0}
|
65
|
+
(?<domain> (?> \g<dot_atom> | \g<domain_literal> | \g<obs_domain> ) ){0}
|
66
|
+
(?<domain_literal> (?> \g<CFWS>? \[ (?: \g<FWS>? \g<dtext> )* \g<FWS>? \] \g<CFWS>? ) ){0}
|
67
|
+
(?<dtext> (?> [\x21-\x5a] | [\x5e-\x7e] | \g<obs_dtext> ) ){0}
|
68
|
+
(?<quoted_pair> (?> \\ (?: \g<VCHAR> | \g<WSP> ) | \g<obs_qp> ) ){0}
|
69
|
+
(?<dot_atom> (?> \g<CFWS>? \g<dot_atom_text> \g<CFWS>? ) ){0}
|
70
|
+
(?<dot_atom_text> (?> \g<atext> (?: \. \g<atext> )* ) ){0}
|
71
|
+
(?<atext> (?> [a-zA-Z0-9!\#\$%&'*\+\/\=\?\^_`{\|}~\-]+ ) ){0}
|
72
|
+
(?<atom> (?> \g<CFWS>? \g<atext> \g<CFWS>? ) ){0}
|
73
|
+
(?<word> (?> \g<atom> | \g<quoted_string> ) ){0}
|
74
|
+
(?<quoted_string> (?> \g<CFWS>? " (?: \g<FWS>? \g<qcontent> )* \g<FWS>? " \g<CFWS>? ) ){0}
|
75
|
+
(?<qcontent> (?> \g<qtext> | \g<quoted_pair> ) ){0}
|
76
|
+
(?<qtext> (?> \x21 | [\x23-\x5b] | [\x5d-\x7e] | \g<obs_qtext> ) ){0}
|
77
|
+
|
78
|
+
# comments and whitespace
|
79
|
+
(?<FWS> (?> (?: \g<WSP>* \r\n )? \g<WSP>+ | \g<obs_FWS> ) ){0}
|
80
|
+
(?<CFWS> (?> (?: \g<FWS>? \g<comment> )+ \g<FWS>? | \g<FWS> ) ){0}
|
81
|
+
(?<comment> (?> \( (?: \g<FWS>? \g<ccontent> )* \g<FWS>? \) ) ){0}
|
82
|
+
(?<ccontent> (?>\g<ctext> | \g<quoted_pair> | \g<comment> ) ){0}
|
83
|
+
(?<ctext> (?> [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | \g<obs_ctext> ) ){0}
|
84
|
+
|
85
|
+
# obsolete tokens
|
86
|
+
(?<obs_domain> (?> \g<atom> (?: \. \g<atom> )* ) ){0}
|
87
|
+
(?<obs_local_part> (?> \g<word> (?: \. \g<word> )* ) ){0}
|
88
|
+
(?<obs_dtext> (?> \g<obs_NO_WS_CTL> | \g<quoted_pair> ) ){0}
|
89
|
+
(?<obs_qp> (?> \\ (?: \x00 | \g<obs_NO_WS_CTL> | \n | \r ) ) ){0}
|
90
|
+
(?<obs_FWS> (?> \g<WSP>+ (?: \r\n \g<WSP>+ )* ) ){0}
|
91
|
+
(?<obs_ctext> (?> \g<obs_NO_WS_CTL> ) ){0}
|
92
|
+
(?<obs_qtext> (?> \g<obs_NO_WS_CTL> ) ){0}
|
93
|
+
(?<obs_NO_WS_CTL> (?> [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ) ){0}
|
94
|
+
|
95
|
+
# character class definitions
|
96
|
+
(?<VCHAR> (?> [\x21-\x7E] ) ){0}
|
97
|
+
(?<WSP> [ \t] ){0}
|
98
|
+
\g<addr_spec>
|
99
|
+
/uix
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require 'i18n'
|
18
|
+
|
19
|
+
require_relative 'raisers'
|
20
|
+
|
21
|
+
module Gravaty
|
22
|
+
module Utils
|
23
|
+
|
24
|
+
# This module contains the XML-RPC connector class.
|
25
|
+
#
|
26
|
+
# Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
|
27
|
+
# Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
28
|
+
# License:: GNU General Public License version 3
|
29
|
+
module RpcConnector
|
30
|
+
|
31
|
+
# Creates a +RpcConnector+ described by the user's email +digest+ and a +password+. Throws a +ArgumentError+ if the supplied +digest+ or the +password+ are not valid.
|
32
|
+
#
|
33
|
+
# Usage::
|
34
|
+
# - <tt>rpc_connector = RpcConnector.new digest, passowrd</tt>
|
35
|
+
# Params::
|
36
|
+
# - +digest+, the user's email address MD5 digest.
|
37
|
+
# - +password+, the user's Gravatar account password.
|
38
|
+
# Returns:: a +RcpConnector+ object for the specified email +digest+.
|
39
|
+
# Raises:: +ArgumentError+, if any of the supplied parameters are not valid.
|
40
|
+
class RpcConnector
|
41
|
+
include Gravaty::Utils::Raisers
|
42
|
+
|
43
|
+
def initialize(digest, password = nil)
|
44
|
+
I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../locales/', '*.yml')]
|
45
|
+
|
46
|
+
raise ArgumentError, I18n.t('error.nil') if digest.nil? or digest.empty?
|
47
|
+
raise ArgumentError, I18n.t('error.nil') if password.nil? or password.empty?
|
48
|
+
|
49
|
+
@digest = digest
|
50
|
+
@connector = XMLRPC::Client.new(RPC_URI, build_rpc_path, 443, nil, nil, nil, nil, true)
|
51
|
+
|
52
|
+
@params = Hash.new
|
53
|
+
@params[:password] = password
|
54
|
+
end
|
55
|
+
|
56
|
+
def call(a_method = RPC_TEST_METHOD, params = {})
|
57
|
+
raiser_downcase 'error.value', a_method, RPC_METHODS
|
58
|
+
|
59
|
+
@connector.call a_method, @params.merge(params)
|
60
|
+
end
|
61
|
+
|
62
|
+
# ------------------------------------------------------------------------------ here starts the list of private methods
|
63
|
+
private
|
64
|
+
|
65
|
+
def build_rpc_path
|
66
|
+
"/xmlrpc?user=#{@digest}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
module Gravaty
|
18
|
+
# Current version number for Gravaty gem.
|
19
|
+
VERSION = '8.0.0'
|
20
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
|
4
|
+
#
|
5
|
+
# This file is part of gravaty.
|
6
|
+
#
|
7
|
+
# gravaty is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
11
|
+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
|
14
|
+
# <http://www.gnu.org/licenses/>.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require_relative '../../test_helper'
|
18
|
+
|
19
|
+
describe Gravaty::Gravaty do
|
20
|
+
describe 'when using I18N' do
|
21
|
+
|
22
|
+
RELATIVE_PATH = '/../../../lib/gravaty/locales/'
|
23
|
+
|
24
|
+
before do
|
25
|
+
I18n.load_path = Dir[File.join(File.dirname(__FILE__), RELATIVE_PATH, '*.yml')]
|
26
|
+
end
|
27
|
+
|
28
|
+
subject { I18n.available_locales }
|
29
|
+
|
30
|
+
it 'shall return at least one available locale' do
|
31
|
+
subject.wont_be_nil
|
32
|
+
subject.wont_be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'shall contain at least English and Italiano' do
|
36
|
+
subject.must_include :en
|
37
|
+
subject.must_include :it
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'shall contain a test.test signpost for each available locale' do
|
41
|
+
def load_yaml_file(locale)
|
42
|
+
filename = File::join(File::dirname(__FILE__), RELATIVE_PATH, "#{locale}" + '.yml')
|
43
|
+
filename = File::expand_path filename
|
44
|
+
YAML::load(File::open "#{filename}")
|
45
|
+
end
|
46
|
+
|
47
|
+
subject.each do |locale|
|
48
|
+
I18n.locale = locale
|
49
|
+
|
50
|
+
translation = load_yaml_file(locale)
|
51
|
+
translation["#{locale}"]['test']['test'].wont_be_nil
|
52
|
+
|
53
|
+
a_string = I18n.t('test.test')
|
54
|
+
a_string.wont_be_nil
|
55
|
+
a_string.wont_be_empty
|
56
|
+
a_string.wont_include 'translation missing'
|
57
|
+
a_string.must_equal translation["#{locale}"]['test']['test']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|