hyves_oauth 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in hyves_oauth.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require "hyves_oauth/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "hyves_oauth"
8
+ s.version = HyvesOAuth::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["Kevin van Dijk"]
11
+ s.email = ["kevin@madkangaroo.com"]
12
+ s.homepage = ""
13
+ s.summary = %q{A Ruby client for the Hyves API using OAuth}
14
+ s.description = %q{A Ruby client for the Hyves API using OAuth}
15
+
16
+ s.rubyforge_project = "hyves_oauth"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_dependency("oauth", ">= 0.4.4")
24
+ end
@@ -0,0 +1,55 @@
1
+ module HyvesOAuth
2
+ class Client
3
+ def initialize(options = {})
4
+ @consumer_key = options[:consumer_key]
5
+ @consumer_secret = options[:consumer_secret]
6
+ @token = options[:token]
7
+ @secret = options[:secret]
8
+
9
+ end
10
+
11
+ def request_token(options = {})
12
+ @request_token = consumer.get_request_token(options, {"strict_oauth_spec_response" => "true", "ha_method" => "auth.requesttoken", "methods" => "wwws.create,users.getLoggedin"})
13
+ end
14
+
15
+ def authorize_url
16
+ @request_token.authorize_url.gsub("http://data.hyves-api.nl/oauth/", "http://www.hyves.nl/api/")
17
+ end
18
+
19
+ def authorize(token, secret, options = {})
20
+ request_token = OAuth::RequestToken.new(consumer, token, secret)
21
+ @access_token = request_token.get_access_token(options, {"strict_oauth_spec_response" => "true", "ha_method" => "auth.accesstoken"})
22
+ @token = @access_token.token
23
+ @secret = @access_token.secret
24
+ @access_token
25
+ end
26
+
27
+ def update(message)
28
+ post("/", {"ha_method" => "wwws.create", "emotion" => message, "visibility" => "default"})
29
+ end
30
+
31
+ def get_logged_in
32
+ post "/", {"ha_method" => "users.getLoggedin"}
33
+ end
34
+ private
35
+ def consumer
36
+ @consumer ||= OAuth::Consumer.new(@consumer_key, @consumer_secret, {
37
+ :site => "http://data.hyves-api.nl",
38
+ :request_token_path => "/",
39
+ :access_token_path => "/",
40
+ :http_method => :post
41
+ })
42
+ end
43
+
44
+ def access_token
45
+ @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)
46
+ end
47
+
48
+ def post(path, body='', headers={})
49
+ body.merge!("ha_format" => "json")
50
+ headers.merge!("User-Agent" => "hyves_oauth gem v#{HyvesOAuth::VERSION}")
51
+ oauth_response = access_token.post("/1#{path}", body, headers)
52
+ JSON.parse(oauth_response.body)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module HyvesOAuth
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "hyves_oauth/client"
2
+ require "hyves_oauth/version"
3
+
4
+ module HyvesOAuth
5
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hyves_oauth
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Kevin van Dijk
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-27 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: oauth
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 0
32
+ - 4
33
+ - 4
34
+ version: 0.4.4
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: A Ruby client for the Hyves API using OAuth
38
+ email:
39
+ - kevin@madkangaroo.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - .gitignore
48
+ - Gemfile
49
+ - Rakefile
50
+ - hyves_oauth.gemspec
51
+ - lib/hyves_oauth.rb
52
+ - lib/hyves_oauth/client.rb
53
+ - lib/hyves_oauth/version.rb
54
+ has_rdoc: true
55
+ homepage: ""
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project: hyves_oauth
84
+ rubygems_version: 1.3.7
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: A Ruby client for the Hyves API using OAuth
88
+ test_files: []
89
+