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.

Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +587 -0
  3. data/COPYING.md +234 -0
  4. data/Gemfile +17 -0
  5. data/ISSUES.md +40 -0
  6. data/README.md +128 -0
  7. data/Rakefile +48 -0
  8. data/acknowledgements.md +40 -0
  9. data/authors.md +44 -0
  10. data/copyright.md +339 -0
  11. data/examples/avatar.rb +121 -0
  12. data/examples/basics.rb +60 -0
  13. data/examples/profile.rb +143 -0
  14. data/examples/xmlrpc.rb +33 -0
  15. data/gravaty.gemspec +59 -0
  16. data/gravaty.odp +0 -0
  17. data/gravaty.pdf +0 -0
  18. data/html/CHANGELOG.html +876 -0
  19. data/html/COPYING_md.html +803 -0
  20. data/html/Gemfile.html +114 -0
  21. data/html/Gravaty.html +322 -0
  22. data/html/Gravaty/Gravaty.html +997 -0
  23. data/html/Gravaty/ParsableDuckType.html +158 -0
  24. data/html/Gravaty/Parser.html +233 -0
  25. data/html/Gravaty/Parsers.html +94 -0
  26. data/html/Gravaty/Parsers/Avatar.html +166 -0
  27. data/html/Gravaty/Parsers/Callback.html +167 -0
  28. data/html/Gravaty/Parsers/Default.html +174 -0
  29. data/html/Gravaty/Parsers/Force.html +167 -0
  30. data/html/Gravaty/Parsers/Format.html +177 -0
  31. data/html/Gravaty/Parsers/Pixelsize.html +177 -0
  32. data/html/Gravaty/Parsers/Rating.html +177 -0
  33. data/html/Gravaty/Parsers/Secure.html +166 -0
  34. data/html/Gravaty/Parsers/Type.html +177 -0
  35. data/html/Gravaty/Utils.html +107 -0
  36. data/html/Gravaty/Utils/Downloader.html +106 -0
  37. data/html/Gravaty/Utils/Downloader/Downloader.html +224 -0
  38. data/html/Gravaty/Utils/Raisers.html +199 -0
  39. data/html/Gravaty/Utils/Rfc5322.html +149 -0
  40. data/html/Gravaty/Utils/RpcConnector.html +106 -0
  41. data/html/Gravaty/Utils/RpcConnector/RpcConnector.html +241 -0
  42. data/html/ISSUES_md.html +165 -0
  43. data/html/Object.html +183 -0
  44. data/html/README_md.html +436 -0
  45. data/html/Rakefile.html +152 -0
  46. data/html/acknowledgements_md.html +172 -0
  47. data/html/authors_md.html +178 -0
  48. data/html/copyright_md.html +553 -0
  49. data/html/created.rid +59 -0
  50. data/html/css/fonts.css +167 -0
  51. data/html/css/rdoc.css +590 -0
  52. data/html/fonts/Lato-Light.ttf +0 -0
  53. data/html/fonts/Lato-LightItalic.ttf +0 -0
  54. data/html/fonts/Lato-Regular.ttf +0 -0
  55. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  56. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  57. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  58. data/html/gravaty_gemspec.html +162 -0
  59. data/html/images/add.png +0 -0
  60. data/html/images/arrow_up.png +0 -0
  61. data/html/images/brick.png +0 -0
  62. data/html/images/brick_link.png +0 -0
  63. data/html/images/bug.png +0 -0
  64. data/html/images/bullet_black.png +0 -0
  65. data/html/images/bullet_toggle_minus.png +0 -0
  66. data/html/images/bullet_toggle_plus.png +0 -0
  67. data/html/images/date.png +0 -0
  68. data/html/images/delete.png +0 -0
  69. data/html/images/find.png +0 -0
  70. data/html/images/loadingAnimation.gif +0 -0
  71. data/html/images/macFFBgHack.png +0 -0
  72. data/html/images/package.png +0 -0
  73. data/html/images/page_green.png +0 -0
  74. data/html/images/page_white_text.png +0 -0
  75. data/html/images/page_white_width.png +0 -0
  76. data/html/images/plugin.png +0 -0
  77. data/html/images/ruby.png +0 -0
  78. data/html/images/tag_blue.png +0 -0
  79. data/html/images/tag_green.png +0 -0
  80. data/html/images/transparent.png +0 -0
  81. data/html/images/wrench.png +0 -0
  82. data/html/images/wrench_orange.png +0 -0
  83. data/html/images/zoom.png +0 -0
  84. data/html/index.html +467 -0
  85. data/html/js/darkfish.js +161 -0
  86. data/html/js/jquery.js +4 -0
  87. data/html/js/navigation.js +142 -0
  88. data/html/js/navigation.js.gz +0 -0
  89. data/html/js/search.js +109 -0
  90. data/html/js/search_index.js +1 -0
  91. data/html/js/search_index.js.gz +0 -0
  92. data/html/js/searcher.js +229 -0
  93. data/html/js/searcher.js.gz +0 -0
  94. data/html/table_of_contents.html +479 -0
  95. data/lib/gravaty.rb +59 -0
  96. data/lib/gravaty/application.rb +272 -0
  97. data/lib/gravaty/constants.rb +53 -0
  98. data/lib/gravaty/locales/en.yml +34 -0
  99. data/lib/gravaty/locales/it.yml +34 -0
  100. data/lib/gravaty/locales/ja.yml +35 -0
  101. data/lib/gravaty/parser.rb +41 -0
  102. data/lib/gravaty/parsers/avatar.rb +33 -0
  103. data/lib/gravaty/parsers/callback.rb +34 -0
  104. data/lib/gravaty/parsers/default.rb +79 -0
  105. data/lib/gravaty/parsers/force.rb +33 -0
  106. data/lib/gravaty/parsers/format.rb +38 -0
  107. data/lib/gravaty/parsers/pixelsize.rb +38 -0
  108. data/lib/gravaty/parsers/rating.rb +38 -0
  109. data/lib/gravaty/parsers/secure.rb +32 -0
  110. data/lib/gravaty/parsers/type.rb +38 -0
  111. data/lib/gravaty/utils/downloader.rb +150 -0
  112. data/lib/gravaty/utils/raisers.rb +50 -0
  113. data/lib/gravaty/utils/rfc5322.rb +102 -0
  114. data/lib/gravaty/utils/rpc_connector.rb +71 -0
  115. data/lib/gravaty/version.rb +20 -0
  116. data/test/gravaty/locales/test_locales.rb +61 -0
  117. data/test/gravaty/parsers/test_avatar.rb +35 -0
  118. data/test/gravaty/parsers/test_callback.rb +37 -0
  119. data/test/gravaty/parsers/test_default.rb +69 -0
  120. data/test/gravaty/parsers/test_force.rb +35 -0
  121. data/test/gravaty/parsers/test_format.rb +48 -0
  122. data/test/gravaty/parsers/test_pixelsize.rb +50 -0
  123. data/test/gravaty/parsers/test_rating.rb +48 -0
  124. data/test/gravaty/parsers/test_secure.rb +35 -0
  125. data/test/gravaty/parsers/test_type.rb +37 -0
  126. data/test/gravaty/test_application.rb +111 -0
  127. data/test/gravaty/test_avatar.rb +115 -0
  128. data/test/gravaty/test_parsable_duck_type.rb +31 -0
  129. data/test/gravaty/test_parser.rb +55 -0
  130. data/test/gravaty/test_profile.rb +63 -0
  131. data/test/gravaty/utils/test_downloader.rb +43 -0
  132. data/test/gravaty/utils/test_raisers.rb +55 -0
  133. data/test/gravaty/utils/test_rfc5322.rb +58 -0
  134. data/test/gravaty/utils/test_rpc_connector.rb +74 -0
  135. data/test/test_gravaty.rb +44 -0
  136. data/test/test_helper.rb +77 -0
  137. metadata +315 -0
@@ -0,0 +1,35 @@
1
+ # gravaty
2
+ # Copyright © 2013 新部裕
3
+ # Copyright © 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
+ ja:
17
+ error:
18
+ invalid: "無効なパラメータ %{value} です(RFC5322 もしくは以後の更新による)。"
19
+ nil: nil パラメータは許されません。
20
+ param: "パラメータ %{value} は無効です。"
21
+ type: "型 %{value} は既知の拡張ではありません。"
22
+ uri: "URI %{value} が無効です。"
23
+ value: "値 %{value} が範囲外です。"
24
+ warn:
25
+ deprecated: このメソッドはすでに廃止され、推奨されていません。
26
+ test:
27
+ test: 試験データ
28
+ gravatar:
29
+ errors:
30
+ -7: secure.gravatar.com を使用
31
+ -8: 内部エラー
32
+ -9: 認証エラー
33
+ -10: メソッド引数がありません
34
+ -11: メソッド引数が間違っています
35
+ -100: その他のエラー (テキスト参照)
@@ -0,0 +1,41 @@
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 'constants'
18
+
19
+ module Gravaty
20
+
21
+ # This class is a simple utility that is used to parse and filter parameters for gravaty.
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
+ class Parser
27
+ attr_reader :parsers
28
+
29
+ def initialize(args = {})
30
+ @parsers = Hash.new
31
+ ALLOWED_PARAMS.each { |param| parsers[param] = args[param] } unless args.nil?
32
+ end
33
+
34
+ # Provides the duck type for a generic parsing object.
35
+ def parse(method = nil, value = nil)
36
+ a_parser = nil
37
+ a_parser = parsers[method.to_sym] unless method.nil? or parsers.nil?
38
+ a_parser.parse value unless a_parser.nil?
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,33 @@
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 Parsers
19
+
20
+ # This class is an implementation of the Parsable duck type that checks for avater or profile URI. The only needed parameter is a boolean, with +true+ for avatar.
21
+ #
22
+ # Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
23
+ # Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
24
+ # License:: GNU General Public License version 3
25
+ class Avatar
26
+
27
+ # The parsable duck type interface to every parser usage.
28
+ def parse(value = true)
29
+ value ? 'avatar/' : ''
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
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 Parsers
19
+
20
+ # This class is an implementation of the Parsable duck type that provides the callback name. The only needed parameter is a valid callback +String+ name.
21
+ #
22
+ # Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
23
+ # Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
24
+ # License:: GNU General Public License version 3
25
+ class Callback
26
+
27
+ # The parsable duck type interface to every parser usage.
28
+ def parse(value = nil)
29
+ return "callback=#{value}" unless value.nil? or value.empty?
30
+ ''
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,79 @@
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 'cgi'
18
+
19
+ require_relative '../constants'
20
+
21
+ module Gravaty
22
+ module Parsers
23
+
24
+ # This class is an implementation of the Parsable duck type that checks the default option. The only needed parameter is a valid default option.
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
+ class Default
30
+
31
+ # The parsable duck type interface to every parser usage.
32
+ def parse(value = nil)
33
+ unless value.nil? or value.empty?
34
+ unless DEFAULT_OPTIONS.include? value
35
+ valid = %w(http https).index { |scheme| valid?(value, scheme) }
36
+
37
+ raise ArgumentError, I18n.t('error.uri', value: value) if valid.nil?
38
+ end
39
+
40
+ return 'd=' + CGI::escape(value).to_s
41
+ end
42
+ ''
43
+ end
44
+
45
+ # ------------------------------------------------------------------------ here starts the list of private methods
46
+ private
47
+
48
+ def valid?(value, scheme)
49
+ return false if value.nil?
50
+ return false if value.empty?
51
+
52
+ an_uri = URI.extract(value.downcase, scheme)
53
+
54
+ return false if an_uri.nil?
55
+ return false if an_uri.empty?
56
+
57
+ begin
58
+ an_uri = URI::parse an_uri[0]
59
+
60
+ #See URI validation rules at http://en.gravatar.com/site/implement/images/#default-image
61
+
62
+ #rule 2
63
+ return false if (an_uri.scheme == 'http') and (an_uri.port != Net::HTTP.http_default_port)
64
+ return false if (an_uri.scheme == 'https') and (an_uri.port != Net::HTTP.https_default_port)
65
+
66
+ #rule 3
67
+ allowed = IMAGES_FORMATS.index { |format| an_uri.path.end_with? format }
68
+ return false if allowed.nil?
69
+
70
+ #rule 4
71
+ return false unless an_uri.query.nil?
72
+ rescue
73
+ return false
74
+ end
75
+ true
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,33 @@
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 Parsers
19
+
20
+ # This class is an implementation of the Parsable duck type that checks forces the default value. The only needed parameter is a boolean, with +true+ for forced.
21
+ #
22
+ # Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
23
+ # Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
24
+ # License:: GNU General Public License version 3
25
+ class Force
26
+ # The parsable duck type interface to every parser usage.
27
+ def parse(value = false)
28
+ return 'f=y' if value
29
+ ''
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,38 @@
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 '../constants'
18
+ require_relative '../utils/raisers'
19
+
20
+ module Gravaty
21
+ module Parsers
22
+
23
+ # This class is an implementation of the Parsable duck type that checks the profile type. The only needed parameter is a valid profile format.
24
+ #
25
+ # Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
26
+ # Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
27
+ # License:: GNU General Public License version 3
28
+ class Format
29
+ include Utils::Raisers
30
+
31
+ # The parsable duck type interface to every parser usage.
32
+ def parse(value = nil)
33
+ raiser_downcase('error.type', value, PROFILE_FORMATS)
34
+ value.nil? ? '' : ".#{value.downcase}"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
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 '../constants'
18
+ require_relative '../utils/raisers'
19
+
20
+ module Gravaty
21
+ module Parsers
22
+
23
+ # This class is an implementation of the Parsable duck type that checks the image size. The only needed parameter is a valid image size.
24
+ #
25
+ # Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
26
+ # Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
27
+ # License:: GNU General Public License version 3
28
+ class Pixelsize
29
+ include Utils::Raisers
30
+
31
+ # The parsable duck type interface to every parser usage.
32
+ def parse(value = nil)
33
+ raiser_to_i('error.value', value, ALLOWED_SIZES)
34
+ value.nil? ? '' : "s=#{value.to_s}"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
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 '../constants'
18
+ require_relative '../utils/raisers'
19
+
20
+ module Gravaty
21
+ module Parsers
22
+
23
+ # This class is an implementation of the Parsable duck type that checks the rating type. The only needed parameter is a valid rating type.
24
+ #
25
+ # Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
26
+ # Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
27
+ # License:: GNU General Public License version 3
28
+ class Rating
29
+ include Utils::Raisers
30
+
31
+ # the parsable duck type interface to every parser usage.
32
+ def parse(value = nil)
33
+ raiser_downcase('error.value', value, RATING_OPTIONS)
34
+ value.nil? ? '' : "rating=#{value.downcase.to_s}"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,32 @@
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 Parsers
19
+
20
+ # This class is an implementation of the Parsable duck type that provides the secure or unsecure URI. The only needed parameter is a boolean, with +true+ for secure.
21
+ #
22
+ # Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
23
+ # Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
24
+ # License:: GNU General Public License version 3
25
+ class Secure
26
+ # The parsable duck type interface to every parser usage.
27
+ def parse(value = false)
28
+ value ? 'https://secure' : 'http://www'
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,38 @@
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 '../constants'
18
+ require_relative '../utils/raisers'
19
+
20
+ module Gravaty
21
+ module Parsers
22
+
23
+ # This class is an implementation of the Parsable duck type that checks the avatar type. The only needed parameter is a valid avatar format.
24
+ #
25
+ # Author:: {Marco Bresciani}[mailto:m.bresciani@email.it]
26
+ # Copyright:: Copyright © 2013, 2014, 2015, 2016 Marco Bresciani
27
+ # License:: GNU General Public License version 3
28
+ class Type
29
+ include Utils::Raisers
30
+
31
+ # The parsable duck type interface to every parser usage.
32
+ def parse(value = nil)
33
+ raiser_downcase('error.type', value, AVATAR_FORMATS)
34
+ value.nil? ? '' : ".#{value.downcase}"
35
+ end
36
+ end
37
+ end
38
+ end