gravtastic 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,7 +20,7 @@ The best way to learn more about Gravtastic is to [look through the annotated so
20
20
 
21
21
  ## Usage
22
22
 
23
- For this example I'm going to assume you are using Rails. Don't worry if you arn't, the concepts are still the same.
23
+ For this example I'm going to assume you are using Rails. Don't worry if you aren't, the concepts are still the same.
24
24
 
25
25
  First off, add this to your `Gemfile`:
26
26
 
@@ -73,7 +73,7 @@ The best way to do this is to set the `:default` option when using `#gravatr_url
73
73
  <tr>
74
74
  <td><b>secure</b></td>
75
75
  <td>Gravatar transmitted with SSL</td>
76
- <td>false</td>
76
+ <td>true</td>
77
77
  <td>true/false</td>
78
78
  </tr>
79
79
  <tr>
@@ -90,7 +90,7 @@ The best way to do this is to set the `:default` option when using `#gravatr_url
90
90
  </tr>
91
91
  <tr>
92
92
  <td><b>rating</b></td>
93
- <td>The lowest level of ratings you want to allow</td>
93
+ <td>The highest level of ratings you want to allow</td>
94
94
  <td>G</td>
95
95
  <td>G, PG, R or X</td>
96
96
  </tr>
@@ -129,6 +129,24 @@ And wallah! It's exactly the same as with ActiveRecord! Now all instances of the
129
129
  _Note: the `#gravatar_url` methods don't get included until you specify the class `is_gravtastic!`_
130
130
 
131
131
 
132
+ ## Javascript
133
+
134
+ _Note: this feature requires Rails 3.1 & CoffeeScript._
135
+
136
+ Web applications are increasingly performing client side rendering in Javascript. It's not always practical or clean to calculate the `gravatar_url` on the server. As of version 3.2, Gravtastic comes bundled with Javascript helpers.
137
+
138
+ If you are using Rails 3.1 you can simple require Gravtastic in your `Gemfile` and add
139
+
140
+ //= require gravtastic
141
+
142
+ in your `application.js` file. This will include a function, `Gravtastic` which performs similarly to `gravtastic_url`.
143
+
144
+ > Gravtastic('christopher.lloyd@gmail.com')
145
+ "https://secure.gravatar.com/avatar/08f077ea061585744ee080824f5a8e65.png?r=PG"
146
+ > Gravtastic('christopher.lloyd@gmail.com', {default: 'identicon', size: 64})
147
+ "https://secure.gravatar.com/avatar/08f077ea061585744ee080824f5a8e65.png?r=PG&d=identicon&s=64"
148
+
149
+
132
150
  ## Making Changes Yourself
133
151
 
134
152
  Gravtastic is a mature project. There isn't any active work which needs to be done on it, but I do continue to maintain it. Just don't expect same day fixes. If you find something that needs fixing, the best way to contribute is to fork the repo and submit a pull request.
@@ -146,6 +164,7 @@ Gravtastic is a mature project. There isn't any active work which needs to be do
146
164
  * [Jeff Kreeftmeijer](http://github.com/jeffkreeftmeijer)
147
165
  * [Ryan Lewis](http://github.com/c00lryguy)
148
166
  * [Arthur Chiu](http://github.com/achiu)
167
+ * [Paul Johnston](http://pajhome.org.uk/crypt/md5/) for his awesome MD5.js implementation.
149
168
 
150
169
 
151
170
  ## License
@@ -157,3 +176,16 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
157
176
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
158
177
 
159
178
  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
179
+
180
+ --
181
+
182
+ md5.js Copyright (c) 1998 - 2009, Paul Johnston & Contributors
183
+ All rights reserved.
184
+
185
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
186
+
187
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
188
+
189
+ Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
190
+
191
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require 'rake/gempackagetask'
1
+ require 'rubygems/package_task'
2
2
  require 'rake/clean'
3
3
  require 'rspec/core/rake_task'
4
4
 
@@ -12,7 +12,7 @@ end
12
12
 
13
13
  load(gemspec_file)
14
14
 
15
- Rake::GemPackageTask.new(@spec) do |t|
15
+ Gem::PackageTask.new(@spec) do |t|
16
16
  t.need_tar = true
17
17
  t.need_zip = true
18
18
  end
@@ -21,11 +21,4 @@ CLEAN.add 'pkg'
21
21
  require 'spec/rake/spectask'
22
22
  RSpec::Core::RakeTask.new do |t|
23
23
  t.rspec_opts = ['--color', '--require ./spec/helper']
24
- # t.files = FileList['spec/*.rb']
25
24
  end
26
-
27
- desc 'Build documentation'
28
- task :doc do
29
- sh 'docco lib/gravtastic.rb'
30
- end
31
- CLEAN.add 'docs'
@@ -5,33 +5,39 @@
5
5
  require 'digest/md5'
6
6
  require 'gravtastic/version'
7
7
 
8
+ begin
9
+ require 'rails'
10
+ require 'gravtastic/engine'
11
+ rescue LoadError
12
+ end
13
+
8
14
  module Gravtastic
9
-
15
+
10
16
  # When you `include Gravtastic`, Ruby automatically calls this method
11
17
  # with the class you called it in. It allows us extend the class with the
12
18
  # `#gravtastic` method.
13
19
  def self.included(model)
14
20
  model.extend StageOne
15
21
  end
16
-
17
- # Sets the model's default attributes. It is called when you use
22
+
23
+ # Sets the model's default attributes. It is called when you use
18
24
  # `#gravtastic` in your model.
19
25
  def self.configure(model, *args, &blk)
20
26
  options = args.last.is_a?(Hash) ? args.pop : {}
21
27
 
22
28
  model.gravatar_defaults = {
23
- :rating => 'PG',
24
- :secure => false,
29
+ :rating => 'PG',
30
+ :secure => true,
25
31
  :filetype => :png
26
32
  }.merge(options)
27
-
33
+
28
34
  # The method where Gravtastic get the users' email from defaults to `#email`.
29
35
  model.gravatar_source = args.first || :email
30
36
  end
31
37
 
32
- # We include Gravtastic in multiple stages. This is mainly so that if you
33
- # include Gravastic in a superclass (something like `ActiveRecord::Base`)
34
- # then it only adds the relevant methods to the classes which _actually_ use
38
+ # We include Gravtastic in multiple stages. This is mainly so that if you
39
+ # include Gravastic in a superclass (something like `ActiveRecord::Base`)
40
+ # then it only adds the relevant methods to the classes which _actually_ use
35
41
  # it.
36
42
  module StageOne
37
43
  def gravtastic(*args, &blk)
@@ -40,9 +46,9 @@ module Gravtastic
40
46
  Gravtastic.configure(self, *args, &blk)
41
47
  self
42
48
  end
43
-
44
- # All these aliases deal with pervious bad design decisions. Let that be a
45
- # lesson, name things simply, try not to follow fads and try not to break
49
+
50
+ # All these aliases deal with previous bad design decisions. Let that be a
51
+ # lesson, name things simply, try not to follow fads and try not to break
46
52
  # backwards compatibility.
47
53
  alias_method :gravtastic!, :gravtastic
48
54
  alias_method :has_gravatar, :gravtastic
@@ -52,7 +58,7 @@ module Gravtastic
52
58
 
53
59
  module ClassMethods
54
60
  attr_accessor :gravatar_source, :gravatar_defaults
55
-
61
+
56
62
  # Gravtastic abbreviates certain params so that it produces the smallest
57
63
  # possible URL. Every byte counts.
58
64
  def gravatar_abbreviations
@@ -64,14 +70,14 @@ module Gravtastic
64
70
  end
65
71
 
66
72
  module InstanceMethods
67
-
73
+
68
74
  # The raw MD5 hash of the users' email. Gravatar is particularly tricky as
69
- # it downcases all emails. This is really the guts of the module,
75
+ # it downcases all emails. This is really the guts of the module,
70
76
  # everything else is just convenience.
71
77
  def gravatar_id
72
78
  Digest::MD5.hexdigest(send(self.class.gravatar_source).to_s.downcase)
73
79
  end
74
-
80
+
75
81
  # Constructs the full Gravatar url.
76
82
  def gravatar_url(options={})
77
83
  options = self.class.gravatar_defaults.merge(options)
@@ -81,9 +87,9 @@ module Gravtastic
81
87
  end
82
88
 
83
89
  private
84
-
90
+
85
91
  # Creates a params hash like "?foo=bar" from a hash like {'foo' => 'bar'}.
86
- # The values are sorted so it produces deterministic output (and can
92
+ # The values are sorted so it produces deterministic output (and can
87
93
  # therefore be tested easily).
88
94
  def url_params_from_hash(hash)
89
95
  '?' + hash.map do |key, val|
@@ -95,7 +101,7 @@ module Gravtastic
95
101
  def gravatar_hostname(secure)
96
102
  'http' + (secure ? 's://secure.' : '://') + 'gravatar.com/avatar/'
97
103
  end
98
-
104
+
99
105
  # Munges the ID and the filetype into one. Like "abc123.png"
100
106
  def gravatar_filename(filetype)
101
107
  "#{gravatar_id}.#{filetype}"
@@ -0,0 +1,4 @@
1
+ module Gravtastic
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -1,6 +1,6 @@
1
1
  module Gravtastic
2
2
 
3
- VERSION = '3.1.0'
3
+ VERSION = '3.2.0'
4
4
 
5
5
  # Returns the version of Gravtastic
6
6
  def self.version
@@ -0,0 +1,37 @@
1
+ #= require md5
2
+
3
+ # Private abbreviations
4
+ abbreviations =
5
+ size: 's'
6
+ default: 'd'
7
+ rating: 'r'
8
+
9
+ window.Gravtastic = (email, options={}) ->
10
+ id = MD5(email.toString().toLowerCase())
11
+
12
+ # Initialize options
13
+ opts = {}
14
+ opts[key] = val for key, val of Gravtastic.defaults
15
+ opts[key] = val for key, val of options
16
+
17
+ host = if opts.secure
18
+ "https://secure.gravatar.com/avatar"
19
+ else
20
+ "http://gravatar.com/avatar"
21
+
22
+ path = "/#{id}.#{opts.filetype || 'png'}"
23
+
24
+ params = "?" + (
25
+ for key, val of opts when key isnt "secure" and key isnt "filetype"
26
+ "#{abbreviations[key] || key}=#{val}"
27
+ ).join('&')
28
+
29
+ host + path + params
30
+
31
+
32
+ # These are easily overridden in your own application
33
+ window.Gravtastic.defaults =
34
+ rating: 'PG'
35
+ secure: true
36
+ filetype: 'png'
37
+
@@ -0,0 +1,383 @@
1
+ ;(function(export) {
2
+ /*
3
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
4
+ * Digest Algorithm, as defined in RFC 1321.
5
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
6
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
7
+ * Distributed under the BSD License
8
+ * See http://pajhome.org.uk/crypt/md5 for more info.
9
+ */
10
+
11
+ /*
12
+ * Configurable variables. You may need to tweak these to be compatible with
13
+ * the server-side, but the defaults work in most cases.
14
+ */
15
+ var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
16
+ var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
17
+
18
+ /*
19
+ * These are the functions you'll usually want to call
20
+ * They take string arguments and return either hex or base-64 encoded strings
21
+ */
22
+ function hex_md5(s) { return rstr2hex(rstr_md5(str2rstr_utf8(s))); }
23
+ function b64_md5(s) { return rstr2b64(rstr_md5(str2rstr_utf8(s))); }
24
+ function any_md5(s, e) { return rstr2any(rstr_md5(str2rstr_utf8(s)), e); }
25
+ function hex_hmac_md5(k, d)
26
+ { return rstr2hex(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
27
+ function b64_hmac_md5(k, d)
28
+ { return rstr2b64(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))); }
29
+ function any_hmac_md5(k, d, e)
30
+ { return rstr2any(rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
31
+
32
+ /*
33
+ * Perform a simple self-test to see if the VM is working
34
+ */
35
+ function md5_vm_test()
36
+ {
37
+ return hex_md5("abc").toLowerCase() == "900150983cd24fb0d6963f7d28e17f72";
38
+ }
39
+
40
+ /*
41
+ * Calculate the MD5 of a raw string
42
+ */
43
+ function rstr_md5(s)
44
+ {
45
+ return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
46
+ }
47
+
48
+ /*
49
+ * Calculate the HMAC-MD5, of a key and some data (raw strings)
50
+ */
51
+ function rstr_hmac_md5(key, data)
52
+ {
53
+ var bkey = rstr2binl(key);
54
+ if(bkey.length > 16) bkey = binl_md5(bkey, key.length * 8);
55
+
56
+ var ipad = Array(16), opad = Array(16);
57
+ for(var i = 0; i < 16; i++)
58
+ {
59
+ ipad[i] = bkey[i] ^ 0x36363636;
60
+ opad[i] = bkey[i] ^ 0x5C5C5C5C;
61
+ }
62
+
63
+ var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
64
+ return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
65
+ }
66
+
67
+ /*
68
+ * Convert a raw string to a hex string
69
+ */
70
+ function rstr2hex(input)
71
+ {
72
+ try { hexcase } catch(e) { hexcase=0; }
73
+ var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
74
+ var output = "";
75
+ var x;
76
+ for(var i = 0; i < input.length; i++)
77
+ {
78
+ x = input.charCodeAt(i);
79
+ output += hex_tab.charAt((x >>> 4) & 0x0F)
80
+ + hex_tab.charAt( x & 0x0F);
81
+ }
82
+ return output;
83
+ }
84
+
85
+ /*
86
+ * Convert a raw string to a base-64 string
87
+ */
88
+ function rstr2b64(input)
89
+ {
90
+ try { b64pad } catch(e) { b64pad=''; }
91
+ var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
92
+ var output = "";
93
+ var len = input.length;
94
+ for(var i = 0; i < len; i += 3)
95
+ {
96
+ var triplet = (input.charCodeAt(i) << 16)
97
+ | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
98
+ | (i + 2 < len ? input.charCodeAt(i+2) : 0);
99
+ for(var j = 0; j < 4; j++)
100
+ {
101
+ if(i * 8 + j * 6 > input.length * 8) output += b64pad;
102
+ else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
103
+ }
104
+ }
105
+ return output;
106
+ }
107
+
108
+ /*
109
+ * Convert a raw string to an arbitrary string encoding
110
+ */
111
+ function rstr2any(input, encoding)
112
+ {
113
+ var divisor = encoding.length;
114
+ var i, j, q, x, quotient;
115
+
116
+ /* Convert to an array of 16-bit big-endian values, forming the dividend */
117
+ var dividend = Array(Math.ceil(input.length / 2));
118
+ for(i = 0; i < dividend.length; i++)
119
+ {
120
+ dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
121
+ }
122
+
123
+ /*
124
+ * Repeatedly perform a long division. The binary array forms the dividend,
125
+ * the length of the encoding is the divisor. Once computed, the quotient
126
+ * forms the dividend for the next step. All remainders are stored for later
127
+ * use.
128
+ */
129
+ var full_length = Math.ceil(input.length * 8 /
130
+ (Math.log(encoding.length) / Math.log(2)));
131
+ var remainders = Array(full_length);
132
+ for(j = 0; j < full_length; j++)
133
+ {
134
+ quotient = Array();
135
+ x = 0;
136
+ for(i = 0; i < dividend.length; i++)
137
+ {
138
+ x = (x << 16) + dividend[i];
139
+ q = Math.floor(x / divisor);
140
+ x -= q * divisor;
141
+ if(quotient.length > 0 || q > 0)
142
+ quotient[quotient.length] = q;
143
+ }
144
+ remainders[j] = x;
145
+ dividend = quotient;
146
+ }
147
+
148
+ /* Convert the remainders to the output string */
149
+ var output = "";
150
+ for(i = remainders.length - 1; i >= 0; i--)
151
+ output += encoding.charAt(remainders[i]);
152
+
153
+ return output;
154
+ }
155
+
156
+ /*
157
+ * Encode a string as utf-8.
158
+ * For efficiency, this assumes the input is valid utf-16.
159
+ */
160
+ function str2rstr_utf8(input)
161
+ {
162
+ var output = "";
163
+ var i = -1;
164
+ var x, y;
165
+
166
+ while(++i < input.length)
167
+ {
168
+ /* Decode utf-16 surrogate pairs */
169
+ x = input.charCodeAt(i);
170
+ y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
171
+ if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
172
+ {
173
+ x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
174
+ i++;
175
+ }
176
+
177
+ /* Encode output as utf-8 */
178
+ if(x <= 0x7F)
179
+ output += String.fromCharCode(x);
180
+ else if(x <= 0x7FF)
181
+ output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
182
+ 0x80 | ( x & 0x3F));
183
+ else if(x <= 0xFFFF)
184
+ output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
185
+ 0x80 | ((x >>> 6 ) & 0x3F),
186
+ 0x80 | ( x & 0x3F));
187
+ else if(x <= 0x1FFFFF)
188
+ output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
189
+ 0x80 | ((x >>> 12) & 0x3F),
190
+ 0x80 | ((x >>> 6 ) & 0x3F),
191
+ 0x80 | ( x & 0x3F));
192
+ }
193
+ return output;
194
+ }
195
+
196
+ /*
197
+ * Encode a string as utf-16
198
+ */
199
+ function str2rstr_utf16le(input)
200
+ {
201
+ var output = "";
202
+ for(var i = 0; i < input.length; i++)
203
+ output += String.fromCharCode( input.charCodeAt(i) & 0xFF,
204
+ (input.charCodeAt(i) >>> 8) & 0xFF);
205
+ return output;
206
+ }
207
+
208
+ function str2rstr_utf16be(input)
209
+ {
210
+ var output = "";
211
+ for(var i = 0; i < input.length; i++)
212
+ output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
213
+ input.charCodeAt(i) & 0xFF);
214
+ return output;
215
+ }
216
+
217
+ /*
218
+ * Convert a raw string to an array of little-endian words
219
+ * Characters >255 have their high-byte silently ignored.
220
+ */
221
+ function rstr2binl(input)
222
+ {
223
+ var output = Array(input.length >> 2);
224
+ for(var i = 0; i < output.length; i++)
225
+ output[i] = 0;
226
+ for(var i = 0; i < input.length * 8; i += 8)
227
+ output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
228
+ return output;
229
+ }
230
+
231
+ /*
232
+ * Convert an array of little-endian words to a string
233
+ */
234
+ function binl2rstr(input)
235
+ {
236
+ var output = "";
237
+ for(var i = 0; i < input.length * 32; i += 8)
238
+ output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
239
+ return output;
240
+ }
241
+
242
+ /*
243
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
244
+ */
245
+ function binl_md5(x, len)
246
+ {
247
+ /* append padding */
248
+ x[len >> 5] |= 0x80 << ((len) % 32);
249
+ x[(((len + 64) >>> 9) << 4) + 14] = len;
250
+
251
+ var a = 1732584193;
252
+ var b = -271733879;
253
+ var c = -1732584194;
254
+ var d = 271733878;
255
+
256
+ for(var i = 0; i < x.length; i += 16)
257
+ {
258
+ var olda = a;
259
+ var oldb = b;
260
+ var oldc = c;
261
+ var oldd = d;
262
+
263
+ a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
264
+ d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
265
+ c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
266
+ b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
267
+ a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
268
+ d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
269
+ c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
270
+ b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
271
+ a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
272
+ d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
273
+ c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
274
+ b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
275
+ a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
276
+ d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
277
+ c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
278
+ b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
279
+
280
+ a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
281
+ d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
282
+ c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
283
+ b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
284
+ a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
285
+ d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
286
+ c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
287
+ b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
288
+ a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
289
+ d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
290
+ c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
291
+ b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
292
+ a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
293
+ d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
294
+ c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
295
+ b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
296
+
297
+ a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
298
+ d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
299
+ c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
300
+ b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
301
+ a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
302
+ d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
303
+ c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
304
+ b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
305
+ a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
306
+ d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
307
+ c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
308
+ b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
309
+ a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
310
+ d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
311
+ c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
312
+ b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
313
+
314
+ a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
315
+ d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
316
+ c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
317
+ b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
318
+ a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
319
+ d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
320
+ c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
321
+ b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
322
+ a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
323
+ d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
324
+ c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
325
+ b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
326
+ a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
327
+ d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
328
+ c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
329
+ b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
330
+
331
+ a = safe_add(a, olda);
332
+ b = safe_add(b, oldb);
333
+ c = safe_add(c, oldc);
334
+ d = safe_add(d, oldd);
335
+ }
336
+ return Array(a, b, c, d);
337
+ }
338
+
339
+ /*
340
+ * These functions implement the four basic operations the algorithm uses.
341
+ */
342
+ function md5_cmn(q, a, b, x, s, t)
343
+ {
344
+ return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
345
+ }
346
+ function md5_ff(a, b, c, d, x, s, t)
347
+ {
348
+ return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
349
+ }
350
+ function md5_gg(a, b, c, d, x, s, t)
351
+ {
352
+ return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
353
+ }
354
+ function md5_hh(a, b, c, d, x, s, t)
355
+ {
356
+ return md5_cmn(b ^ c ^ d, a, b, x, s, t);
357
+ }
358
+ function md5_ii(a, b, c, d, x, s, t)
359
+ {
360
+ return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
361
+ }
362
+
363
+ /*
364
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
365
+ * to work around bugs in some JS interpreters.
366
+ */
367
+ function safe_add(x, y)
368
+ {
369
+ var lsw = (x & 0xFFFF) + (y & 0xFFFF);
370
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
371
+ return (msw << 16) | (lsw & 0xFFFF);
372
+ }
373
+
374
+ /*
375
+ * Bitwise rotate a 32-bit number to the left.
376
+ */
377
+ function bit_rol(num, cnt)
378
+ {
379
+ return (num << cnt) | (num >>> (32 - cnt));
380
+ }
381
+
382
+ export.MD5 = hex_md5;
383
+ })(window);
metadata CHANGED
@@ -1,70 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gravtastic
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 3
7
- - 1
8
- - 0
9
- version: 3.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.2.0
5
+ prerelease: !!null
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Chris Lloyd
13
- autorequire:
9
+ autorequire: !!null
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-10-18 00:00:00 +02:00
18
- default_executable:
12
+ date: 2011-08-03 00:00:00.000000000 +10:00
13
+ default_executable: !!null
19
14
  dependencies: []
20
-
21
15
  description: A Ruby wrapper for Gravatar URLs
22
16
  email: christopher.lloyd@gmail.com
23
17
  executables: []
24
-
25
18
  extensions: []
26
-
27
19
  extra_rdoc_files: []
28
-
29
- files:
20
+ files:
30
21
  - README.md
31
22
  - Rakefile
32
23
  - Gemfile
24
+ - lib/gravtastic/engine.rb
33
25
  - lib/gravtastic/version.rb
34
26
  - lib/gravtastic.rb
35
27
  - spec/gravtastic_spec.rb
36
28
  - spec/helper.rb
37
- has_rdoc: false
29
+ - vendor/assets/javascripts/gravtastic.coffee
30
+ - vendor/assets/javascripts/md5.js
31
+ has_rdoc: true
38
32
  homepage: http://github.com/chrislloyd/gravtastic
39
33
  licenses: []
40
-
41
- post_install_message:
34
+ post_install_message: !!null
42
35
  rdoc_options: []
43
-
44
- require_paths:
36
+ require_paths:
45
37
  - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
38
+ required_ruby_version: !ruby/object:Gem::Requirement
47
39
  none: false
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- segments:
52
- - 0
53
- version: "0"
54
- required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
45
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- segments:
60
- - 0
61
- version: "0"
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
62
50
  requirements: []
63
-
64
51
  rubyforge_project: gravtastic
65
- rubygems_version: 1.3.7
66
- signing_key:
52
+ rubygems_version: 1.5.0
53
+ signing_key: !!null
67
54
  specification_version: 3
68
55
  summary: A Ruby wrapper for Gravatar URLs
69
56
  test_files: []
70
-