firering 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/{README.rdoc → README.md} +51 -36
- data/firering.gemspec +4 -4
- data/lib/firering.rb +1 -1
- data/lib/firering/connection.rb +8 -2
- metadata +5 -5
data/LICENSE
CHANGED
data/{README.rdoc → README.md}
RENAMED
@@ -1,40 +1,62 @@
|
|
1
|
-
|
1
|
+
# firering
|
2
2
|
|
3
3
|
Campfire API interface powered by eventmachine, em-http-request and yajl-ruby.
|
4
4
|
|
5
|
-
|
5
|
+
## Sample code
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
print "Enter password: " ; password = gets.chomp
|
7
|
+
```ruby
|
8
|
+
require 'firering'
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
c.max_retries = 10 # default to -1, which means perform connection retries on drop forever.
|
15
|
-
end
|
10
|
+
print "Enter subdomain: "; subdomain = gets.chomp
|
11
|
+
print "Enter user: " ; login = gets.chomp
|
12
|
+
print "Enter password: " ; password = gets.chomp
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
conn = Firering::Connection.new("http://#{subdomain}.campfirenow.com") do |c|
|
15
|
+
c.login = login
|
16
|
+
c.password = password
|
17
|
+
c.max_retries = 10 # default to -1, which means perform connection retries on drop forever.
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
EM.run do
|
21
|
+
conn.authenticate do |user|
|
22
|
+
conn.rooms do |rooms|
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
24
|
+
rooms.each do |room|
|
25
|
+
if room.name == "Room Name"
|
27
26
|
|
27
|
+
room.stream do |message|
|
28
|
+
message.user { |user| puts "#{user}: #{message}" }
|
28
29
|
end
|
29
|
-
end
|
30
30
|
|
31
|
+
end
|
31
32
|
end
|
32
|
-
end
|
33
33
|
|
34
|
-
|
34
|
+
end
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
trap("INT") { EM.stop }
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
## Specifying connection options:
|
42
|
+
|
43
|
+
An user agent can be specified.
|
44
|
+
HTTP Options correspond to [EM::HTTPRequest options](https://github.com/igrigorik/em-http-request/wiki/Issuing-Requests):
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
conn = Firering::Connection.new("http://#{subdomain}.campfirenow.com") do |conn|
|
48
|
+
conn.user_agent = "My Cool App 1.0"
|
49
|
+
conn.http_options = {
|
50
|
+
proxy: {
|
51
|
+
host: url,
|
52
|
+
port: port,
|
53
|
+
authorization: [username, password]
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
## campf-notif
|
38
60
|
|
39
61
|
The gem bundles an executable script for spawning libnotify powered
|
40
62
|
notifications. To be able to use it, check your distro package repositories
|
@@ -52,7 +74,7 @@ Once the variables are set, run the script as follows:
|
|
52
74
|
|
53
75
|
And watch the lovely notifications each time something is posted to a room.
|
54
76
|
|
55
|
-
|
77
|
+
## Running the specs
|
56
78
|
|
57
79
|
When the specs are run a process is forked where a Rack application is run.
|
58
80
|
This rack application serves all the fixtured responses that mimic the working
|
@@ -63,13 +85,13 @@ fixtures server.
|
|
63
85
|
|
64
86
|
For more details take a look at spec/fixtures/load_server.rb file.
|
65
87
|
|
66
|
-
|
88
|
+
## TODO
|
67
89
|
|
68
90
|
* Better API documentation
|
69
91
|
* Post files to a room
|
70
92
|
* Retrieve recently uploaded files
|
71
93
|
|
72
|
-
|
94
|
+
## Note on Patches/Pull Requests
|
73
95
|
|
74
96
|
* Fork the project.
|
75
97
|
* Make your feature addition or bug fix.
|
@@ -79,17 +101,10 @@ For more details take a look at spec/fixtures/load_server.rb file.
|
|
79
101
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
80
102
|
* Send me a pull request. Bonus points for topic branches.
|
81
103
|
|
82
|
-
|
104
|
+
## Contributors
|
83
105
|
|
84
|
-
|
85
|
-
https://github.com/EmmanuelOga/firering/pull/2 ,
|
86
|
-
https://github.com/EmmanuelOga/firering/pull/3
|
87
|
-
https://github.com/EmmanuelOga/firering/pull/7
|
88
|
-
* caius (Caius Durling), https://github.com/EmmanuelOga/firering/pull/5
|
89
|
-
* cesario (Franck Verrot), https://github.com/EmmanuelOga/firering/pull/6
|
90
|
-
* PizzaPowered, https://github.com/PizzaPowered/firering
|
91
|
-
* gdb (Greg Brockman), https://github.com/EmmanuelOga/firering/pull/8
|
106
|
+
See https://github.com/EmmanuelOga/firering/graphs/contributors
|
92
107
|
|
93
|
-
|
108
|
+
## Copyright
|
94
109
|
|
95
|
-
Copyright (c)
|
110
|
+
Copyright (c) 2013 Emmanuel Oga. See LICENSE for details.
|
data/firering.gemspec
CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
|
6
6
|
s.name = 'firering'
|
7
|
-
s.version = '1.
|
8
|
-
s.date = '2013-05
|
7
|
+
s.version = '1.4.0'
|
8
|
+
s.date = '2013-07-05'
|
9
9
|
s.rubyforge_project = 'firering'
|
10
10
|
|
11
11
|
s.summary = "Campfire API interface powered by eventmachine em-http-request and yajl-ruby."
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.default_executable = 'campf-notify'
|
22
22
|
|
23
23
|
s.rdoc_options = ["--charset=UTF-8"]
|
24
|
-
s.extra_rdoc_files = %w[README.
|
24
|
+
s.extra_rdoc_files = %w[README.md LICENSE]
|
25
25
|
|
26
26
|
s.add_dependency('eventmachine', ["~> 1.0.3"])
|
27
27
|
s.add_dependency('em-http-request', ["~> 1.0.3"])
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.files = %w[
|
37
37
|
Gemfile
|
38
38
|
LICENSE
|
39
|
-
README.
|
39
|
+
README.md
|
40
40
|
Rakefile
|
41
41
|
bin/campf-notify
|
42
42
|
examples/authenticate.rb
|
data/lib/firering.rb
CHANGED
data/lib/firering/connection.rb
CHANGED
@@ -11,12 +11,18 @@ module Firering
|
|
11
11
|
attr_accessor :password
|
12
12
|
attr_accessor :token
|
13
13
|
attr_accessor :login
|
14
|
+
attr_accessor :user_agent
|
15
|
+
|
16
|
+
# HTTP Options correspond to EM::HTTPRequest options:
|
17
|
+
# https://github.com/igrigorik/em-http-request/wiki/Issuing-Requests
|
18
|
+
attr_accessor :http_options
|
14
19
|
|
15
20
|
attr_reader :performed_retries
|
16
21
|
|
17
22
|
def initialize(host, streaming_host = "https://streaming.campfirenow.com")
|
18
23
|
@retry_delay, @redirects, @max_retries, @performed_retries = 2, 1, -1, 0
|
19
24
|
self.host, self.streaming_host = host, streaming_host
|
25
|
+
self.user_agent = "firering library version #{VERSION}"
|
20
26
|
yield self if block_given?
|
21
27
|
end
|
22
28
|
|
@@ -43,7 +49,7 @@ module Firering
|
|
43
49
|
def parameters(data = nil)
|
44
50
|
parameters = {
|
45
51
|
:redirects => redirects,
|
46
|
-
:head => auth_headers.merge("Content-Type" => "application/json")
|
52
|
+
:head => auth_headers.merge("Content-Type" => "application/json").merge('User-Agent' => user_agent)
|
47
53
|
}
|
48
54
|
parameters.merge!(:body => data.is_a?(String) ? data : Yajl::Encoder.encode(data)) if data
|
49
55
|
parameters
|
@@ -53,7 +59,7 @@ module Firering
|
|
53
59
|
uri = host.join(path)
|
54
60
|
logger.info("performing request to #{uri}")
|
55
61
|
|
56
|
-
http = EventMachine::HttpRequest.new(uri).send(method, parameters(data))
|
62
|
+
http = EventMachine::HttpRequest.new(uri, http_options || {}).send(method, parameters(data))
|
57
63
|
|
58
64
|
http.errback do
|
59
65
|
perform_retry(http) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firering
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05
|
12
|
+
date: 2013-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -129,12 +129,12 @@ executables:
|
|
129
129
|
- campf-notify
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files:
|
132
|
-
- README.
|
132
|
+
- README.md
|
133
133
|
- LICENSE
|
134
134
|
files:
|
135
135
|
- Gemfile
|
136
136
|
- LICENSE
|
137
|
-
- README.
|
137
|
+
- README.md
|
138
138
|
- Rakefile
|
139
139
|
- bin/campf-notify
|
140
140
|
- examples/authenticate.rb
|
@@ -211,7 +211,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
211
211
|
version: '0'
|
212
212
|
segments:
|
213
213
|
- 0
|
214
|
-
hash:
|
214
|
+
hash: 4060696139980185122
|
215
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
216
|
none: false
|
217
217
|
requirements:
|