proletarian-oauth 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +48 -0
- data/License.txt +20 -0
- data/Manifest.txt +71 -0
- data/README.rdoc +73 -0
- data/Rakefile +34 -0
- data/TODO +14 -0
- data/bin/oauth +5 -0
- data/lib/oauth/cli.rb +130 -0
- data/lib/oauth/client/action_controller_request.rb +52 -0
- data/lib/oauth/client/helper.rb +75 -0
- data/lib/oauth/client/net_http.rb +75 -0
- data/lib/oauth/client.rb +4 -0
- data/lib/oauth/consumer.rb +246 -0
- data/lib/oauth/helper.rb +17 -0
- data/lib/oauth/oauth_test_helper.rb +26 -0
- data/lib/oauth/request_proxy/action_controller_request.rb +62 -0
- data/lib/oauth/request_proxy/base.rb +107 -0
- data/lib/oauth/request_proxy/jabber_request.rb +42 -0
- data/lib/oauth/request_proxy/mock_request.rb +36 -0
- data/lib/oauth/request_proxy/net_http.rb +65 -0
- data/lib/oauth/request_proxy/rack_request.rb +40 -0
- data/lib/oauth/request_proxy.rb +24 -0
- data/lib/oauth/server.rb +68 -0
- data/lib/oauth/signature/base.rb +89 -0
- data/lib/oauth/signature/hmac/base.rb +12 -0
- data/lib/oauth/signature/hmac/md5.rb +9 -0
- data/lib/oauth/signature/hmac/rmd160.rb +9 -0
- data/lib/oauth/signature/hmac/sha1.rb +10 -0
- data/lib/oauth/signature/hmac/sha2.rb +9 -0
- data/lib/oauth/signature/md5.rb +13 -0
- data/lib/oauth/signature/plaintext.rb +23 -0
- data/lib/oauth/signature/rsa/sha1.rb +44 -0
- data/lib/oauth/signature/sha1.rb +13 -0
- data/lib/oauth/signature.rb +28 -0
- data/lib/oauth/token.rb +137 -0
- data/lib/oauth/version.rb +3 -0
- data/lib/oauth.rb +3 -0
- data/oauth.gemspec +43 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/cases/oauth_case.rb +19 -0
- data/test/cases/spec/1_0-final/test_construct_request_url.rb +62 -0
- data/test/cases/spec/1_0-final/test_normalize_request_parameters.rb +88 -0
- data/test/cases/spec/1_0-final/test_parameter_encodings.rb +86 -0
- data/test/cases/spec/1_0-final/test_signature_base_strings.rb +77 -0
- data/test/keys/rsa.cert +11 -0
- data/test/keys/rsa.pem +16 -0
- data/test/test_action_controller_request_proxy.rb +28 -0
- data/test/test_consumer.rb +328 -0
- data/test/test_helper.rb +15 -0
- data/test/test_hmac_sha1.rb +21 -0
- data/test/test_net_http_client.rb +169 -0
- data/test/test_net_http_request_proxy.rb +38 -0
- data/test/test_rack_request_proxy.rb +40 -0
- data/test/test_rsa_sha1.rb +59 -0
- data/test/test_server.rb +40 -0
- data/test/test_signature.rb +11 -0
- data/test/test_signature_base.rb +32 -0
- data/test/test_signature_plain_text.rb +31 -0
- data/test/test_token.rb +14 -0
- data/website/index.html +87 -0
- data/website/index.txt +73 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +177 -0
data/lib/oauth/server.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'oauth/helper'
|
2
|
+
require 'oauth/consumer'
|
3
|
+
module OAuth
|
4
|
+
# This is mainly used to create consumer credentials and can pretty much be ignored if you want to create your own
|
5
|
+
class Server
|
6
|
+
include OAuth::Helper
|
7
|
+
attr_accessor :base_url
|
8
|
+
|
9
|
+
@@server_paths={
|
10
|
+
:request_token_path=>"/oauth/request_token",
|
11
|
+
:authorize_path=>"/oauth/authorize",
|
12
|
+
:access_token_path=>"/oauth/access_token"
|
13
|
+
}
|
14
|
+
# Create a new server instance
|
15
|
+
def initialize(base_url,paths={})
|
16
|
+
@base_url=base_url
|
17
|
+
@paths=@@server_paths.merge(paths)
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate_credentials()
|
21
|
+
[generate_key(16),generate_key]
|
22
|
+
end
|
23
|
+
|
24
|
+
def generate_consumer_credentials(params={})
|
25
|
+
Consumer.new( *generate_credentials)
|
26
|
+
end
|
27
|
+
|
28
|
+
# mainly for testing purposes
|
29
|
+
def create_consumer
|
30
|
+
credentials=generate_credentials
|
31
|
+
Consumer.new(
|
32
|
+
credentials[0],
|
33
|
+
credentials[1],
|
34
|
+
{
|
35
|
+
:site=>base_url,
|
36
|
+
:request_token_path=>request_token_path,
|
37
|
+
:authorize_path=>authorize_path,
|
38
|
+
:access_token_path=>access_token_path
|
39
|
+
})
|
40
|
+
end
|
41
|
+
|
42
|
+
def request_token_path
|
43
|
+
@paths[:request_token_path]
|
44
|
+
end
|
45
|
+
|
46
|
+
def request_token_url
|
47
|
+
base_url+request_token_path
|
48
|
+
end
|
49
|
+
|
50
|
+
def authorize_path
|
51
|
+
@paths[:authorize_path]
|
52
|
+
end
|
53
|
+
|
54
|
+
def authorize_url
|
55
|
+
base_url+authorize_path
|
56
|
+
end
|
57
|
+
|
58
|
+
def access_token_path
|
59
|
+
@paths[:access_token_path]
|
60
|
+
end
|
61
|
+
|
62
|
+
def access_token_url
|
63
|
+
base_url+access_token_path
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'oauth/signature'
|
2
|
+
require 'oauth/helper'
|
3
|
+
require 'oauth/request_proxy/base'
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
module OAuth::Signature
|
7
|
+
class Base
|
8
|
+
include OAuth::Helper
|
9
|
+
|
10
|
+
attr_accessor :options
|
11
|
+
|
12
|
+
def self.implements(signature_method)
|
13
|
+
OAuth::Signature.available_methods[signature_method] = self
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.digest_class(digest_class = nil)
|
17
|
+
return @digest_class if digest_class.nil?
|
18
|
+
@digest_class = digest_class
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :token_secret, :consumer_secret, :request
|
22
|
+
|
23
|
+
def initialize(request, options = {}, &block)
|
24
|
+
raise TypeError unless request.kind_of?(OAuth::RequestProxy::Base)
|
25
|
+
@request = request
|
26
|
+
@options = options
|
27
|
+
|
28
|
+
if block_given?
|
29
|
+
|
30
|
+
# consumer secret and token secret need to be looked up based on pieces of the request
|
31
|
+
@token_secret, @consumer_secret = yield block.arity == 1 ? request : [token, consumer_key,nonce,request.timestamp]
|
32
|
+
|
33
|
+
else
|
34
|
+
## consumer secret was determined beforehand
|
35
|
+
|
36
|
+
@consumer_secret = options[:consumer].secret if options[:consumer]
|
37
|
+
|
38
|
+
# presence of :consumer_secret option will override any Consumer that's provided
|
39
|
+
@consumer_secret = options[:consumer_secret] if options[:consumer_secret]
|
40
|
+
|
41
|
+
## token secret was determined beforehand
|
42
|
+
|
43
|
+
@token_secret = options[:token].secret if options[:token]
|
44
|
+
|
45
|
+
# presence of :token_secret option will override any Token that's provided
|
46
|
+
@token_secret = options[:token_secret] if options[:token_secret]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def signature
|
51
|
+
Base64.encode64(digest).chomp.gsub(/\n/,'')
|
52
|
+
end
|
53
|
+
|
54
|
+
def ==(cmp_signature)
|
55
|
+
Base64.decode64(signature) == Base64.decode64(cmp_signature)
|
56
|
+
end
|
57
|
+
|
58
|
+
def verify
|
59
|
+
self == self.request.signature
|
60
|
+
end
|
61
|
+
|
62
|
+
def signature_base_string
|
63
|
+
request.signature_base_string
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def token
|
69
|
+
request.token
|
70
|
+
end
|
71
|
+
|
72
|
+
def consumer_key
|
73
|
+
request.consumer_key
|
74
|
+
end
|
75
|
+
|
76
|
+
def nonce
|
77
|
+
request.nonce
|
78
|
+
end
|
79
|
+
|
80
|
+
def secret
|
81
|
+
"#{escape(consumer_secret)}&#{escape(token_secret)}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def digest
|
85
|
+
self.class.digest_class.digest(signature_base_string)
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'oauth/signature/base'
|
2
|
+
|
3
|
+
module OAuth::Signature
|
4
|
+
class PLAINTEXT < Base
|
5
|
+
implements 'plaintext'
|
6
|
+
|
7
|
+
def signature
|
8
|
+
signature_base_string
|
9
|
+
end
|
10
|
+
|
11
|
+
def ==(cmp_signature)
|
12
|
+
signature == escape(cmp_signature)
|
13
|
+
end
|
14
|
+
|
15
|
+
def signature_base_string
|
16
|
+
secret
|
17
|
+
end
|
18
|
+
|
19
|
+
def secret
|
20
|
+
escape super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'oauth/signature/base'
|
2
|
+
require 'openssl'
|
3
|
+
|
4
|
+
module OAuth::Signature::RSA
|
5
|
+
class SHA1 < OAuth::Signature::Base
|
6
|
+
implements 'rsa-sha1'
|
7
|
+
|
8
|
+
def ==(cmp_signature)
|
9
|
+
public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(cmp_signature.is_a?(Array) ? cmp_signature.first : cmp_signature), signature_base_string)
|
10
|
+
end
|
11
|
+
|
12
|
+
def public_key
|
13
|
+
if consumer_secret.is_a?(String)
|
14
|
+
decode_public_key
|
15
|
+
elsif consumer_secret.is_a?(OpenSSL::X509::Certificate)
|
16
|
+
consumer_secret.public_key
|
17
|
+
else
|
18
|
+
consumer_secret
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def decode_public_key
|
25
|
+
case consumer_secret
|
26
|
+
when /-----BEGIN CERTIFICATE-----/
|
27
|
+
OpenSSL::X509::Certificate.new( consumer_secret).public_key
|
28
|
+
else
|
29
|
+
OpenSSL::PKey::RSA.new( consumer_secret)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def digest
|
34
|
+
private_key = OpenSSL::PKey::RSA.new(
|
35
|
+
if options[:private_key_file]
|
36
|
+
IO.read(options[:private_key_file])
|
37
|
+
else
|
38
|
+
consumer_secret
|
39
|
+
end
|
40
|
+
)
|
41
|
+
private_key.sign(OpenSSL::Digest::SHA1.new, signature_base_string)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module OAuth
|
2
|
+
module Signature
|
3
|
+
def self.available_methods
|
4
|
+
@available_methods ||= {}
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.build(request, options = {}, &block)
|
8
|
+
request = OAuth::RequestProxy.proxy(request, options)
|
9
|
+
klass = available_methods[(request.signature_method || "").downcase]
|
10
|
+
raise UnknownSignatureMethod, request.signature_method unless klass
|
11
|
+
klass.new(request, options, &block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.sign(request, options = {}, &block)
|
15
|
+
self.build(request, options, &block).signature
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.verify(request, options = {}, &block)
|
19
|
+
self.build(request, options, &block).verify
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.signature_base_string(request, options = {}, &block)
|
23
|
+
self.build(request, options, &block).signature_base_string
|
24
|
+
end
|
25
|
+
|
26
|
+
class UnknownSignatureMethod < Exception; end
|
27
|
+
end
|
28
|
+
end
|
data/lib/oauth/token.rb
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'oauth/helper'
|
2
|
+
module OAuth
|
3
|
+
|
4
|
+
# Superclass for the various tokens used by OAuth
|
5
|
+
|
6
|
+
class Token
|
7
|
+
include OAuth::Helper
|
8
|
+
|
9
|
+
attr_accessor :token, :secret
|
10
|
+
|
11
|
+
def initialize(token, secret)
|
12
|
+
@token = token
|
13
|
+
@secret = secret
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_query
|
17
|
+
"oauth_token=#{escape(token)}&oauth_secret=#{escape(secret)}"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
# Used on the server for generating tokens
|
23
|
+
class ServerToken<Token
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
super generate_key(16),generate_key
|
27
|
+
end
|
28
|
+
end
|
29
|
+
# Superclass for tokens used by OAuth Clients
|
30
|
+
class ConsumerToken<Token
|
31
|
+
attr_accessor :consumer
|
32
|
+
|
33
|
+
def initialize(consumer,token="",secret="")
|
34
|
+
super token,secret
|
35
|
+
@consumer=consumer
|
36
|
+
end
|
37
|
+
|
38
|
+
# Make a signed request using given http_method to the path
|
39
|
+
#
|
40
|
+
# @token.request(:get,'/people')
|
41
|
+
# @token.request(:post,'/people',@person.to_xml,{ 'Content-Type' => 'application/xml' })
|
42
|
+
#
|
43
|
+
def request(http_method,path,*arguments)
|
44
|
+
response=consumer.request(http_method,path,self,{},*arguments)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Sign a request generated elsewhere using Net:HTTP::Post.new or friends
|
48
|
+
def sign!(request,options = {})
|
49
|
+
consumer.sign!(request,self,options)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# The RequestToken is used for the initial Request.
|
55
|
+
# This is normally created by the Consumer object.
|
56
|
+
class RequestToken<ConsumerToken
|
57
|
+
|
58
|
+
# Returns the authorization url that you need to use for redirecting the user
|
59
|
+
def authorize_url
|
60
|
+
consumer.authorize_url+"?oauth_token="+CGI.escape(token)
|
61
|
+
end
|
62
|
+
|
63
|
+
# exchange for AccessToken on server
|
64
|
+
def get_access_token(options={})
|
65
|
+
response=consumer.token_request(consumer.http_method,(consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path),self,options)
|
66
|
+
OAuth::AccessToken.new(consumer,response[:oauth_token],response[:oauth_token_secret])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# The Access Token is used for the actual "real" web service calls thatyou perform against the server
|
71
|
+
class AccessToken<ConsumerToken
|
72
|
+
|
73
|
+
# The less intrusive way. Otherwise, if we are to do it correctly inside consumer,
|
74
|
+
# we need to restructure and touch more methods: request(), sign!(), etc.
|
75
|
+
def request(http_method, path, *arguments)
|
76
|
+
request_uri = URI.parse(path)
|
77
|
+
site_uri = consumer.uri
|
78
|
+
is_service_uri_different = (request_uri.absolute? && request_uri != site_uri)
|
79
|
+
consumer.uri(request_uri) if is_service_uri_different
|
80
|
+
resp = super(http_method, path, *arguments)
|
81
|
+
# NOTE: reset for wholesomeness? meaning that we admit only AccessToken service calls may use different URIs?
|
82
|
+
# so reset in case consumer is still used for other token-management tasks subsequently?
|
83
|
+
consumer.uri(site_uri) if is_service_uri_different
|
84
|
+
resp
|
85
|
+
end
|
86
|
+
|
87
|
+
# Make a regular get request using AccessToken
|
88
|
+
#
|
89
|
+
# @response=@token.get('/people')
|
90
|
+
# @response=@token.get('/people',{'Accept'=>'application/xml'})
|
91
|
+
#
|
92
|
+
def get(path,headers={})
|
93
|
+
request(:get,path,headers)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Make a regular head request using AccessToken
|
97
|
+
#
|
98
|
+
# @response=@token.head('/people')
|
99
|
+
#
|
100
|
+
def head(path,headers={})
|
101
|
+
request(:head,path,headers)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Make a regular post request using AccessToken
|
105
|
+
#
|
106
|
+
# @response=@token.post('/people')
|
107
|
+
# @response=@token.post('/people',{:name=>'Bob',:email=>'bob@mailinator.com'})
|
108
|
+
# @response=@token.post('/people',{:name=>'Bob',:email=>'bob@mailinator.com'},{'Accept'=>'application/xml'})
|
109
|
+
# @response=@token.post('/people',nil,{'Accept'=>'application/xml'})
|
110
|
+
# @response=@token.post('/people',@person.to_xml,{'Accept'=>'application/xml','Content-Type' => 'application/xml'})
|
111
|
+
#
|
112
|
+
def post(path, body = '',headers={})
|
113
|
+
request(:post,path,body,headers)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Make a regular put request using AccessToken
|
117
|
+
#
|
118
|
+
# @response=@token.put('/people/123')
|
119
|
+
# @response=@token.put('/people/123',{:name=>'Bob',:email=>'bob@mailinator.com'})
|
120
|
+
# @response=@token.put('/people/123',{:name=>'Bob',:email=>'bob@mailinator.com'},{'Accept'=>'application/xml'})
|
121
|
+
# @response=@token.put('/people/123',nil,{'Accept'=>'application/xml'})
|
122
|
+
# @response=@token.put('/people/123',@person.to_xml,{'Accept'=>'application/xml','Content-Type' => 'application/xml'})
|
123
|
+
#
|
124
|
+
def put(path, body = '', headers={})
|
125
|
+
request(:put,path,body,headers)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Make a regular delete request using AccessToken
|
129
|
+
#
|
130
|
+
# @response=@token.delete('/people/123')
|
131
|
+
# @response=@token.delete('/people/123',{'Accept'=>'application/xml'})
|
132
|
+
#
|
133
|
+
def delete(path,headers={})
|
134
|
+
request(:delete,path,headers)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
data/lib/oauth.rb
ADDED
data/oauth.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{oauth}
|
5
|
+
s.version = "0.3.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons"]
|
9
|
+
s.date = %q{2009-01-26}
|
10
|
+
s.default_executable = %q{oauth}
|
11
|
+
s.description = %q{OAuth Core Ruby implementation}
|
12
|
+
s.email = %q{pelleb@gmail.com}
|
13
|
+
s.executables = ["oauth"]
|
14
|
+
s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "website/index.txt"]
|
15
|
+
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "TODO", "bin/oauth", "lib/oauth.rb", "lib/oauth/cli.rb", "lib/oauth/client.rb", "lib/oauth/client/action_controller_request.rb", "lib/oauth/client/helper.rb", "lib/oauth/client/net_http.rb", "lib/oauth/consumer.rb", "lib/oauth/helper.rb", "lib/oauth/oauth_test_helper.rb", "lib/oauth/request_proxy.rb", "lib/oauth/request_proxy/action_controller_request.rb", "lib/oauth/request_proxy/base.rb", "lib/oauth/request_proxy/jabber_request.rb", "lib/oauth/request_proxy/mock_request.rb", "lib/oauth/request_proxy/net_http.rb", "lib/oauth/request_proxy/rack_request.rb", "lib/oauth/server.rb", "lib/oauth/signature.rb", "lib/oauth/signature/base.rb", "lib/oauth/signature/hmac/base.rb", "lib/oauth/signature/hmac/md5.rb", "lib/oauth/signature/hmac/rmd160.rb", "lib/oauth/signature/hmac/sha1.rb", "lib/oauth/signature/hmac/sha2.rb", "lib/oauth/signature/md5.rb", "lib/oauth/signature/plaintext.rb", "lib/oauth/signature/rsa/sha1.rb", "lib/oauth/signature/sha1.rb", "lib/oauth/token.rb", "lib/oauth/version.rb", "oauth.gemspec", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "test/cases/oauth_case.rb", "test/cases/spec/1_0-final/test_construct_request_url.rb", "test/cases/spec/1_0-final/test_normalize_request_parameters.rb", "test/cases/spec/1_0-final/test_parameter_encodings.rb", "test/cases/spec/1_0-final/test_signature_base_strings.rb", "test/keys/rsa.cert", "test/keys/rsa.pem", "test/test_action_controller_request_proxy.rb", "test/test_consumer.rb", "test/test_helper.rb", "test/test_hmac_sha1.rb", "test/test_net_http_client.rb", "test/test_net_http_request_proxy.rb", "test/test_rack_request_proxy.rb", "test/test_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_plain_text.rb", "test/test_token.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.rhtml"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://oauth.rubyforge.org}
|
18
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubyforge_project = %q{oauth}
|
21
|
+
s.rubygems_version = %q{1.3.1}
|
22
|
+
s.summary = %q{OAuth Core Ruby implementation}
|
23
|
+
s.test_files = ["test/cases/spec/1_0-final/test_construct_request_url.rb", "test/cases/spec/1_0-final/test_normalize_request_parameters.rb", "test/cases/spec/1_0-final/test_parameter_encodings.rb", "test/cases/spec/1_0-final/test_signature_base_strings.rb", "test/test_action_controller_request_proxy.rb", "test/test_consumer.rb", "test/test_helper.rb", "test/test_hmac_sha1.rb", "test/test_net_http_client.rb", "test/test_net_http_request_proxy.rb", "test/test_rack_request_proxy.rb", "test/test_rsa_sha1.rb", "test/test_server.rb", "test/test_signature.rb", "test/test_signature_base.rb", "test/test_signature_plain_text.rb", "test/test_token.rb"]
|
24
|
+
|
25
|
+
if s.respond_to? :specification_version then
|
26
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
27
|
+
s.specification_version = 2
|
28
|
+
|
29
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
30
|
+
s.add_runtime_dependency(%q<ruby-hmac>, [">= 0.3.1"])
|
31
|
+
s.add_development_dependency(%q<newgem>, [">= 1.2.3"])
|
32
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<ruby-hmac>, [">= 0.3.1"])
|
35
|
+
s.add_dependency(%q<newgem>, [">= 1.2.3"])
|
36
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
37
|
+
end
|
38
|
+
else
|
39
|
+
s.add_dependency(%q<ruby-hmac>, [">= 0.3.1"])
|
40
|
+
s.add_dependency(%q<newgem>, [">= 1.2.3"])
|
41
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
42
|
+
end
|
43
|
+
end
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
begin
|
5
|
+
require 'newgem'
|
6
|
+
rescue LoadError
|
7
|
+
puts "\n\nGenerating the website requires the newgem RubyGem"
|
8
|
+
puts "Install: gem install newgem\n\n"
|
9
|
+
exit(1)
|
10
|
+
end
|
11
|
+
require 'redcloth'
|
12
|
+
require 'syntax/convertors/html'
|
13
|
+
require 'erb'
|
14
|
+
require File.dirname(__FILE__) + '/../lib/oauth/version.rb'
|
15
|
+
|
16
|
+
version = OAuth::VERSION::STRING
|
17
|
+
download = 'http://rubyforge.org/projects/oauth'
|
18
|
+
|
19
|
+
class Fixnum
|
20
|
+
def ordinal
|
21
|
+
# teens
|
22
|
+
return 'th' if (10..19).include?(self % 100)
|
23
|
+
# others
|
24
|
+
case self % 10
|
25
|
+
when 1: return 'st'
|
26
|
+
when 2: return 'nd'
|
27
|
+
when 3: return 'rd'
|
28
|
+
else return 'th'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Time
|
34
|
+
def pretty
|
35
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def convert_syntax(syntax, source)
|
40
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
41
|
+
end
|
42
|
+
|
43
|
+
if ARGV.length >= 1
|
44
|
+
src, template = ARGV
|
45
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
|
46
|
+
|
47
|
+
else
|
48
|
+
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
49
|
+
exit!
|
50
|
+
end
|
51
|
+
|
52
|
+
template = ERB.new(File.open(template).read)
|
53
|
+
|
54
|
+
title = nil
|
55
|
+
body = nil
|
56
|
+
File.open(src) do |fsrc|
|
57
|
+
title_text = fsrc.readline
|
58
|
+
body_text = fsrc.read
|
59
|
+
syntax_items = []
|
60
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
61
|
+
ident = syntax_items.length
|
62
|
+
element, syntax, source = $1, $2, $3
|
63
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
64
|
+
"syntax-temp-#{ident}"
|
65
|
+
}
|
66
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
67
|
+
body = RedCloth.new(body_text).to_html
|
68
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
69
|
+
end
|
70
|
+
stat = File.stat(src)
|
71
|
+
created = stat.ctime
|
72
|
+
modified = stat.mtime
|
73
|
+
|
74
|
+
$stdout << template.result(binding)
|