gravaty 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +835 -0
- data/COPYING.md +675 -0
- data/Gemfile +21 -0
- data/ISSUES.md +62 -0
- data/README.md +287 -0
- data/Rakefile +52 -0
- data/acknowledgements.md +66 -0
- data/authors.md +63 -0
- data/copyright.md +468 -0
- data/examples/avatar.rb +159 -0
- data/examples/basics.rb +75 -0
- data/examples/cacert.pem +3401 -0
- data/examples/profile.rb +187 -0
- data/examples/xmlrpc.rb +41 -0
- data/gravaty.gemspec +78 -0
- data/gravaty.odp +0 -0
- data/gravaty.pdf +0 -0
- data/html/CHANGELOG.html +1117 -0
- data/html/COPYING_md.html +393 -0
- data/html/Gemfile.html +108 -0
- data/html/Gravaty/Gravaty.html +1002 -0
- data/html/Gravaty/ParsableDuckType.html +162 -0
- data/html/Gravaty/Parser.html +239 -0
- data/html/Gravaty/Parsers/Avatar.html +169 -0
- data/html/Gravaty/Parsers/Callback.html +170 -0
- data/html/Gravaty/Parsers/Default.html +178 -0
- data/html/Gravaty/Parsers/Force.html +170 -0
- data/html/Gravaty/Parsers/Format.html +181 -0
- data/html/Gravaty/Parsers/Pixelsize.html +181 -0
- data/html/Gravaty/Parsers/Rating.html +181 -0
- data/html/Gravaty/Parsers/Secure.html +169 -0
- data/html/Gravaty/Parsers/Type.html +181 -0
- data/html/Gravaty/Parsers.html +96 -0
- data/html/Gravaty/Utils/Downloader/Downloader.html +227 -0
- data/html/Gravaty/Utils/Downloader.html +108 -0
- data/html/Gravaty/Utils/Raisers.html +203 -0
- data/html/Gravaty/Utils/Rfc5322.html +139 -0
- data/html/Gravaty/Utils/RpcConnector/RpcConnector.html +248 -0
- data/html/Gravaty/Utils/RpcConnector.html +111 -0
- data/html/Gravaty/Utils.html +111 -0
- data/html/Gravaty.html +320 -0
- data/html/ISSUES_md.html +165 -0
- data/html/Object.html +187 -0
- data/html/README_md.html +276 -0
- data/html/Rakefile.html +141 -0
- data/html/acknowledgements_md.html +160 -0
- data/html/authors_md.html +173 -0
- data/html/copyright_md.html +481 -0
- data/html/created.rid +59 -0
- data/html/css/fonts.css +167 -0
- data/html/css/rdoc.css +590 -0
- data/html/examples/cacert_pem.html +1056 -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 +169 -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 +308 -0
- data/html/js/darkfish.js +161 -0
- data/html/js/jquery.js +4 -0
- data/html/js/navigation.js +141 -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 +995 -0
- data/lib/gravaty/application.rb +354 -0
- data/lib/gravaty/constants.rb +65 -0
- data/lib/gravaty/locales/en.yml +38 -0
- data/lib/gravaty/locales/it.yml +38 -0
- data/lib/gravaty/locales/ja.yml +39 -0
- data/lib/gravaty/parser.rb +50 -0
- data/lib/gravaty/parsers/avatar.rb +40 -0
- data/lib/gravaty/parsers/callback.rb +41 -0
- data/lib/gravaty/parsers/default.rb +92 -0
- data/lib/gravaty/parsers/force.rb +40 -0
- data/lib/gravaty/parsers/format.rb +45 -0
- data/lib/gravaty/parsers/pixelsize.rb +45 -0
- data/lib/gravaty/parsers/rating.rb +45 -0
- data/lib/gravaty/parsers/secure.rb +39 -0
- data/lib/gravaty/parsers/type.rb +45 -0
- data/lib/gravaty/utils/downloader.rb +156 -0
- data/lib/gravaty/utils/raisers.rb +63 -0
- data/lib/gravaty/utils/rfc5322.rb +110 -0
- data/lib/gravaty/utils/rpc_connector.rb +86 -0
- data/lib/gravaty/version.rb +24 -0
- data/lib/gravaty.rb +75 -0
- data/test/gravaty/locales/test_locales.rb +69 -0
- data/test/gravaty/parsers/test_avatar.rb +39 -0
- data/test/gravaty/parsers/test_callback.rb +42 -0
- data/test/gravaty/parsers/test_default.rb +79 -0
- data/test/gravaty/parsers/test_force.rb +39 -0
- data/test/gravaty/parsers/test_format.rb +54 -0
- data/test/gravaty/parsers/test_pixelsize.rb +56 -0
- data/test/gravaty/parsers/test_rating.rb +54 -0
- data/test/gravaty/parsers/test_secure.rb +39 -0
- data/test/gravaty/parsers/test_type.rb +44 -0
- data/test/gravaty/test_application.rb +126 -0
- data/test/gravaty/test_avatar.rb +122 -0
- data/test/gravaty/test_parser.rb +59 -0
- data/test/gravaty/test_profile.rb +70 -0
- data/test/gravaty/utils/test_downloader.rb +51 -0
- data/test/gravaty/utils/test_raisers.rb +62 -0
- data/test/gravaty/utils/test_rfc5322.rb +82 -0
- data/test/gravaty/utils/test_rpc_connector.rb +82 -0
- data/test/test_gravaty.rb +48 -0
- data/test/test_helper.rb +105 -0
- metadata +348 -0
@@ -0,0 +1,86 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require 'i18n'
|
22
|
+
|
23
|
+
require_relative 'raisers'
|
24
|
+
|
25
|
+
module Gravaty
|
26
|
+
module Utils
|
27
|
+
|
28
|
+
# This module contains the XML-RPC connector class.
|
29
|
+
#
|
30
|
+
# Author:: {Marco Bresciani}[mailto:marcobresciani_1974@libero.it]
|
31
|
+
# Copyright:: Copyright © 2013, 2014, 2015, 2016, 2017, 2018,
|
32
|
+
# 2019 Marco Bresciani
|
33
|
+
# License:: GNU General Public License version 3
|
34
|
+
module RpcConnector
|
35
|
+
|
36
|
+
# Creates a +RpcConnector+ described by the user's email +digest+
|
37
|
+
# and a +password+. Throws a +ArgumentError+ if the supplied
|
38
|
+
# +digest+ or the +password+ are not valid.
|
39
|
+
#
|
40
|
+
# Usage::
|
41
|
+
# - <tt>rpc_connector = RpcConnector.new digest, passowrd</tt>
|
42
|
+
# Params::
|
43
|
+
# - +digest+, the user's email address MD5 digest.
|
44
|
+
# - +password+, the user's Gravatar account password.
|
45
|
+
# Returns:: a +RcpConnector+ object for the specified email
|
46
|
+
# +digest+.
|
47
|
+
# Raises:: +ArgumentError+, if any of the supplied parameters are
|
48
|
+
# not valid.
|
49
|
+
class RpcConnector
|
50
|
+
include Gravaty::Utils::Raisers
|
51
|
+
|
52
|
+
def initialize(digest, password = nil)
|
53
|
+
I18n.load_path =
|
54
|
+
Dir[File.join(File.dirname(__FILE__),
|
55
|
+
'/../locales/', '*.yml')]
|
56
|
+
|
57
|
+
raise ArgumentError, I18n.t('error.nil') if digest.nil? or
|
58
|
+
digest.empty?
|
59
|
+
raise ArgumentError, I18n.t('error.nil') if password.nil? or
|
60
|
+
password.empty?
|
61
|
+
|
62
|
+
@digest = digest
|
63
|
+
@connector = XMLRPC::Client.new(RPC_URI, build_rpc_path, 443,
|
64
|
+
nil, nil, nil, nil, true)
|
65
|
+
|
66
|
+
@params = Hash.new
|
67
|
+
@params[:password] = password
|
68
|
+
end
|
69
|
+
|
70
|
+
def call(a_method = RPC_TEST_METHOD, params = {})
|
71
|
+
raiser_downcase 'error.value', a_method, RPC_METHODS
|
72
|
+
|
73
|
+
@connector.call a_method, @params.merge(params)
|
74
|
+
end
|
75
|
+
|
76
|
+
# ------------------------------ here starts the list of private methods
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def build_rpc_path
|
81
|
+
"/xmlrpc?user=#{@digest}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
module Gravaty
|
22
|
+
# Current version number for Gravaty gem.
|
23
|
+
VERSION = '9.0.0'
|
24
|
+
end
|
data/lib/gravaty.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# gravaty
|
2
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani
|
3
|
+
#
|
4
|
+
# This file is part of gravaty.
|
5
|
+
#
|
6
|
+
# gravaty is free software: you can redistribute it and/or modify it
|
7
|
+
# under the terms of the GNU General Public License as published by the
|
8
|
+
# Free Software Foundation, either version 3 of the License, or (at your
|
9
|
+
# option) any later version.
|
10
|
+
#
|
11
|
+
# gravaty is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
13
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
14
|
+
# for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with gravaty. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'digest/md5'
|
20
|
+
require 'i18n'
|
21
|
+
require 'uri'
|
22
|
+
|
23
|
+
require_relative 'gravaty/application'
|
24
|
+
require_relative 'gravaty/parser'
|
25
|
+
require_relative 'gravaty/parsers/avatar'
|
26
|
+
require_relative 'gravaty/parsers/callback'
|
27
|
+
require_relative 'gravaty/parsers/default'
|
28
|
+
require_relative 'gravaty/parsers/force'
|
29
|
+
require_relative 'gravaty/parsers/format'
|
30
|
+
require_relative 'gravaty/parsers/pixelsize'
|
31
|
+
require_relative 'gravaty/parsers/rating'
|
32
|
+
require_relative 'gravaty/parsers/secure'
|
33
|
+
require_relative 'gravaty/parsers/type'
|
34
|
+
|
35
|
+
# Author:: {Marco Bresciani}[mailto:marcobresciani_1974@libero.it]
|
36
|
+
# Copyright:: Copyright © 2013, 2014, 2015, 2016, 2017, 2018,
|
37
|
+
# 2019 Marco Bresciani
|
38
|
+
# License:: GNU General Public License version 3
|
39
|
+
module Gravaty
|
40
|
+
|
41
|
+
# Creates a new Gravaty described by the user's +email+. Throws a
|
42
|
+
# <code>ArgumentError</code> exception if the supplied +email+ address
|
43
|
+
# is nil or not valid according to RFC5322.
|
44
|
+
#
|
45
|
+
# Usage::
|
46
|
+
# - <tt>new_gravaty = Gravaty::gravatize email</tt>
|
47
|
+
# - <tt>new_gravaty = Gravaty::gravatize(email)</tt>
|
48
|
+
# Params:: +email_address+, the user's email address (a syntactically
|
49
|
+
# valid one).
|
50
|
+
# Returns:: a +Gravaty+ object for the specified +email+ address.
|
51
|
+
# Raises:: +ArgumentError+, if the supplied +email+ address is +nil+
|
52
|
+
# or not valid according to RFC 5322.
|
53
|
+
def self.gravatize(email_address)
|
54
|
+
Gravaty.new email_address, parser
|
55
|
+
end
|
56
|
+
|
57
|
+
# ------------------------------ here starts the list of private methods
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
# Provides the parameters' parsers object.
|
62
|
+
def self.parser
|
63
|
+
parsers = {avatar: Parsers::Avatar.new,
|
64
|
+
callback: Parsers::Callback.new,
|
65
|
+
default: Parsers::Default.new,
|
66
|
+
force: Parsers::Force.new,
|
67
|
+
format: Parsers::Format.new,
|
68
|
+
pixelsize: Parsers::Pixelsize.new,
|
69
|
+
rating: Parsers::Rating.new,
|
70
|
+
secure: Parsers::Secure.new,
|
71
|
+
type: Parsers::Type.new}
|
72
|
+
|
73
|
+
Parser.new parsers
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require_relative '../../test_helper'
|
22
|
+
|
23
|
+
describe Gravaty::Gravaty do
|
24
|
+
describe 'when using I18N' do
|
25
|
+
|
26
|
+
RELATIVE_PATH = '/../../../lib/gravaty/locales/'
|
27
|
+
|
28
|
+
before do
|
29
|
+
I18n.load_path = Dir[File.join(File
|
30
|
+
.dirname(__FILE__),
|
31
|
+
RELATIVE_PATH, '*.yml')]
|
32
|
+
end
|
33
|
+
|
34
|
+
subject {I18n.available_locales}
|
35
|
+
|
36
|
+
it 'shall return at least one available locale' do
|
37
|
+
subject.wont_be_nil
|
38
|
+
subject.wont_be_empty
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'shall contain at least English and Italiano' do
|
42
|
+
subject.must_include :en
|
43
|
+
subject.must_include :it
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'shall contain a test.test signpost for each available locale' do
|
47
|
+
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
|
+
end
|
54
|
+
|
55
|
+
subject.each do |locale|
|
56
|
+
I18n.locale = locale
|
57
|
+
|
58
|
+
translation = load_yaml_file(locale)
|
59
|
+
translation["#{locale}"]['test']['test'].wont_be_nil
|
60
|
+
|
61
|
+
a_string = I18n.t('test.test')
|
62
|
+
a_string.wont_be_nil
|
63
|
+
a_string.wont_be_empty
|
64
|
+
a_string.wont_include 'translation missing'
|
65
|
+
a_string.must_equal translation["#{locale}"]['test']['test']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require_relative '../../test_helper'
|
22
|
+
|
23
|
+
describe Gravaty::Gravaty do
|
24
|
+
describe 'when using a parser' do
|
25
|
+
include Gravaty::ParsableDuckType
|
26
|
+
|
27
|
+
before do
|
28
|
+
@parser = subject
|
29
|
+
end
|
30
|
+
|
31
|
+
subject {Gravaty::Parsers::Avatar.new}
|
32
|
+
|
33
|
+
[['avatar/', true], ['', false]].each do |pair|
|
34
|
+
it "shall return '#{pair[0]}' when parameter is '#{pair[1]}'" do
|
35
|
+
subject.parse(pair[1]).must_equal pair[0]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require_relative '../../test_helper'
|
22
|
+
|
23
|
+
describe Gravaty::Gravaty do
|
24
|
+
describe 'when using a parser' do
|
25
|
+
include Gravaty::ParsableDuckType
|
26
|
+
|
27
|
+
before do
|
28
|
+
@parser = subject
|
29
|
+
end
|
30
|
+
|
31
|
+
subject {Gravaty::Parsers::Callback.new}
|
32
|
+
|
33
|
+
%w(test sample_callback).each do |value|
|
34
|
+
[[nil, ''], ['', ''], %W(#{value} callback=#{value})]
|
35
|
+
.each do |pair|
|
36
|
+
it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
|
37
|
+
subject.parse(pair[0]).must_equal pair[1]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require 'cgi'
|
22
|
+
|
23
|
+
require_relative '../../test_helper'
|
24
|
+
|
25
|
+
describe Gravaty::Gravaty do
|
26
|
+
describe 'when using a parser' do
|
27
|
+
include Gravaty::ParsableDuckType
|
28
|
+
|
29
|
+
before do
|
30
|
+
I18n.load_path = Dir[File.join(
|
31
|
+
File.dirname(__FILE__),
|
32
|
+
'/../../../lib/gravaty/locales/', '*.yml')]
|
33
|
+
@parser = subject
|
34
|
+
end
|
35
|
+
|
36
|
+
subject {Gravaty::Parsers::Default.new}
|
37
|
+
|
38
|
+
Gravaty::DEFAULT_OPTIONS.each do |value|
|
39
|
+
[[nil, ''], ['', ''], %W(#{value} d=#{value})].each do |pair|
|
40
|
+
it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
|
41
|
+
subject.parse(pair[0]).must_equal pair[1]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Gravaty::IMAGES_FORMATS.each do |extension|
|
47
|
+
value = "http://www.example.com/images/example.#{extension}"
|
48
|
+
escaped = "d=#{CGI::escape(value)}"
|
49
|
+
|
50
|
+
it "shall return '#{escaped}' when parameter is '#{value}'" do
|
51
|
+
subject.parse(value).must_equal escaped
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'with invalid default URI image URI' do
|
56
|
+
it 'shall raise exception' do
|
57
|
+
begin
|
58
|
+
subject.parse('http://www.example.com/images/example.svg')
|
59
|
+
.must_raise ArgumentError
|
60
|
+
rescue ArgumentError => aErr
|
61
|
+
aErr.wont_be_nil
|
62
|
+
aErr.message.wont_be_nil
|
63
|
+
aErr.message.wont_be_empty
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'shall raise exception' do
|
68
|
+
begin
|
69
|
+
subject.parse('svg').must_raise ArgumentError
|
70
|
+
rescue ArgumentError => aErr
|
71
|
+
aErr.wont_be_nil
|
72
|
+
aErr.message.wont_be_nil
|
73
|
+
aErr.message.wont_be_empty
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require_relative '../../test_helper'
|
22
|
+
|
23
|
+
describe Gravaty::Gravaty do
|
24
|
+
describe 'when using a parser' do
|
25
|
+
include Gravaty::ParsableDuckType
|
26
|
+
|
27
|
+
before do
|
28
|
+
@parser = subject
|
29
|
+
end
|
30
|
+
|
31
|
+
subject {Gravaty::Parsers::Force.new}
|
32
|
+
|
33
|
+
[['f=y', true], ['', false]].each do |pair|
|
34
|
+
it "shall return '#{pair[0]}' when parameter is '#{pair[1]}'" do
|
35
|
+
subject.parse(pair[1]).must_equal pair[0]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require_relative '../../test_helper'
|
22
|
+
|
23
|
+
describe Gravaty::Gravaty do
|
24
|
+
describe 'when using a parser' do
|
25
|
+
include Gravaty::ParsableDuckType
|
26
|
+
|
27
|
+
before do
|
28
|
+
I18n.load_path = Dir[File.join(
|
29
|
+
File.dirname(__FILE__),
|
30
|
+
'/../../../lib/gravaty/locales/', '*.yml')]
|
31
|
+
@parser = subject
|
32
|
+
end
|
33
|
+
|
34
|
+
subject {Gravaty::Parsers::Format.new}
|
35
|
+
|
36
|
+
Gravaty::PROFILE_FORMATS.each do |value|
|
37
|
+
[[nil, ''], %W(#{value} .#{value.downcase})].each do |pair|
|
38
|
+
it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
|
39
|
+
subject.parse(pair[0]).must_equal pair[1]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'shall raise exception with invalid default image extension' do
|
45
|
+
begin
|
46
|
+
subject.parse('svg').must_raise ArgumentError
|
47
|
+
rescue ArgumentError => aErr
|
48
|
+
aErr.wont_be_nil
|
49
|
+
aErr.message.wont_be_nil
|
50
|
+
aErr.message.wont_be_empty
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require_relative '../../test_helper'
|
22
|
+
|
23
|
+
describe Gravaty::Gravaty do
|
24
|
+
describe 'when using a parser' do
|
25
|
+
include Gravaty::ParsableDuckType
|
26
|
+
|
27
|
+
before do
|
28
|
+
I18n.load_path = Dir[File.join(
|
29
|
+
File.dirname(__FILE__),
|
30
|
+
'/../../../lib/gravaty/locales/', '*.yml')]
|
31
|
+
@parser = subject
|
32
|
+
end
|
33
|
+
|
34
|
+
subject {Gravaty::Parsers::Pixelsize.new}
|
35
|
+
|
36
|
+
it 'shall return nothing when parameter is nil' do
|
37
|
+
subject.parse(nil).must_be_empty
|
38
|
+
end
|
39
|
+
|
40
|
+
Gravaty::ALLOWED_SIZES.each do |value|
|
41
|
+
it "shall return s='#{value.to_s}' when parameter is '#{value}'" do
|
42
|
+
subject.parse(value).must_equal "s=#{value.to_s}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'shall raise an exception when provided with invalid rating' do
|
47
|
+
begin
|
48
|
+
subject.parse(0).must_raise ArgumentError
|
49
|
+
rescue ArgumentError => aErr
|
50
|
+
aErr.wont_be_nil
|
51
|
+
aErr.message.wont_be_nil
|
52
|
+
aErr.message.wont_be_empty
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require_relative '../../test_helper'
|
22
|
+
|
23
|
+
describe Gravaty::Gravaty do
|
24
|
+
describe 'when using a parser' do
|
25
|
+
include Gravaty::ParsableDuckType
|
26
|
+
|
27
|
+
before do
|
28
|
+
I18n.load_path = Dir[File.join(
|
29
|
+
File.dirname(__FILE__),
|
30
|
+
'/../../../lib/gravaty/locales/', '*.yml')]
|
31
|
+
@parser = subject
|
32
|
+
end
|
33
|
+
|
34
|
+
subject {Gravaty::Parsers::Rating.new}
|
35
|
+
|
36
|
+
Gravaty::RATING_OPTIONS.each do |value|
|
37
|
+
[[nil, ''], %W(#{value} rating=#{value.downcase})].each do |pair|
|
38
|
+
it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
|
39
|
+
subject.parse(pair[0]).must_equal pair[1]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'shall raise an exception when provided with invalid rating' do
|
45
|
+
begin
|
46
|
+
subject.parse('xxx').must_raise ArgumentError
|
47
|
+
rescue ArgumentError => aErr
|
48
|
+
aErr.wont_be_nil
|
49
|
+
aErr.message.wont_be_nil
|
50
|
+
aErr.message.wont_be_empty
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#--
|
2
|
+
# gravaty
|
3
|
+
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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
|
+
|
21
|
+
require_relative '../../test_helper'
|
22
|
+
|
23
|
+
describe Gravaty::Gravaty do
|
24
|
+
describe 'when using a parser' do
|
25
|
+
include Gravaty::ParsableDuckType
|
26
|
+
|
27
|
+
before do
|
28
|
+
@parser = subject
|
29
|
+
end
|
30
|
+
|
31
|
+
subject {Gravaty::Parsers::Secure.new}
|
32
|
+
|
33
|
+
[['https://secure', true], ['http://www', false]].each do |pair|
|
34
|
+
it "shall return '#{pair[0]}' when parameter is '#{pair[1]}'" do
|
35
|
+
subject.parse(pair[1]).must_equal pair[0]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|