em-convore 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 +4 -0
- data/Gemfile +4 -0
- data/README.md +12 -0
- data/Rakefile +2 -0
- data/convore.gemspec +25 -0
- data/lib/convore.rb +18 -0
- data/lib/convore/account.rb +33 -0
- data/lib/convore/api.rb +22 -0
- data/lib/convore/base.rb +69 -0
- data/lib/convore/client.rb +47 -0
- data/lib/convore/group.rb +102 -0
- data/lib/convore/message.rb +25 -0
- data/lib/convore/topic.rb +64 -0
- data/lib/convore/user.rb +16 -0
- data/lib/convore/version.rb +3 -0
- data/test/test_account.rb +39 -0
- data/test/test_group.rb +98 -0
- data/test/test_message.rb +24 -0
- data/test/test_topic.rb +48 -0
- data/test/test_user.rb +18 -0
- metadata +136 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
data/convore.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "convore/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "em-convore"
|
7
|
+
s.version = Convore::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Carlos Vilhena"]
|
10
|
+
s.email = ["carlosvilhena@gmail.com"]
|
11
|
+
s.homepage = "http://carvil.github.com"
|
12
|
+
s.summary = %q{A convore.com API implementation in ruby using EM}
|
13
|
+
s.description = %q{A convore.com API implementation in ruby using EM}
|
14
|
+
|
15
|
+
# s.rubyforge_project = "convore"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency('eventmachine','0.12.10')
|
23
|
+
s.add_dependency('rest-client','1.6.7')
|
24
|
+
s.add_dependency('em-http-request','0.3.0')
|
25
|
+
end
|
data/lib/convore.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'em-http-request'
|
5
|
+
|
6
|
+
module Convore
|
7
|
+
end
|
8
|
+
|
9
|
+
require_relative 'convore/version'
|
10
|
+
|
11
|
+
require_relative 'convore/api'
|
12
|
+
require_relative 'convore/base'
|
13
|
+
require_relative 'convore/user'
|
14
|
+
require_relative 'convore/group'
|
15
|
+
require_relative 'convore/topic'
|
16
|
+
require_relative 'convore/message'
|
17
|
+
require_relative 'convore/client'
|
18
|
+
require_relative 'convore/account'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
|
3
|
+
module Convore
|
4
|
+
class Account < Base
|
5
|
+
attr_accessor :username, :password
|
6
|
+
|
7
|
+
def initialize(username, password)
|
8
|
+
@username = username
|
9
|
+
@password = password
|
10
|
+
end
|
11
|
+
|
12
|
+
#Use this method to check if the user is properly logged in (also get user id)
|
13
|
+
def verified?
|
14
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/account/verify.json"
|
15
|
+
end
|
16
|
+
|
17
|
+
#Mark all messages as read
|
18
|
+
def mark_all_read
|
19
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/account/mark_read.json", {}
|
20
|
+
end
|
21
|
+
|
22
|
+
#Get members online now
|
23
|
+
def get_members_online
|
24
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/account/online.json"
|
25
|
+
end
|
26
|
+
|
27
|
+
#Get the users mentions
|
28
|
+
def get_mentions
|
29
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/account/online.json"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
data/lib/convore/api.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# TODO: Establish link to client connect, to use their username/password?
|
2
|
+
|
3
|
+
module Convore
|
4
|
+
class API
|
5
|
+
class << self
|
6
|
+
def cache
|
7
|
+
@@cache ||= {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def get(api_uri, username=nil, password=nil)
|
11
|
+
response = cache[api_uri] ? cache[api_uri] :
|
12
|
+
Net::HTTP.start('convore.com', 443, nil, nil, nil, nil, {:use_ssl => true}) {|http|
|
13
|
+
req = Net::HTTP::Get.new(api_uri)
|
14
|
+
req.basic_auth(username, password) if username && password
|
15
|
+
req.set_content_type('application/json')
|
16
|
+
http.request(req)
|
17
|
+
}
|
18
|
+
cache[api_uri] = response
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/convore/base.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
module Convore
|
2
|
+
class Base
|
3
|
+
attr_accessor :attributes, :username, :password
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@attributes ||= {}
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def method_missing(method, *args)
|
11
|
+
@attributes = {} if @attributes.nil?
|
12
|
+
if method.match(/\=/)
|
13
|
+
@attributes[method.to_s.gsub(/\=$/, '').to_sym] = args.first
|
14
|
+
return true
|
15
|
+
else
|
16
|
+
return @attributes[method] if @attributes[method]
|
17
|
+
end
|
18
|
+
raise NoMethodError.new("no such method: #{method}")
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
class << self
|
23
|
+
|
24
|
+
def get_class(key)
|
25
|
+
case key
|
26
|
+
when 'message' then Message
|
27
|
+
when 'user', 'creator', 'mentioned_user' then User
|
28
|
+
when 'group' then Group
|
29
|
+
when 'topic' then Topic
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def from_json(json)
|
34
|
+
return nil if !json
|
35
|
+
|
36
|
+
object = new(@username, @password)
|
37
|
+
json.each {|key, val|
|
38
|
+
key_class = get_class(key)
|
39
|
+
|
40
|
+
value = if val.is_a?(Hash) && key_class
|
41
|
+
key_class.from_json(json[key])
|
42
|
+
elsif val.is_a?(Numeric) && key_class && key_class.api
|
43
|
+
key_class.find(val)
|
44
|
+
else
|
45
|
+
val
|
46
|
+
end
|
47
|
+
|
48
|
+
object.send("#{key}=", value)
|
49
|
+
}
|
50
|
+
object
|
51
|
+
end
|
52
|
+
|
53
|
+
def api
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def find(rid)
|
58
|
+
return false if !api || !rid.is_a?(Numeric)
|
59
|
+
|
60
|
+
api_uri = "/api/#{api[-1] == 's' ? api : "#{api}s"}/#{rid}.json"
|
61
|
+
|
62
|
+
response = Convore::API.get(api_uri)
|
63
|
+
|
64
|
+
json = JSON.parse(response.body)
|
65
|
+
from_json(json[api])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
module Convore
|
3
|
+
class Client
|
4
|
+
attr_accessor :thread, :stream, :cursor, :username, :password
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@stream ||= []
|
8
|
+
@ts ||= Time.now.to_f
|
9
|
+
end
|
10
|
+
|
11
|
+
def listen
|
12
|
+
raise Exception.new("username and password need to be set to listen to /live") if !username || !password
|
13
|
+
|
14
|
+
http = EM::HttpRequest.new("https://convore.com/api/live.json?cursor=#{@cursor if @cursor}").get :head => {'authorization' => ["#{@username}", "#{@password}"]}
|
15
|
+
|
16
|
+
http.callback {
|
17
|
+
process_response(http.response)
|
18
|
+
}
|
19
|
+
|
20
|
+
http.errback {
|
21
|
+
}
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def process_response(response)
|
26
|
+
json = JSON.parse(response)
|
27
|
+
|
28
|
+
if json['messages']
|
29
|
+
json['messages'].each {|msg|
|
30
|
+
if msg['_ts'] && @ts < msg['_ts']
|
31
|
+
case msg['kind']
|
32
|
+
when 'message' then
|
33
|
+
stream.unshift(Message.from_json(msg))
|
34
|
+
when 'topic' then
|
35
|
+
stream.unshift(Topic.from_json(msg))
|
36
|
+
when 'star', 'unstar' then
|
37
|
+
stream.unshift(Star.from_json(msg))
|
38
|
+
end
|
39
|
+
@ts = msg['_ts'] if msg['_ts']
|
40
|
+
@cursor = msg['_id'] if msg['_id']
|
41
|
+
end
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#If posts don't have a mandatory payload they need to be fed a hash {}
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
module Convore
|
5
|
+
class Group < Base
|
6
|
+
attr_accessor :username, :password
|
7
|
+
|
8
|
+
def initialize(username, password)
|
9
|
+
@username = username
|
10
|
+
@password = password
|
11
|
+
end
|
12
|
+
|
13
|
+
#Get a list of the current user's groups
|
14
|
+
def get_groups
|
15
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/groups.json"
|
16
|
+
end
|
17
|
+
|
18
|
+
#Create a new group.
|
19
|
+
def create_group(hash)
|
20
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/create.json",
|
21
|
+
{:name => hash[:name],
|
22
|
+
:kind => hash[:kind],
|
23
|
+
#from here down optional
|
24
|
+
:description => hash[:description],
|
25
|
+
:slug => hash[:slug]}
|
26
|
+
end
|
27
|
+
|
28
|
+
#Get detailed information about the group
|
29
|
+
def get_group_info(group_id)
|
30
|
+
if group_id.integer?
|
31
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}.json"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#Get the group members
|
36
|
+
def get_group_members(group_id, *hash)
|
37
|
+
if group_id.integer?
|
38
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/members.json",
|
39
|
+
#from here down optional
|
40
|
+
#{:filter => hash[:admin]}
|
41
|
+
hash[0]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
#Join a public group
|
46
|
+
def join_public_group(group_id)
|
47
|
+
if group_id.integer?
|
48
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/join.json", {}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
#Requests to join a private group
|
53
|
+
def join_private_group(group_id)
|
54
|
+
if group_id.integer?
|
55
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/request.json", ()
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
#Leave a group
|
60
|
+
def leave_group(group_id)
|
61
|
+
if group_id.integer?
|
62
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/leave.json", {}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#Get group members online now
|
67
|
+
def get_online_members(group_id)
|
68
|
+
if group_id.integer?
|
69
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/online.json", {}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
#Get the latest topics in a group
|
74
|
+
def get_latest_topics(group_id, *hash)
|
75
|
+
if group_id.integer?
|
76
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/topics.json",
|
77
|
+
#from here down optional (pagination)
|
78
|
+
#{:until_id => hash[:until_id]}
|
79
|
+
hash[0]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
#Create a new topic
|
84
|
+
def create_topic(group_id, hash)
|
85
|
+
if group_id.integer?
|
86
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/topics/create.json",
|
87
|
+
{:name => hash[:name]}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
#Mark all messages in the group as read
|
92
|
+
def mark_all_read(group_id)
|
93
|
+
if group_id.integer?
|
94
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/groups/#{group_id}/mark_read.json", {}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.api
|
99
|
+
'group'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Convore
|
2
|
+
class Message < Base
|
3
|
+
|
4
|
+
def initialize(username, password)
|
5
|
+
@username = username
|
6
|
+
@password = password
|
7
|
+
end
|
8
|
+
|
9
|
+
#Star a message. If the message has already been starred by this user,
|
10
|
+
# this endpoint will then unstar the message.
|
11
|
+
def star_message(message_id)
|
12
|
+
if message_id.integer?
|
13
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/messages/#{message_id}/star.json", {}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
#Delete a message. You must be the creator of the message or a group admin in order to delete the message.
|
18
|
+
def delete_message(message_id)
|
19
|
+
if message_id.integer?
|
20
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/messages/#{message_id}/delete.json", {}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Convore
|
2
|
+
class Topic < Base
|
3
|
+
|
4
|
+
def initialize(username, password)
|
5
|
+
@username = username
|
6
|
+
@password = password
|
7
|
+
end
|
8
|
+
|
9
|
+
#Get detailed information about the topic
|
10
|
+
def get_topic(topic_id)
|
11
|
+
if topic_id.integer?
|
12
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}.json"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
#Get the latest messages in a topic. Use the optional until_id parameter
|
17
|
+
#to paginate and get prior messages. Set the optional mark_read parameter
|
18
|
+
#to false to leave the messages as unread
|
19
|
+
def get_topic_messages(topic_id, *hash)
|
20
|
+
if topic_id.integer?
|
21
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/messages.json",
|
22
|
+
#Optional Parms
|
23
|
+
#until_id
|
24
|
+
#mark_read
|
25
|
+
hash[0]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#Post a new message
|
30
|
+
def create_message(topic_id, hash)
|
31
|
+
if topic_id.integer?
|
32
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/messages/create.json",
|
33
|
+
{:message => hash[:message]}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#Delete a topic. You must be the creator of the topic or a
|
38
|
+
# group admin in order to delete the topic.
|
39
|
+
def delete_topic(topic_id)
|
40
|
+
if topic_id.integer?
|
41
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/delete.json", {}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
#Edit a topic. You must be the creator of the topic or a group admin in order to edit the topic.
|
46
|
+
def edit_topic(topic_id, hash)
|
47
|
+
if topic_id.integer?
|
48
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/edit.json",
|
49
|
+
{:name => hash[:name]}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
#Mark all messages in a topic as read
|
54
|
+
def mark_read(topic_id)
|
55
|
+
if topic_id.integer?
|
56
|
+
RestClient.post "https://#{@username}:#{@password}@convore.com/api/topics/#{topic_id}/mark_read.json", {}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.api
|
61
|
+
'topic'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/convore/user.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Convore
|
2
|
+
class User < Base
|
3
|
+
|
4
|
+
def initialize(username, password)
|
5
|
+
@username = username
|
6
|
+
@password = password
|
7
|
+
end
|
8
|
+
|
9
|
+
#Get detailed information about the user
|
10
|
+
def get_info(user_id)
|
11
|
+
if user_id.integer?
|
12
|
+
RestClient.get "https://#{@username}:#{@password}@convore.com/api/users/#{user_id}.json"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#TODO: More robust checkingthen 200, works for now though
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require '../lib/convore'
|
5
|
+
|
6
|
+
class Test_Account < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@username = 'Botticus'
|
10
|
+
@password = 'bot123'
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_verified?
|
14
|
+
account = Convore::Account.new(@username, @password)
|
15
|
+
response = account.verified?
|
16
|
+
assert_equal(response.code, 200)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_mark_all_read
|
20
|
+
account = Convore::Account.new(@username, @password)
|
21
|
+
response = account.mark_all_read
|
22
|
+
assert_equal(response.code, 200)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_members_online
|
26
|
+
account = Convore::Account.new(@username, @password)
|
27
|
+
response = account.get_members_online
|
28
|
+
assert_equal(response.code, 200)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_get_mentions
|
32
|
+
account = Convore::Account.new(@username, @password)
|
33
|
+
response = account.get_mentions
|
34
|
+
assert_equal(response.code, 200)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
|
data/test/test_group.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require '../lib/convore'
|
3
|
+
|
4
|
+
class Test_Group < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@username = 'Botticus'
|
8
|
+
@password = 'bot123'
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def test_get_groups
|
13
|
+
group = Convore::Group.new(@username, @password)
|
14
|
+
response = group.get_groups
|
15
|
+
assert_equal(response.code, 200)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create_group
|
19
|
+
group = Convore::Group.new(@username, @password)
|
20
|
+
hash = {:name => 'testgroup', :kind => 'private',
|
21
|
+
:description => 'this is a test group', :slug => 'test' }
|
22
|
+
response = group.create_group(hash)
|
23
|
+
assert_equal(response.code, 200)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_get_group_info
|
27
|
+
group = Convore::Group.new(@username, @password)
|
28
|
+
response = group.get_group_info(7939)
|
29
|
+
assert_equal(response.code, 200)
|
30
|
+
end
|
31
|
+
|
32
|
+
#1 parms
|
33
|
+
def test_get_group_members_1
|
34
|
+
group = Convore::Group.new(@username, @password)
|
35
|
+
response = group.get_group_members(7939)
|
36
|
+
assert_equal(response.code, 200)
|
37
|
+
end
|
38
|
+
|
39
|
+
#2 parms
|
40
|
+
def test_get_group_members_2
|
41
|
+
group = Convore::Group.new(@username, @password)
|
42
|
+
response = group.get_group_members(7939, {:filter => 'admin'})
|
43
|
+
assert_equal(response.code, 200)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_join_public_group
|
47
|
+
group = Convore::Group.new(@username, @password)
|
48
|
+
response = group.join_public_group(7939)
|
49
|
+
assert_equal(response.code, 200)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_join_private_group
|
53
|
+
group = Convore::Group.new(@username, @password)
|
54
|
+
response = group.join_public_group(8595)
|
55
|
+
assert_equal(response.code, 200)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_leave_group
|
59
|
+
group = Convore::Group.new(@username, @password)
|
60
|
+
response = group.leave_group(7939)
|
61
|
+
assert_equal(response.code, 200)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_get_online_members
|
65
|
+
group = Convore::Group.new(@username, @password)
|
66
|
+
response = group.leave_group(7939)
|
67
|
+
assert_equal(response.code, 200)
|
68
|
+
end
|
69
|
+
|
70
|
+
#1 parm
|
71
|
+
def test_get_latest_topics_1
|
72
|
+
group = Convore::Group.new(@username, @password)
|
73
|
+
response = group.get_latest_topics(7939)
|
74
|
+
assert_equal(response.code, 200)
|
75
|
+
end
|
76
|
+
|
77
|
+
#2 parm
|
78
|
+
def test_get_latest_topics_2
|
79
|
+
group = Convore::Group.new(@username, @password)
|
80
|
+
response = group.get_latest_topics(7939, {:until_id => 1})
|
81
|
+
assert_equal(response.code, 200)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_create_topic
|
85
|
+
group = Convore::Group.new(@username, @password)
|
86
|
+
response = group.create_topic(8482, {:name => "I am a test topic"})
|
87
|
+
assert_equal(response.code, 200)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_mark_all_read
|
91
|
+
group = Convore::Group.new(@username, @password)
|
92
|
+
response = group.mark_all_read(8482)
|
93
|
+
assert_equal(response.code, 200)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require '../lib/convore'
|
3
|
+
|
4
|
+
class Test_Message < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@username = 'Botticus'
|
8
|
+
@password = 'bot123'
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def test_star_message
|
13
|
+
message = Convore::Message.new(@username, @password)
|
14
|
+
response = message.star_message(8595)
|
15
|
+
assert_equal(response.code, 200)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_delete_message
|
19
|
+
message = Convore::Message.new(@username, @password)
|
20
|
+
response = message.delete_message(8595)
|
21
|
+
assert_equal(response.code, 200)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/test/test_topic.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require '../lib/convore'
|
3
|
+
|
4
|
+
class Test_Topic < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@username = 'Botticus'
|
8
|
+
@password = 'bot123'
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def test_get_topic
|
13
|
+
topic = Convore::Topic.new(@username, @password)
|
14
|
+
response = topic.get_topic(8595)
|
15
|
+
assert_equal(response.code, 200)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_topic_messages
|
19
|
+
topic = Convore::Topic.new(@username, @password)
|
20
|
+
response = topic.get_topic_messages(8595, { :until_id => 11, :mark_read => 'false'})
|
21
|
+
assert_equal(response.code, 200)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_create_message
|
25
|
+
topic = Convore::Topic.new(@username, @password)
|
26
|
+
response = topic.get_topic_messages(8595, {:message => 'waffles123123'})
|
27
|
+
assert_equal(response.code, 200)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_delete_topic
|
31
|
+
topic = Convore::Topic.new(@username, @password)
|
32
|
+
response = topic.delete_topic(8595)
|
33
|
+
assert_equal(response.code, 200)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_edit_topic
|
37
|
+
topic = Convore::Topic.new(@username, @password)
|
38
|
+
response = topic.edit_topic(8595, {:topic_text => "Y so srs?"} )
|
39
|
+
assert_equal(response.code, 200)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_mark_read
|
43
|
+
topic = Convore::Topic.new(@username, @password)
|
44
|
+
response = topic.mark_read(8595 )
|
45
|
+
assert_equal(response.code, 200)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/test/test_user.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require '../lib/convore'
|
3
|
+
|
4
|
+
class Test_User < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@username = 'Botticus'
|
8
|
+
@password = 'bot123'
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def test_get_info
|
13
|
+
message = Convore::User.new(@username, @password)
|
14
|
+
response = message.get_info(8595)
|
15
|
+
assert_equal(response.code, 200)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: em-convore
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Carlos Vilhena
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-08-26 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: eventmachine
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 59
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 12
|
32
|
+
- 10
|
33
|
+
version: 0.12.10
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rest-client
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - "="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 1
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 6
|
48
|
+
- 7
|
49
|
+
version: 1.6.7
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: em-http-request
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - "="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 19
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
- 3
|
64
|
+
- 0
|
65
|
+
version: 0.3.0
|
66
|
+
type: :runtime
|
67
|
+
version_requirements: *id003
|
68
|
+
description: A convore.com API implementation in ruby using EM
|
69
|
+
email:
|
70
|
+
- carlosvilhena@gmail.com
|
71
|
+
executables: []
|
72
|
+
|
73
|
+
extensions: []
|
74
|
+
|
75
|
+
extra_rdoc_files: []
|
76
|
+
|
77
|
+
files:
|
78
|
+
- .gitignore
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- convore.gemspec
|
83
|
+
- lib/convore.rb
|
84
|
+
- lib/convore/account.rb
|
85
|
+
- lib/convore/api.rb
|
86
|
+
- lib/convore/base.rb
|
87
|
+
- lib/convore/client.rb
|
88
|
+
- lib/convore/group.rb
|
89
|
+
- lib/convore/message.rb
|
90
|
+
- lib/convore/topic.rb
|
91
|
+
- lib/convore/user.rb
|
92
|
+
- lib/convore/version.rb
|
93
|
+
- test/test_account.rb
|
94
|
+
- test/test_group.rb
|
95
|
+
- test/test_message.rb
|
96
|
+
- test/test_topic.rb
|
97
|
+
- test/test_user.rb
|
98
|
+
homepage: http://carvil.github.com
|
99
|
+
licenses: []
|
100
|
+
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 3
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
requirements: []
|
125
|
+
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 1.8.6
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: A convore.com API implementation in ruby using EM
|
131
|
+
test_files:
|
132
|
+
- test/test_account.rb
|
133
|
+
- test/test_group.rb
|
134
|
+
- test/test_message.rb
|
135
|
+
- test/test_topic.rb
|
136
|
+
- test/test_user.rb
|