ren_ren 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ GEM
2
+ remote: http://ruby.taobao.org/
3
+ remote: http://gemcutter.org/
4
+ remote: http://gems.github.com/
5
+ specs:
6
+ git (1.2.5)
7
+ jeweler (1.5.2)
8
+ bundler (~> 1.0.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ json (1.6.4)
12
+ multi_json (1.0.4)
13
+ rake (0.9.2.2)
14
+ rcov (0.9.11)
15
+ rdoc (3.12)
16
+ json (~> 1.4)
17
+ riot (0.12.5)
18
+ rr
19
+ rr (1.0.4)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ bundler (~> 1.0.0)
26
+ jeweler (~> 1.5.2)
27
+ multi_json (~> 1.0.4)
28
+ rcov
29
+ rdoc
30
+ riot
@@ -2,15 +2,15 @@
2
2
 
3
3
  A third party, non-official renren API gem created by Eiffel Qiu
4
4
 
5
- == Contributing to ren_ren
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
5
+ To install the gem simply enter:
6
+
7
+ gem install ren_ren
8
+
9
+ This is a minimalistic API implementation, where all function calls goes through a single method. For example to publish a feed item one might do the following:
10
+
11
+ RenRen::Config.access_token = "XXXX"
12
+ renren = RenRen::Base.new(RenRen::Config.access_token)
13
+ renren.api({:method, "users.getInfo"})
14
14
 
15
15
  == Copyright
16
16
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -0,0 +1,3 @@
1
+ api_key: 1cd9fe46f45046c58b1e1393a340b167
2
+ api_secret: 369c07af41a8487cb2127bf97044c839
3
+ access_token: 158581|6.c94545f703133d081e7a3a104c7952fe.2592000.1326452400-433516336
@@ -1,2 +1,10 @@
1
1
  require 'ren_ren/config'
2
2
  require 'ren_ren/base'
3
+ require 'yaml'
4
+
5
+ if File.exists?('config/config.yml')
6
+ config = YAML.load_file('config/config.yml')
7
+ RenRen::Config.api_key = config["api_key"]
8
+ RenRen::Config.api_secret = config["api_secret"]
9
+ RenRen::Config.access_token = config["access_token"]
10
+ end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'uri'
3
+ require 'multi_json'
4
+ require 'net/http'
5
+ require 'digest'
6
+
7
+ module RenRen
8
+ class Base
9
+
10
+ attr_accessor :params
11
+
12
+ def initialize(access_token)
13
+ @params = {}
14
+ @params[:method] = "users.getInfo"
15
+ @params[:call_id] = Time.now.to_i
16
+ @params[:format] = 'json'
17
+ @params[:v] = '1.0'
18
+ @params[:access_token] = access_token
19
+ end
20
+
21
+ def api(opts = {:method => "users.getInfo"})
22
+ MultiJson.decode(Net::HTTP.post_form(URI.parse('http://api.renren.com/restserver.do'), merge_params(opts)).body)
23
+ end
24
+
25
+ private
26
+ def merge_params(opts)
27
+ params = @params.merge(opts){|key, first, second| second}
28
+ params[:sig] = Digest::MD5.hexdigest(params.map{|k,v| "#{k}=#{v}"}.sort.join + RenRen::Config.api_secret)
29
+ params
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,29 @@
1
+ module RenRen
2
+ module Config
3
+
4
+ def self.api_key=(val)
5
+ @@api_key = val
6
+ end
7
+
8
+ def self.api_key
9
+ @@api_key
10
+ end
11
+
12
+ def self.api_secret=(val)
13
+ @@api_secret = val
14
+ end
15
+
16
+ def self.api_secret
17
+ @@api_secret
18
+ end
19
+
20
+ def self.access_token=(val)
21
+ @@access_token = val
22
+ end
23
+
24
+ def self.access_token
25
+ @@access_token
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,72 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "ren_ren"
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Eiffel Q"]
12
+ s.date = "2011-12-29"
13
+ s.description = "renren api ruby gem"
14
+ s.email = "eiffelqiu@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "config/config.yml",
28
+ "lib/ren_ren.rb",
29
+ "lib/ren_ren/base.rb",
30
+ "lib/ren_ren/config.rb",
31
+ "ren_ren.gemspec",
32
+ "test/ren_ren_test.rb",
33
+ "test/teststrap.rb"
34
+ ]
35
+ s.homepage = "http://github.com/eiffelqiu/ren_ren"
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = "1.8.13"
39
+ s.summary = "renren api ruby gem"
40
+ s.test_files = [
41
+ "test/ren_ren_test.rb",
42
+ "test/teststrap.rb"
43
+ ]
44
+
45
+ if s.respond_to? :specification_version then
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ s.add_development_dependency(%q<riot>, [">= 0"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
52
+ s.add_development_dependency(%q<rcov>, [">= 0"])
53
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
54
+ s.add_development_dependency(%q<multi_json>, ["~> 1.0.4"])
55
+ else
56
+ s.add_dependency(%q<riot>, [">= 0"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
59
+ s.add_dependency(%q<rcov>, [">= 0"])
60
+ s.add_dependency(%q<rdoc>, [">= 0"])
61
+ s.add_dependency(%q<multi_json>, ["~> 1.0.4"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<riot>, [">= 0"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
67
+ s.add_dependency(%q<rcov>, [">= 0"])
68
+ s.add_dependency(%q<rdoc>, [">= 0"])
69
+ s.add_dependency(%q<multi_json>, ["~> 1.0.4"])
70
+ end
71
+ end
72
+
@@ -2,10 +2,19 @@ require 'teststrap'
2
2
 
3
3
  context "ren_ren" do
4
4
  setup do
5
- false
5
+ RenRen::Base.new(RenRen::Config.access_token)
6
6
  end
7
7
 
8
- # asserts "i'm a failure :(" do
9
- # topic
10
- # end
8
+ context "user info" do
9
+ asserts("user info is not null") { !topic.api().empty? }
10
+ asserts("user's sex") { topic.api()[0]['sex'] == 1 }
11
+ asserts("user's uid") { topic.api()[0]['uid'] == 433516336 }
12
+ asserts("user's name") { topic.api()[0]['name'] == "锐思互动" }
13
+ end
14
+
15
+ context "feed info" do
16
+ asserts("user info is not null") { !topic.api().empty? }
17
+ asserts("feed info is not null") { !topic.api({:method => "feed.get", :uid => topic.api()[0]['uid']}).empty? }
18
+ asserts("user's name")
19
+ end
11
20
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ren_ren
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eiffel Q
@@ -119,11 +119,16 @@ extra_rdoc_files:
119
119
  files:
120
120
  - .document
121
121
  - Gemfile
122
+ - Gemfile.lock
122
123
  - LICENSE.txt
123
124
  - README.rdoc
124
125
  - Rakefile
125
126
  - VERSION
127
+ - config/config.yml
126
128
  - lib/ren_ren.rb
129
+ - lib/ren_ren/base.rb
130
+ - lib/ren_ren/config.rb
131
+ - ren_ren.gemspec
127
132
  - test/ren_ren_test.rb
128
133
  - test/teststrap.rb
129
134
  homepage: http://github.com/eiffelqiu/ren_ren