libfchat 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/libfchat/fchat.rb +34 -0
- data/lib/libfchat/version.rb +1 -1
- data/test/fchat_test.rb +14 -0
- metadata +20 -1
@@ -0,0 +1,34 @@
|
|
1
|
+
module Libfchat
|
2
|
+
begin
|
3
|
+
require 'rubygems'
|
4
|
+
rescue LoadError
|
5
|
+
#I don't actually NEED rubygems, unless on 1.8
|
6
|
+
end
|
7
|
+
require 'net/http'
|
8
|
+
require 'multi_json'
|
9
|
+
require 'eventmachine'
|
10
|
+
require 'em-http-request'
|
11
|
+
require 'libfchat/webapi'
|
12
|
+
|
13
|
+
class Fchat
|
14
|
+
attr_reader :ticket
|
15
|
+
|
16
|
+
def login(server,account,password,timeout=30)
|
17
|
+
webapi = Libfchat::WebAPI.new
|
18
|
+
@ticket = webapi.get_ticket(account,password)
|
19
|
+
|
20
|
+
EventMachine.run {
|
21
|
+
http = EventMachine::HttpRequest.new(server).get :timeout => timeout
|
22
|
+
http.errback { puts "Could not connect to " + server }
|
23
|
+
http.callback {
|
24
|
+
puts "Websocket connected"
|
25
|
+
}
|
26
|
+
|
27
|
+
http.stream { |msg|
|
28
|
+
puts "Received: #{msg}"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/libfchat/version.rb
CHANGED
@@ -2,5 +2,5 @@ module Libfchat
|
|
2
2
|
# We're doing this because we might write tests that deal
|
3
3
|
# with other versions of Libfchat and we are unsure how to
|
4
4
|
# handle this better.
|
5
|
-
VERSION = "0.1.
|
5
|
+
VERSION = "0.1.3" unless defined?(::Libfchat::VERSION)
|
6
6
|
end
|
data/test/fchat_test.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
require 'libfchat/fchat'
|
6
|
+
|
7
|
+
class TestFchat < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_can_create_object
|
10
|
+
j = Libfchat::Fchat.new
|
11
|
+
assert_equal true, j.is_a?(Object)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libfchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.3.6
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: em-http-request
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.2
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.0.2
|
62
78
|
description: A library for connecting to F-chat ( http://f-list.net )
|
63
79
|
email: cheetahmorph@gmail.com
|
64
80
|
executables: []
|
@@ -67,7 +83,9 @@ extra_rdoc_files: []
|
|
67
83
|
files:
|
68
84
|
- lib/libfchat/version.rb
|
69
85
|
- lib/libfchat/webapi.rb
|
86
|
+
- lib/libfchat/fchat.rb
|
70
87
|
- test/webapi_test.rb
|
88
|
+
- test/fchat_test.rb
|
71
89
|
homepage: http://github.com/jippen/libfchat-ruby
|
72
90
|
licenses:
|
73
91
|
- MIT
|
@@ -95,3 +113,4 @@ specification_version: 3
|
|
95
113
|
summary: A library for connection to F-chat
|
96
114
|
test_files:
|
97
115
|
- test/webapi_test.rb
|
116
|
+
- test/fchat_test.rb
|