campfiyah 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/campfiyah.gemspec +1 -0
- data/lib/campfiyah/account.rb +5 -1
- data/lib/campfiyah/adapters.rb +1 -1
- data/lib/campfiyah/adapters/http.rb +8 -0
- data/lib/campfiyah/adapters/memory.rb +4 -0
- data/lib/campfiyah/adapters/memory/room.json +1 -0
- data/lib/campfiyah/room.rb +10 -1
- data/lib/campfiyah/version.rb +1 -1
- data/spec/room_spec.rb +11 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 138144f1c52be3e93efd7d421ef44c822d3c004c
|
4
|
+
data.tar.gz: a180497c63f6828db04609c648cd95cad7f3ae96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49069a3c5686d5fcd91c1aa792771e0daf80efe1ac5e5b84374ca2b0ccd75cdd26d00c50c8f8cf4051286215ceee8244e2171c51f9883e23dd082e443e385ed5
|
7
|
+
data.tar.gz: 369d5185d32df7117152a49e8a1c6b7703839da6ef670ff88786c92a7879a38ce08393242124acd138526790745eee72ba2773486042c20948acb1175c86dc21
|
data/README.md
CHANGED
@@ -37,6 +37,15 @@ room = account.room_by_id(123456)
|
|
37
37
|
room.message("woot")
|
38
38
|
```
|
39
39
|
|
40
|
+
Or you can find information on users
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
account = Campfiyah::Account.new(default_subdomain, default_token)
|
44
|
+
user = account.user_by_id(123456)
|
45
|
+
user.email
|
46
|
+
user.name
|
47
|
+
```
|
48
|
+
|
40
49
|
You can also enable the in-memory adapter for development or tests.
|
41
50
|
|
42
51
|
```ruby
|
data/campfiyah.gemspec
CHANGED
data/lib/campfiyah/account.rb
CHANGED
data/lib/campfiyah/adapters.rb
CHANGED
@@ -26,6 +26,14 @@ module Campfiyah
|
|
26
26
|
rooms.sort { |a,b| b['updated_at'] <=> a['updated_at'] }
|
27
27
|
end
|
28
28
|
|
29
|
+
def room_by_id(id)
|
30
|
+
room = nil
|
31
|
+
response = connection.get("/room/#{id}.json")
|
32
|
+
if response.status == 200
|
33
|
+
room = response.body["room"]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
def user_by_id(id)
|
30
38
|
response = connection.get("/users/#{id}.json")
|
31
39
|
if response.status == 200
|
@@ -5,6 +5,10 @@ module Campfiyah
|
|
5
5
|
@rooms ||= Yajl.load(File.read("#{File.dirname(__FILE__)}/memory/rooms.json"))['rooms']
|
6
6
|
end
|
7
7
|
|
8
|
+
def room_by_id(id)
|
9
|
+
@room ||= Yajl.load(File.read("#{File.dirname(__FILE__)}/memory/room.json"))['room']
|
10
|
+
end
|
11
|
+
|
8
12
|
def user_by_id(id)
|
9
13
|
hash = Yajl.load(File.read("#{File.dirname(__FILE__)}/memory/user.json"))['user']
|
10
14
|
hash['id'] = id
|
@@ -0,0 +1 @@
|
|
1
|
+
{"room":{"full":false,"locked":false,"users":[{"type":"Member","email_address":"hubot@github.com","avatar_url":"http://dge9rmgqjs8m1.cloudfront.net/global/missing/avatar.gif?r=3","admin":true,"name":"Hubot","created_at":"2008/04/12 01:08:29 +0000","id":307524},{"type":"Member","email_address":"atmos@atmos.org","avatar_url":"http://dge9rmgqjs8m1.cloudfront.net/global/d2f0470bc40603fa3c32d01018db49548fb7de7e/avatar.gif?r=3","admin":true,"name":"atmos","created_at":"2010/08/18 18:01:25 +0000","id":420}],"name":"The Danger Room","updated_at":"2013/09/26 20:27:25 +0000","open_to_guests":false,"created_at":"2011/02/07 22:36:38 +0000","topic":"Danger","id":123456}}
|
data/lib/campfiyah/room.rb
CHANGED
@@ -12,5 +12,14 @@ module Campfiyah
|
|
12
12
|
def message(message)
|
13
13
|
@adapter.message(id, message)
|
14
14
|
end
|
15
|
+
|
16
|
+
def users
|
17
|
+
@users ||= users!
|
18
|
+
end
|
19
|
+
|
20
|
+
def users!
|
21
|
+
room = @adapter.room_by_id(id)
|
22
|
+
room['users'].map { |user| User.from_hash(user, @adapter) }
|
23
|
+
end
|
15
24
|
end
|
16
|
-
end
|
25
|
+
end
|
data/lib/campfiyah/version.rb
CHANGED
data/spec/room_spec.rb
CHANGED
@@ -5,5 +5,16 @@ describe Campfiyah::Room do
|
|
5
5
|
it "messages a channel" do
|
6
6
|
pending
|
7
7
|
end
|
8
|
+
|
9
|
+
it "finds users for a room" do
|
10
|
+
account = Campfiyah::Account.new(default_subdomain, default_token)
|
11
|
+
account.rooms.should_not be_empty
|
12
|
+
|
13
|
+
room = account.room_by_name("The Danger Room")
|
14
|
+
room.users.size.should eql(2)
|
15
|
+
|
16
|
+
room = account.room_by_id(123456)
|
17
|
+
room.name.should eql("The Danger Room")
|
18
|
+
end
|
8
19
|
end
|
9
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: campfiyah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Donohoe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: debugger
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: A simple faraday based Campfire API
|
112
126
|
email:
|
113
127
|
- atmos@atmos.org
|
@@ -126,6 +140,7 @@ files:
|
|
126
140
|
- lib/campfiyah/adapters.rb
|
127
141
|
- lib/campfiyah/adapters/http.rb
|
128
142
|
- lib/campfiyah/adapters/memory.rb
|
143
|
+
- lib/campfiyah/adapters/memory/room.json
|
129
144
|
- lib/campfiyah/adapters/memory/rooms.json
|
130
145
|
- lib/campfiyah/adapters/memory/user.json
|
131
146
|
- lib/campfiyah/room.rb
|
@@ -164,3 +179,4 @@ test_files:
|
|
164
179
|
- spec/room_spec.rb
|
165
180
|
- spec/spec_helper.rb
|
166
181
|
- spec/user_spec.rb
|
182
|
+
has_rdoc:
|