campfiyah 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d50e6cebc5f704d3bc802fd79863d83443533acc
4
+ data.tar.gz: fcb9ae27fff12bedeab0c05869ebdf58c4b76ed2
5
+ SHA512:
6
+ metadata.gz: f6c7256cda075ca3b550eec0f2635d1d5d545599f33e0ac3f67ec26e1188b79cc2c4e7467d9b60f30ae6345d751894029c1c788bb38c20ca910bc08bca4247f3
7
+ data.tar.gz: fd1120c9b555532ad40131f1233a3d403e2e9d5099ce4144f95bbf77f75828af7d2954f88f6c5eac9a64f96b711b1b76495952de83dac8b6e61f207567d9cb1e
@@ -5,6 +5,7 @@ require 'faraday_middleware'
5
5
  require "campfiyah/version"
6
6
  require "campfiyah/account"
7
7
  require "campfiyah/room"
8
+ require "campfiyah/user"
8
9
  require "campfiyah/adapters"
9
10
 
10
11
  module Campfiyah
@@ -9,6 +9,11 @@ module Campfiyah
9
9
  @subdomain = subdomain
10
10
  end
11
11
 
12
+ def user_by_id(id)
13
+ user = @adapter.user_by_id(id)
14
+ User.from_hash(user, @adapter)
15
+ end
16
+
12
17
  def rooms
13
18
  @rooms ||= @adapter.rooms.map do |room|
14
19
  Room.from_hash(room, @adapter)
@@ -26,6 +26,15 @@ module Campfiyah
26
26
  rooms.sort { |a,b| b['updated_at'] <=> a['updated_at'] }
27
27
  end
28
28
 
29
+ def user_by_id(id)
30
+ response = connection.get("/users/#{id}.json")
31
+ if response.status == 200
32
+ response.body["user"]
33
+ else
34
+ { }
35
+ end
36
+ end
37
+
29
38
  def message(room_id, message)
30
39
  response = connection.post("/room/#{room_id}/speak.json") do |req|
31
40
  req.headers['Content-Type'] = 'application/json'
@@ -44,4 +53,4 @@ module Campfiyah
44
53
  end
45
54
  end
46
55
  end
47
- end
56
+ end
@@ -5,9 +5,15 @@ module Campfiyah
5
5
  @rooms ||= Yajl.load(File.read("#{File.dirname(__FILE__)}/memory/rooms.json"))['rooms']
6
6
  end
7
7
 
8
+ def user_by_id(id)
9
+ hash = Yajl.load(File.read("#{File.dirname(__FILE__)}/memory/user.json"))['user']
10
+ hash['id'] = id
11
+ hash
12
+ end
13
+
8
14
  def message(room_id, message)
9
15
  true
10
16
  end
11
17
  end
12
18
  end
13
- end
19
+ end
@@ -0,0 +1 @@
1
+ {"user":{"name": "atmos", "email_address": "atmos@atmos.org", "id": "420"}}
@@ -0,0 +1,13 @@
1
+ module Campfiyah
2
+ class User
3
+ attr_accessor :id, :name, :email
4
+ def initialize(adapter, id, name, email)
5
+ @adapter, @id, @name, @email = adapter, id, name, email
6
+ end
7
+
8
+ def self.from_hash(hash, adapter)
9
+ new(adapter, hash["id"], hash["name"], hash["email_address"])
10
+ end
11
+ end
12
+ end
13
+
@@ -1,3 +1,3 @@
1
1
  module Campfiyah
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -6,4 +6,4 @@ describe Campfiyah::Room do
6
6
  pending
7
7
  end
8
8
  end
9
- end
9
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ describe Campfiyah::User do
4
+ context "finds a user by id" do
5
+ it "finds her" do
6
+ account = Campfiyah::Account.new(default_subdomain, default_token)
7
+ user = account.user_by_id(420)
8
+
9
+ expect(user.id).to eql(420)
10
+ expect(user.name).to eql("atmos")
11
+ expect(user.email).to eql("atmos@atmos.org")
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,84 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: campfiyah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Corey Donohoe
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-18 00:00:00.000000000 Z
11
+ date: 2013-09-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: yajl-ruby
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: faraday
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: faraday_middleware
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: pry
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: bundler
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,33 +83,29 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rspec
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  description: A simple faraday based Campfire API
@@ -142,37 +127,40 @@ files:
142
127
  - lib/campfiyah/adapters/http.rb
143
128
  - lib/campfiyah/adapters/memory.rb
144
129
  - lib/campfiyah/adapters/memory/rooms.json
130
+ - lib/campfiyah/adapters/memory/user.json
145
131
  - lib/campfiyah/room.rb
132
+ - lib/campfiyah/user.rb
146
133
  - lib/campfiyah/version.rb
147
134
  - spec/account_spec.rb
148
135
  - spec/room_spec.rb
149
136
  - spec/spec_helper.rb
137
+ - spec/user_spec.rb
150
138
  homepage: https://github.com/atmos/campfiyah
151
139
  licenses:
152
140
  - MIT
141
+ metadata: {}
153
142
  post_install_message:
154
143
  rdoc_options: []
155
144
  require_paths:
156
145
  - lib
157
146
  required_ruby_version: !ruby/object:Gem::Requirement
158
- none: false
159
147
  requirements:
160
- - - ! '>='
148
+ - - '>='
161
149
  - !ruby/object:Gem::Version
162
150
  version: '0'
163
151
  required_rubygems_version: !ruby/object:Gem::Requirement
164
- none: false
165
152
  requirements:
166
- - - ! '>='
153
+ - - '>='
167
154
  - !ruby/object:Gem::Version
168
155
  version: '0'
169
156
  requirements: []
170
157
  rubyforge_project:
171
- rubygems_version: 1.8.23
158
+ rubygems_version: 2.0.3
172
159
  signing_key:
173
- specification_version: 3
160
+ specification_version: 4
174
161
  summary: Ruby API to Campfire's json endpoints
175
162
  test_files:
176
163
  - spec/account_spec.rb
177
164
  - spec/room_spec.rb
178
165
  - spec/spec_helper.rb
166
+ - spec/user_spec.rb