daum_oauth 0.1.0

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/Manifest ADDED
@@ -0,0 +1,10 @@
1
+ README
2
+ README.rdoc
3
+ Rakefile
4
+ lib/daum_oauth.rb
5
+ lib/daum_oauth/cafe.rb
6
+ lib/daum_oauth/client.rb
7
+ lib/daum_oauth/yozm.rb
8
+ test.rb
9
+ text.rdoc
10
+ Manifest
data/README ADDED
File without changes
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Daum OAuth
2
+
3
+ Daum OAuth client API library for ruby.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('daum_oauth', '0.1.0') do |p|
6
+ p.description = 'Daum OAuth API client library for ruby'
7
+ p.url = 'http://github.com/thefron/daum_oauth'
8
+ p.author = 'Hoseong Hwang'
9
+ p.email = 'thefron@wafflestudio.com'
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{daum_oauth}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Hoseong Hwang"]
9
+ s.date = %q{2010-10-29}
10
+ s.description = %q{Daum OAuth API client library for ruby}
11
+ s.email = %q{thefron@wafflestudio.com}
12
+ s.extra_rdoc_files = ["README", "README.rdoc", "lib/daum_oauth.rb", "lib/daum_oauth/cafe.rb", "lib/daum_oauth/client.rb", "lib/daum_oauth/yozm.rb"]
13
+ s.files = ["README", "README.rdoc", "Rakefile", "lib/daum_oauth.rb", "lib/daum_oauth/cafe.rb", "lib/daum_oauth/client.rb", "lib/daum_oauth/yozm.rb", "test.rb", "text.rdoc", "Manifest", "daum_oauth.gemspec"]
14
+ s.homepage = %q{http://github.com/thefron/daum_oauth}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Daum_oauth", "--main", "README"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{daum_oauth}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{Daum OAuth API client library for ruby}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
@@ -0,0 +1,28 @@
1
+ #methods for cafe
2
+
3
+ module DaumOAuth
4
+ class Client
5
+ def cafe_favorites
6
+ get("/cafe/favorite_cafes.json")
7
+ end
8
+
9
+ def cafe_alimis
10
+ get("/cafe/alimis.json")
11
+ end
12
+
13
+ def cafe_articles(cafeCode, boardId, page=1)
14
+ get("/cafe/articles/#{cafeCode}/#{boardId}.json?page=#{page}")
15
+ end
16
+
17
+ def cafe_boards(cafeCode)
18
+ get("/cafe/boards/#{cafeCode}.json")
19
+ end
20
+
21
+ def cafe_recent_articles(cafeCode)
22
+ get("/cafe/recent_articles/#{cafeCode}.json")
23
+ end
24
+
25
+ #def cafe_write_article
26
+
27
+ end
28
+ end
@@ -0,0 +1,63 @@
1
+ require 'daum_oauth/yozm'
2
+ require 'daum_oauth/cafe'
3
+
4
+ module DaumOAuth
5
+ class Client
6
+ def initialize(options = {})
7
+ @consumer_key = options[:consumer_key]
8
+ @consumer_secret = options[:consumer_secret]
9
+ @token = options[:token]
10
+ @secret = options[:secret]
11
+ #@callback_url = options[:callback_url]
12
+ end
13
+
14
+ def authorize(token, secret, options = {})
15
+ request_token = OAuth::RequestToken.new(
16
+ consumer, token, secret
17
+ )
18
+ @access_token = request_token.get_access_token(options)
19
+ @token = @access_token.token
20
+ @secret = @access_token.secret
21
+ @access_token
22
+ end
23
+
24
+ def request_token(options={})
25
+ consumer.get_request_token(options)
26
+ end
27
+
28
+ def authentication_request_token(options = {})
29
+ request_token(options)
30
+ end
31
+
32
+ private
33
+
34
+ def consumer
35
+ @consumer ||= OAuth::Consumer.new(
36
+ @consumer_key,
37
+ @consumer_secret,
38
+ {
39
+ :site => 'https://apis.daum.net',
40
+ :request_token_path => '/oauth/requestToken',
41
+ :access_token_path => '/oauth/accessToken',
42
+ :authorize_path => '/oauth/authorize'
43
+ }
44
+ )
45
+ end
46
+
47
+ def access_token
48
+ @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)
49
+ end
50
+
51
+ def get(path, headers={})
52
+ headers.merge!("User-Agent" => "daum_oauth gem v#{DaumOAuth::VERSION}")
53
+ oauth_response = access_token.get(path, headers)
54
+ JSON.parse oauth_response.body
55
+ end
56
+
57
+ def post(path, body='', headers={})
58
+ headers.merge!("User-Agent" => "daum_oauth gem v#{DaumOAuth::VERSION}")
59
+ oauth_response = access_token.post(path, body, headers)
60
+ JSON.parse oauth_response.body
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,31 @@
1
+ #methods for yozm
2
+
3
+ module DaumOAuth
4
+ class Client
5
+
6
+ #check if authorized to yozm
7
+ def yozm_authorized?
8
+ user_info = yozm_show
9
+ !user_info.nil? and user_info['status'] == 200
10
+ end
11
+
12
+ #gets user info
13
+ #if authorized with oauth, the authorized user's info will be returned.
14
+ #Otherwise, you can specify nick_name or url_name.
15
+ def yozm_show(options = nil)
16
+ if options.nil?
17
+ return get("/yozm/v1_0/user/show.json")
18
+ elsif options[:url_name]
19
+ return get("/yozm/v1_0/user/show.json?url_name=#{options[:url_name]}")
20
+ else options[:nick_name]
21
+ return get("/yozm/v1_0/user/show.json?nick_name=#{options[:nick_name]}")
22
+ end
23
+ end
24
+
25
+ #send a message to yozm
26
+ def yozm_add(message, options={})
27
+ #post("/yozm/v1_0/message/add.json", options.merge(:message => message))
28
+ post("/yozm/v1_0/message/add.json", {:message => message})
29
+ end
30
+ end
31
+ end
data/lib/daum_oauth.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'oauth'
2
+ require 'json'
3
+
4
+ require 'daum_oauth/client'
5
+
6
+ module DaumOAuth
7
+ VERSION = '0.1.0'
8
+ end
data/test.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'daum_oauth'
3
+ Client = DaumOAuth::Client.new({:consumer_key => '90871bef-fefc-4078-ba9d-121a49c7099a', :consumer_secret => '89ct6-p-v-yqMOf7osfL7PQfnweAG68QepXRl4zn9quCIjrVcpZcZA00'})
4
+ request_token = Client.request_token(:oauth_callback => 'http://wafflestudio.net/~thefron/callback.html')
5
+ puts "authorize url: #{request_token.authorize_url}"
6
+ oauth_verifier = gets.strip
7
+ access_token = Client.authorize(request_token.token, request_token.secret, :oauth_verifier => oauth_verifier)
data/text.rdoc ADDED
File without changes
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: daum_oauth
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Hoseong Hwang
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-29 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Daum OAuth API client library for ruby
23
+ email: thefron@wafflestudio.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README
30
+ - README.rdoc
31
+ - lib/daum_oauth.rb
32
+ - lib/daum_oauth/cafe.rb
33
+ - lib/daum_oauth/client.rb
34
+ - lib/daum_oauth/yozm.rb
35
+ files:
36
+ - README
37
+ - README.rdoc
38
+ - Rakefile
39
+ - lib/daum_oauth.rb
40
+ - lib/daum_oauth/cafe.rb
41
+ - lib/daum_oauth/client.rb
42
+ - lib/daum_oauth/yozm.rb
43
+ - test.rb
44
+ - text.rdoc
45
+ - Manifest
46
+ - daum_oauth.gemspec
47
+ has_rdoc: true
48
+ homepage: http://github.com/thefron/daum_oauth
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --line-numbers
54
+ - --inline-source
55
+ - --title
56
+ - Daum_oauth
57
+ - --main
58
+ - README
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 11
76
+ segments:
77
+ - 1
78
+ - 2
79
+ version: "1.2"
80
+ requirements: []
81
+
82
+ rubyforge_project: daum_oauth
83
+ rubygems_version: 1.3.7
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Daum OAuth API client library for ruby
87
+ test_files: []
88
+