microid 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/microid.rb +53 -0
  2. metadata +49 -0
data/microid.rb ADDED
@@ -0,0 +1,53 @@
1
+ # = microid.rb
2
+ #
3
+ # This file is MicroID implementation in ruby
4
+ #
5
+ # Visit http://microid.org for further information.
6
+ #
7
+ # Copyright (c) 2007 Antono Vasiljev <antono.vasiljev@gmail.com>
8
+ #
9
+ # This library is distributed under the terms of the Ruby license.
10
+ # You can freely distribute/modify this library.
11
+
12
+ require 'digest/sha1'
13
+
14
+ module Microid
15
+ #
16
+ # == Usage:
17
+ #
18
+ # # Common to both below cases:
19
+ #
20
+ #
21
+ # require 'microid'
22
+ #
23
+ # # As module function:
24
+ #
25
+ #
26
+ # puts Microid::make("http://esperanto.org","mailto:stallman@esperanto.org")
27
+ #
28
+ # http+mailto:sha1:8898cc07ddd28867b5a60cbbf7a063593cc7b83f
29
+ #
30
+ # # As mixed in function
31
+ #
32
+ # include Microid
33
+ #
34
+ # puts make_microid('http://esperanto.org','mailto:stallman@esperanto.org')
35
+ #
36
+ # http+mailto:sha1:8898cc07ddd28867b5a60cbbf7a063593cc7b83f
37
+ #
38
+ def make_microid(first_uri, second_uri)
39
+ [
40
+ [
41
+ [ first_uri.split(':').first, second_uri.split(':').first ].join('+'),
42
+ 'sha1',
43
+ Digest::SHA1.hexdigest(
44
+ [ Digest::SHA1.hexdigest(first_uri),
45
+ Digest::SHA1.hexdigest(second_uri) ].join )
46
+ ].join(':')
47
+ ]
48
+ end
49
+
50
+ alias :make :make_microid
51
+ module_function :make
52
+
53
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: microid
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2007-10-29 00:00:00 +02:00
8
+ summary: MicroID function
9
+ require_paths:
10
+ - .
11
+ email: antono.vasiljev@gmail.com
12
+ homepage: http://microid.rubyforge.org
13
+ rubyforge_project: xilo
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Antono Vasiljev
31
+ files:
32
+ - microid.rb
33
+ test_files: []
34
+
35
+ rdoc_options:
36
+ - --main=microid.rb
37
+ - --line-numbers
38
+ - --charset=utf-8
39
+ - --promiscuous
40
+ extra_rdoc_files: []
41
+
42
+ executables: []
43
+
44
+ extensions: []
45
+
46
+ requirements: []
47
+
48
+ dependencies: []
49
+