yammer-client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/Gemfile +0 -2
- data/README.md +29 -19
- data/lib/yammer.rb +6 -1
- data/lib/yammer/base.rb +131 -0
- data/lib/yammer/{model/group.rb → group.rb} +1 -1
- data/lib/yammer/{model/group_membership.rb → group_membership.rb} +1 -1
- data/lib/yammer/{model/message.rb → message.rb} +1 -1
- data/lib/yammer/{model/message_body.rb → message_body.rb} +0 -0
- data/lib/yammer/model.rb +6 -6
- data/lib/yammer/{model/thread.rb → thread.rb} +1 -1
- data/lib/yammer/{model/user.rb → user.rb} +1 -1
- data/lib/yammer/version.rb +1 -1
- data/spec/model/base_spec.rb +2 -2
- data/spec/spec_helper.rb +12 -8
- data/yammer.gemspec +11 -5
- metadata +59 -30
- metadata.gz.sig +0 -0
- data/lib/yammer/model/base.rb +0 -133
data.tar.gz.sig
ADDED
Binary file
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
Yammer Client
|
2
2
|
=============
|
3
|
+
[![GemVersion](https://badge.fury.io/rb/yammer-client.png)][gemversion]
|
4
|
+
[![Build Status](https://travis-ci.org/tiabas/yammer-client.png?branch=master)][travis]
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/tiabas/yammer-client/badge.png?branch=master)][coveralls]
|
6
|
+
[![Dependency Status](https://gemnasium.com/tiabas/yammer-client.png)][gemnasium]
|
3
7
|
|
4
|
-
[
|
8
|
+
[gemversion]: (http://badge.fury.io/rb/yammer-client)
|
9
|
+
[travis]: (https://travis-ci.org/tiabas/yammer-client)
|
10
|
+
[coveralls]: (https://coveralls.io/r/tiabas/yammer-client)
|
11
|
+
[gemnasium]: https://gemnasium.com/tiabas/yammer-client
|
5
12
|
|
6
13
|
A Yammer Ruby gem
|
7
14
|
|
@@ -88,8 +95,7 @@ To view the current state of the client use the `options` method
|
|
88
95
|
require 'yammer'
|
89
96
|
|
90
97
|
Yammer.options
|
91
|
-
|
92
|
-
# => {:site_url=>"https://www.yammer.com", :client_id=>nil, :client_secret=>nil, :access_token=>nil, :http_adapter=>Yammer::HttpConnection, :connection_options=>{:max_redirects=>5, :use_ssl=>true}}
|
98
|
+
#> {:site_url=>"https://www.yammer.com", :client_id=>nil, :client_secret=>nil, :access_token=>nil, :http_adapter=>Yammer::HttpConnection, :connection_options=>{:max_redirects=>5, :use_ssl=>true}}
|
93
99
|
```
|
94
100
|
|
95
101
|
You may change this configuration by using the `configure` method
|
@@ -100,16 +106,14 @@ Yammer.configure do |c|
|
|
100
106
|
c.client_secret = '[client_secret]'
|
101
107
|
c.token = '[access_token]'
|
102
108
|
end
|
103
|
-
|
104
|
-
# => Yammer
|
109
|
+
#> Yammer
|
105
110
|
```
|
106
111
|
|
107
112
|
At this point, your new settings will take effect
|
108
113
|
|
109
114
|
```ruby
|
110
115
|
Yammer.options
|
111
|
-
|
112
|
-
# => {:site_url=>"https://www.yammer.com", :client_id=>'[client_id]', :client_secret=>'[client_secret]', :access_token=>'[access_token]', :http_adapter=>Yammer::HttpConnection, :connection_options=>{ :max_redirects=>5, :use_ssl=>true }}
|
116
|
+
#> {:site_url=>"https://www.yammer.com", :client_id=>'[client_id]', :client_secret=>'[client_secret]', :access_token=>'[access_token]', :http_adapter=>Yammer::HttpConnection, :connection_options=>{ :max_redirects=>5, :use_ssl=>true }}
|
113
117
|
```
|
114
118
|
|
115
119
|
## Usage
|
@@ -137,18 +141,21 @@ yamr = Yammer::Client.new(
|
|
137
141
|
|
138
142
|
```ruby
|
139
143
|
yamr.get_user_by_email('user@example.com')
|
144
|
+
#<Yammer::Response:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
|
140
145
|
```
|
141
146
|
|
142
147
|
*find a user by user id*
|
143
148
|
|
144
149
|
```ruby
|
145
150
|
yamr.get_user('1588')
|
151
|
+
#<Yammer::Response:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
|
146
152
|
```
|
147
153
|
|
148
154
|
*get the current user*
|
149
155
|
|
150
156
|
```ruby
|
151
157
|
yamr.current_user
|
158
|
+
#<Yammer::Response:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
|
152
159
|
```
|
153
160
|
|
154
161
|
|
@@ -158,18 +165,21 @@ yamr.current_user
|
|
158
165
|
|
159
166
|
```ruby
|
160
167
|
yamr.create_message(:body => 'status update')
|
168
|
+
#<Yammer::Response:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
|
161
169
|
```
|
162
170
|
|
163
171
|
*send a private message to another Yammer user*
|
164
172
|
|
165
173
|
```ruby
|
166
174
|
yamr.create_message(:body => 'private message', :direct_to_id => 24)
|
175
|
+
#<Yammer::Response:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
|
167
176
|
```
|
168
177
|
|
169
178
|
*send a message with an Open Graph Object as an attachment*
|
170
179
|
|
171
180
|
```ruby
|
172
181
|
yamr.create_message(:body => 'here is my open graph object', og_url: "https://www.yammer.com/example/graph/31415926")
|
182
|
+
#<Yammer::Response:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
|
173
183
|
```
|
174
184
|
|
175
185
|
|
@@ -179,12 +189,16 @@ yamr.create_message(:body => 'here is my open graph object', og_url: "https://ww
|
|
179
189
|
|
180
190
|
```ruby
|
181
191
|
yamr.search(:search => 'thekev', :model_types => 'users;groups')
|
192
|
+
#<Yammer::Response:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
|
182
193
|
```
|
183
194
|
|
184
195
|
**Thread**
|
196
|
+
|
185
197
|
*fetch a thread with a given id*
|
198
|
+
|
186
199
|
```ruby
|
187
200
|
yamr.get_thread(42, :model_types => 'users;groups')
|
201
|
+
#<Yammer::Response:0x007fb949434ec8 @headers=#<Net::HTTPOK 200 OK readbody=true>, @body="[JSON Response]", @code=200>
|
188
202
|
```
|
189
203
|
|
190
204
|
|
@@ -201,15 +215,12 @@ any given request. Each model has accessor metods for all keys contained in the
|
|
201
215
|
|
202
216
|
```ruby
|
203
217
|
u = Yammer::User.current
|
204
|
-
|
205
|
-
#=> #<Yammer::User:0x007f9f4b0c39c8>
|
218
|
+
#> <Yammer::User:0x007f9f4b0c39c8>
|
206
219
|
|
207
220
|
u.full_name
|
208
|
-
|
209
|
-
#=> 'Kevin Mutyaba'
|
221
|
+
#> 'Kevin Mutyaba'
|
210
222
|
|
211
223
|
u.update!(:job_title => 'k0dR')
|
212
|
-
|
213
224
|
```
|
214
225
|
|
215
226
|
|
@@ -218,33 +229,32 @@ u.update!(:job_title => 'k0dR')
|
|
218
229
|
*fetch a thread with a given id*
|
219
230
|
|
220
231
|
```ruby
|
221
|
-
|
222
232
|
t = Yammer::Thread.get(3)
|
223
233
|
|
224
234
|
# view the participants in the thread
|
225
235
|
|
226
236
|
parts = t.participants
|
227
|
-
|
237
|
+
#> [{:type=>"user", :id=>18}, {:type=>"user", :id=>64}]
|
228
238
|
|
229
239
|
|
230
240
|
# view the participants in the thread as user object models
|
231
241
|
|
232
242
|
peepl = t.people
|
233
|
-
|
243
|
+
#> [#<Yammer::User:0x007f9f4c086630 @modified_attributes={}, @attrs={}, @new_record=false, @id=18>, #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={}, @new_record=false, @id=64>]
|
234
244
|
|
235
245
|
|
236
246
|
# object models are lazyly loaded
|
237
247
|
|
238
248
|
peepl[0]
|
239
|
-
|
249
|
+
#> #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={}, @new_record=false, @id=18>
|
240
250
|
|
241
251
|
# calling an accessor on a model will hydrate it
|
242
252
|
|
243
253
|
peepl[0].permalink
|
244
|
-
|
254
|
+
#> 'thekev'
|
245
255
|
|
246
256
|
peepl[0]
|
247
|
-
#=> #<Yammer::User:
|
257
|
+
#=> #<Yammer::User:0x007f9f4c086568 @modified_attributes={}, @attrs={:last_name=>"Mutyaba", :network_id=>1, :first_name=>"Kevin", :id => 18, :permalink=>"thekev" }, @network_id=1, @first_name="Kev", @full_name="Tiaba", @permalink="thekev", @id=18 >
|
248
258
|
```
|
249
259
|
|
250
260
|
## Supported Ruby Versions
|
@@ -262,4 +272,4 @@ above.
|
|
262
272
|
## Copyright
|
263
273
|
Copyright (c) 2013 Kevin Mutyaba
|
264
274
|
See [LICENSE][license] for details.
|
265
|
-
[license]: https://github.com/tiabas/yammer-client/blob/master/LICENSE.md
|
275
|
+
[license]: https://github.com/tiabas/yammer-client/blob/master/LICENSE.md
|
data/lib/yammer.rb
CHANGED
@@ -5,7 +5,12 @@ require 'yammer/configurable'
|
|
5
5
|
require 'yammer/response'
|
6
6
|
require 'yammer/client'
|
7
7
|
require 'yammer/identity_map'
|
8
|
-
require 'yammer/
|
8
|
+
require 'yammer/base'
|
9
|
+
require 'yammer/user'
|
10
|
+
require 'yammer/group'
|
11
|
+
require 'yammer/group_membership'
|
12
|
+
require 'yammer/message'
|
13
|
+
require 'yammer/thread'
|
9
14
|
require 'yammer/api'
|
10
15
|
|
11
16
|
module Yammer
|
data/lib/yammer/base.rb
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
module Yammer
|
2
|
+
class Base
|
3
|
+
|
4
|
+
def self.attr_accessor_deffered(*symbols)
|
5
|
+
symbols.each do |key|
|
6
|
+
fetchable_keys[key] = true
|
7
|
+
|
8
|
+
define_method (key.to_s) do
|
9
|
+
if self.class.fetchable_keys.has_key?(key) && !@attrs.has_key?(key) && @id
|
10
|
+
load!
|
11
|
+
end
|
12
|
+
instance_variable_get("@#{key}")
|
13
|
+
end
|
14
|
+
|
15
|
+
define_method ("#{key}=") do |value|
|
16
|
+
if @attrs.fetch(key, false) && !new_record?
|
17
|
+
@modified_attributes[key] = value
|
18
|
+
else
|
19
|
+
@attrs[key] = value
|
20
|
+
end
|
21
|
+
instance_variable_set("@#{key}", value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @!scope class
|
27
|
+
def self.fetchable_keys
|
28
|
+
@fetchable_keys ||= {}
|
29
|
+
return @fetchable_keys
|
30
|
+
end
|
31
|
+
|
32
|
+
# @!scope class
|
33
|
+
def self.identity_map
|
34
|
+
@identity_map ||= Yammer::IdentityMap.new
|
35
|
+
end
|
36
|
+
|
37
|
+
# @!scope class
|
38
|
+
def self.base_name
|
39
|
+
word = "#{self.name.split(/::/).last}"
|
40
|
+
word.gsub!(/::/, '/')
|
41
|
+
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
42
|
+
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
43
|
+
word.tr!("-", "_")
|
44
|
+
word.downcase!
|
45
|
+
word
|
46
|
+
end
|
47
|
+
|
48
|
+
# @!scope class
|
49
|
+
def self.fetch(id)
|
50
|
+
return unless identity_map
|
51
|
+
attributes = identity_map.get("#{self.base_name}_#{id}")
|
52
|
+
unless attributes
|
53
|
+
result = Yammer.send("get_#{self.base_name}", id)
|
54
|
+
attributes = result.body || {}
|
55
|
+
unless attributes.empty?
|
56
|
+
identity_map.put("#{self.base_name}_#{id}", attributes)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
attributes
|
60
|
+
end
|
61
|
+
|
62
|
+
# @!scope class
|
63
|
+
def self.get(id)
|
64
|
+
new(fetch(id))
|
65
|
+
end
|
66
|
+
|
67
|
+
attr_reader :id, :attrs
|
68
|
+
|
69
|
+
def initialize(props={})
|
70
|
+
@modified_attributes = {}
|
71
|
+
@attrs = {}
|
72
|
+
@new_record = true
|
73
|
+
self.id = props.delete(:id)
|
74
|
+
self.update(props)
|
75
|
+
end
|
76
|
+
|
77
|
+
def base_name
|
78
|
+
self.class.base_name
|
79
|
+
end
|
80
|
+
|
81
|
+
def new_record?
|
82
|
+
@new_record
|
83
|
+
end
|
84
|
+
|
85
|
+
def changes
|
86
|
+
@modified_attributes
|
87
|
+
end
|
88
|
+
|
89
|
+
def modified?
|
90
|
+
!changes.empty?
|
91
|
+
end
|
92
|
+
|
93
|
+
def load!
|
94
|
+
result = self.class.fetch(@id)
|
95
|
+
update(result)
|
96
|
+
end
|
97
|
+
alias_method :reload!, :load!
|
98
|
+
|
99
|
+
def save
|
100
|
+
return self if ((!new_record? && @modified_attributes.empty?) || @attrs.empty?)
|
101
|
+
result = if new_record?
|
102
|
+
Yammer.send("create_#{self.base_name}", @attrs)
|
103
|
+
else
|
104
|
+
Yammer.send("update_#{self.base_name}", @id, @modified_attributes)
|
105
|
+
end
|
106
|
+
@modified_attributes = {}
|
107
|
+
self
|
108
|
+
end
|
109
|
+
|
110
|
+
def delete!
|
111
|
+
return if new_record?
|
112
|
+
result = Yammer.send("delete_#{self.base_name}", @id)
|
113
|
+
result.success?
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def id=(model_id)
|
119
|
+
return if model_id.nil?
|
120
|
+
@id = model_id.to_i
|
121
|
+
@new_record = false
|
122
|
+
end
|
123
|
+
|
124
|
+
protected
|
125
|
+
def update(props={})
|
126
|
+
props.each do |key, value|
|
127
|
+
send("#{key}=", value)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
File without changes
|
data/lib/yammer/model.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'yammer/
|
2
|
-
require 'yammer/
|
3
|
-
require 'yammer/
|
4
|
-
require 'yammer/
|
5
|
-
require 'yammer/
|
6
|
-
require 'yammer/
|
1
|
+
require 'yammer/base'
|
2
|
+
require 'yammer/user'
|
3
|
+
require 'yammer/group'
|
4
|
+
require 'yammer/group_membership'
|
5
|
+
require 'yammer/message'
|
6
|
+
require 'yammer/thread'
|
data/lib/yammer/version.rb
CHANGED
data/spec/model/base_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
SimpleCov.start do
|
4
|
-
add_filter 'spec'
|
5
|
-
end
|
6
|
-
end
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
7
3
|
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start
|
9
|
+
|
10
|
+
require 'yammer'
|
8
11
|
require 'rspec'
|
9
12
|
require 'rspec/autorun'
|
10
13
|
require 'webmock/rspec'
|
11
|
-
|
14
|
+
|
15
|
+
WebMock.disable_net_connect!(:allow => 'coveralls.io')
|
12
16
|
|
13
17
|
RSpec.configure do |config|
|
14
18
|
config.mock_with :rspec
|
@@ -39,4 +43,4 @@ end
|
|
39
43
|
|
40
44
|
def fixture(file)
|
41
45
|
File.new("#{fixture_path}/#{file}")
|
42
|
-
end
|
46
|
+
end
|
data/yammer.gemspec
CHANGED
@@ -14,16 +14,22 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.rubygems_version = Yammer::Version
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.require_paths = ['lib']
|
17
|
-
|
17
|
+
|
18
18
|
s.licenses = ['MIT']
|
19
19
|
s.test_files = Dir.glob("spec/**/*")
|
20
20
|
|
21
|
-
s.
|
22
|
-
s.
|
23
|
-
|
24
|
-
s.add_dependency '
|
21
|
+
s.cert_chain = ['certs/tiabas-public.pem']
|
22
|
+
s.signing_key = File.expand_path("~/.gem/certs/private_key.pem") if $0 =~ /gem\z/
|
23
|
+
|
24
|
+
s.add_dependency 'oj', '~> 2.0.10'
|
25
|
+
s.add_dependency 'multi_json', '~> 1.3'
|
26
|
+
s.add_dependency 'oauth2-client', '~> 1.1.2'
|
27
|
+
s.add_dependency 'addressable', '~> 2.3.3'
|
28
|
+
|
25
29
|
s.add_development_dependency 'rake'
|
26
30
|
s.add_development_dependency 'rspec'
|
27
31
|
s.add_development_dependency 'simplecov', '>= 0.7.1'
|
28
32
|
s.add_development_dependency 'webmock', '>= 1.9.0'
|
33
|
+
|
34
|
+
s.post_install_message = %q{ Thanks for installing! If you like this gem please spread the word }
|
29
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yammer-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,73 +9,101 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain:
|
12
|
-
-
|
12
|
+
- !binary |-
|
13
|
+
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURjRENDQWxpZ0F3SUJB
|
14
|
+
Z0lCQVRBTkJna3Foa2lHOXcwQkFRVUZBREEvTVJFd0R3WURWUVFEREFoMGFX
|
15
|
+
RmkKWVhOdWF6RVZNQk1HQ2dtU0pvbVQ4aXhrQVJrV0JXZHRZV2xzTVJNd0VR
|
16
|
+
WUtDWkltaVpQeUxHUUJHUllEWTI5dApNQjRYRFRFek1ETXdNekEyTWpBeE5W
|
17
|
+
b1hEVEUwTURNd016QTJNakF4TlZvd1B6RVJNQThHQTFVRUF3d0lkR2xoCllt
|
18
|
+
RnpibXN4RlRBVEJnb0praWFKay9Jc1pBRVpGZ1ZuYldGcGJERVRNQkVHQ2dt
|
19
|
+
U0pvbVQ4aXhrQVJrV0EyTnYKYlRDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFB
|
20
|
+
RGdnRVBBRENDQVFvQ2dnRUJBTXNtVnNFcmNOdXdRTEtMaDlUNgphNTdRaUsz
|
21
|
+
NWc5empwSUQycFVCbjRhbE1UbUllQVhnMmJYV0xkQXpVMHN3Y2ptYUdCV3o1
|
22
|
+
QWFaZXFUbm5CdmVPClpEb0g2ZTgxMXV1UmpKTVlDa0xReGhsZ2hFQjBUUWtB
|
23
|
+
cU9ueGxqODBUTjJqRncrWUZXTG1TbnhSNFBCb252cHAKWXdXQVkweWxxTTU0
|
24
|
+
RlBSaGFBSVlDNS8zUHZ4MVNZTDkvVXMwMzc2SEVwVjBSdHk2Vlh6N3RVenY4
|
25
|
+
dkZraTVvdApneWZwNWNlV2lZSVpqUTlVdmhtNGx1SlNmWGNpMTNVSFowQWVP
|
26
|
+
N0UxcGFkV2x4M3o4aFpJdmphd3VlVEdSZTVwCkJnWmxJMCt4VjJvZ3ZBbHU4
|
27
|
+
L05DeTBoV1V3Y3BudlJkUHlCVkRSTWxpOGdYR0U5ak52OGRCV2U2N3ZkanpH
|
28
|
+
U2sKWURVQ0F3RUFBYU4zTUhVd0NRWURWUjBUQkFJd0FEQUxCZ05WSFE4RUJB
|
29
|
+
TUNCTEF3SFFZRFZSME9CQllFRkluaApxdkprdUlTTnFET2NzckJSb3RaQzBx
|
30
|
+
b2xNQjBHQTFVZEVRUVdNQlNCRW5ScFlXSmhjMjVyUUdkdFlXbHNMbU52CmJU
|
31
|
+
QWRCZ05WSFJJRUZqQVVnUkowYVdGaVlYTnVhMEJuYldGcGJDNWpiMjB3RFFZ
|
32
|
+
SktvWklodmNOQVFFRkJRQUQKZ2dFQkFFR2I0Z1JEdWxKOWprZjVvUkx5ZGZ3
|
33
|
+
OVVaaTZmVldqNmFhaUpmYmJUNU5Mb3RwVmFXbldkQ09PN2h5OApIRFBZV040
|
34
|
+
MzB6THdyME9ET1U5WE51ZUtuRWtobkJSaVlrY1EwSm1ZZGRQa0w1N2twMHFs
|
35
|
+
SDRnMklxUWZRVjJXCjFiN3NFNDEwekZIbjU1QjVuaWhRWTNjME1NU0w3d3E5
|
36
|
+
RHoyRWt0YklNaWtmNnNHNnpmVWdZRkU0SVFHaTJSYk8KeGE1Zm5UV3Q3S0I1
|
37
|
+
REQwMkhuSExUWjlIbDJreGxQeVd3eWpSRXdOd0VqUG9TVUpGRUJpb3N2QW1s
|
38
|
+
OGZyVURBOQpqNmZBVGcvNGZxcGdJTFBWcUZJR1pPTUpERmNKeS9vZWh3d3hM
|
39
|
+
dTVYTXg4OFdGRDlqVDF2Umo3N0Q3aVBMYlhkCnJmR3MvcUNKS2dpZlhkLzFh
|
40
|
+
bTVobEFINWpYVT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
|
13
41
|
date: 2013-04-08 00:00:00.000000000 Z
|
14
42
|
dependencies:
|
15
43
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
44
|
+
name: oj
|
17
45
|
requirement: !ruby/object:Gem::Requirement
|
18
46
|
none: false
|
19
47
|
requirements:
|
20
|
-
- -
|
48
|
+
- - ~>
|
21
49
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
50
|
+
version: 2.0.10
|
23
51
|
type: :runtime
|
24
52
|
prerelease: false
|
25
53
|
version_requirements: !ruby/object:Gem::Requirement
|
26
54
|
none: false
|
27
55
|
requirements:
|
28
|
-
- -
|
56
|
+
- - ~>
|
29
57
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
58
|
+
version: 2.0.10
|
31
59
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
60
|
+
name: multi_json
|
33
61
|
requirement: !ruby/object:Gem::Requirement
|
34
62
|
none: false
|
35
63
|
requirements:
|
36
|
-
- -
|
64
|
+
- - ~>
|
37
65
|
- !ruby/object:Gem::Version
|
38
|
-
version: '
|
66
|
+
version: '1.3'
|
39
67
|
type: :runtime
|
40
68
|
prerelease: false
|
41
69
|
version_requirements: !ruby/object:Gem::Requirement
|
42
70
|
none: false
|
43
71
|
requirements:
|
44
|
-
- -
|
72
|
+
- - ~>
|
45
73
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
74
|
+
version: '1.3'
|
47
75
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
76
|
+
name: oauth2-client
|
49
77
|
requirement: !ruby/object:Gem::Requirement
|
50
78
|
none: false
|
51
79
|
requirements:
|
52
|
-
- -
|
80
|
+
- - ~>
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
82
|
+
version: 1.1.2
|
55
83
|
type: :runtime
|
56
84
|
prerelease: false
|
57
85
|
version_requirements: !ruby/object:Gem::Requirement
|
58
86
|
none: false
|
59
87
|
requirements:
|
60
|
-
- -
|
88
|
+
- - ~>
|
61
89
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
90
|
+
version: 1.1.2
|
63
91
|
- !ruby/object:Gem::Dependency
|
64
|
-
name:
|
92
|
+
name: addressable
|
65
93
|
requirement: !ruby/object:Gem::Requirement
|
66
94
|
none: false
|
67
95
|
requirements:
|
68
|
-
- -
|
96
|
+
- - ~>
|
69
97
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
98
|
+
version: 2.3.3
|
71
99
|
type: :runtime
|
72
100
|
prerelease: false
|
73
101
|
version_requirements: !ruby/object:Gem::Requirement
|
74
102
|
none: false
|
75
103
|
requirements:
|
76
|
-
- -
|
104
|
+
- - ~>
|
77
105
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
106
|
+
version: 2.3.3
|
79
107
|
- !ruby/object:Gem::Dependency
|
80
108
|
name: rake
|
81
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,20 +195,20 @@ files:
|
|
167
195
|
- lib/yammer/api/thread.rb
|
168
196
|
- lib/yammer/api/topic.rb
|
169
197
|
- lib/yammer/api/user.rb
|
198
|
+
- lib/yammer/base.rb
|
170
199
|
- lib/yammer/client.rb
|
171
200
|
- lib/yammer/configurable.rb
|
172
201
|
- lib/yammer/error.rb
|
202
|
+
- lib/yammer/group.rb
|
203
|
+
- lib/yammer/group_membership.rb
|
173
204
|
- lib/yammer/http_connection.rb
|
174
205
|
- lib/yammer/identity_map.rb
|
206
|
+
- lib/yammer/message.rb
|
207
|
+
- lib/yammer/message_body.rb
|
175
208
|
- lib/yammer/model.rb
|
176
|
-
- lib/yammer/model/base.rb
|
177
|
-
- lib/yammer/model/group.rb
|
178
|
-
- lib/yammer/model/group_membership.rb
|
179
|
-
- lib/yammer/model/message.rb
|
180
|
-
- lib/yammer/model/message_body.rb
|
181
|
-
- lib/yammer/model/thread.rb
|
182
|
-
- lib/yammer/model/user.rb
|
183
209
|
- lib/yammer/response.rb
|
210
|
+
- lib/yammer/thread.rb
|
211
|
+
- lib/yammer/user.rb
|
184
212
|
- lib/yammer/version.rb
|
185
213
|
- spec/api/autocomplete_spec.rb
|
186
214
|
- spec/api/group_membership_spec.rb
|
@@ -215,7 +243,8 @@ files:
|
|
215
243
|
homepage: http://tiabas.github.io/yammer-client
|
216
244
|
licenses:
|
217
245
|
- MIT
|
218
|
-
post_install_message:
|
246
|
+
post_install_message: ! ' Thanks for installing! If you like this gem please spread
|
247
|
+
the word '
|
219
248
|
rdoc_options: []
|
220
249
|
require_paths:
|
221
250
|
- lib
|
metadata.gz.sig
ADDED
Binary file
|
data/lib/yammer/model/base.rb
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
module Yammer
|
2
|
-
module Model
|
3
|
-
class Base
|
4
|
-
|
5
|
-
def self.attr_accessor_deffered(*symbols)
|
6
|
-
symbols.each do |key|
|
7
|
-
fetchable_keys[key] = true
|
8
|
-
|
9
|
-
define_method (key.to_s) do
|
10
|
-
if self.class.fetchable_keys.has_key?(key) && !@attrs.has_key?(key) && @id
|
11
|
-
load!
|
12
|
-
end
|
13
|
-
instance_variable_get("@#{key}")
|
14
|
-
end
|
15
|
-
|
16
|
-
define_method ("#{key}=") do |value|
|
17
|
-
if @attrs.fetch(key, false) && !new_record?
|
18
|
-
@modified_attributes[key] = value
|
19
|
-
else
|
20
|
-
@attrs[key] = value
|
21
|
-
end
|
22
|
-
instance_variable_set("@#{key}", value)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# @!scope class
|
28
|
-
def self.fetchable_keys
|
29
|
-
@fetchable_keys ||= {}
|
30
|
-
return @fetchable_keys
|
31
|
-
end
|
32
|
-
|
33
|
-
# @!scope class
|
34
|
-
def self.identity_map
|
35
|
-
@identity_map ||= Yammer::IdentityMap.new
|
36
|
-
end
|
37
|
-
|
38
|
-
# @!scope class
|
39
|
-
def self.base_name
|
40
|
-
word = "#{self.name.split(/::/).last}"
|
41
|
-
word.gsub!(/::/, '/')
|
42
|
-
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
43
|
-
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
44
|
-
word.tr!("-", "_")
|
45
|
-
word.downcase!
|
46
|
-
word
|
47
|
-
end
|
48
|
-
|
49
|
-
# @!scope class
|
50
|
-
def self.fetch(id)
|
51
|
-
return unless identity_map
|
52
|
-
attributes = identity_map.get("#{self.base_name}_#{id}")
|
53
|
-
unless attributes
|
54
|
-
result = Yammer.send("get_#{self.base_name}", id)
|
55
|
-
attributes = result.body || {}
|
56
|
-
unless attributes.empty?
|
57
|
-
identity_map.put("#{self.base_name}_#{id}", attributes)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
attributes
|
61
|
-
end
|
62
|
-
|
63
|
-
# @!scope class
|
64
|
-
def self.get(id)
|
65
|
-
new(fetch(id))
|
66
|
-
end
|
67
|
-
|
68
|
-
attr_reader :id, :attrs
|
69
|
-
|
70
|
-
def initialize(props={})
|
71
|
-
@modified_attributes = {}
|
72
|
-
@attrs = {}
|
73
|
-
@new_record = true
|
74
|
-
self.id = props.delete(:id)
|
75
|
-
self.update(props)
|
76
|
-
end
|
77
|
-
|
78
|
-
def base_name
|
79
|
-
self.class.base_name
|
80
|
-
end
|
81
|
-
|
82
|
-
def new_record?
|
83
|
-
@new_record
|
84
|
-
end
|
85
|
-
|
86
|
-
def changes
|
87
|
-
@modified_attributes
|
88
|
-
end
|
89
|
-
|
90
|
-
def modified?
|
91
|
-
!changes.empty?
|
92
|
-
end
|
93
|
-
|
94
|
-
def load!
|
95
|
-
result = self.class.fetch(@id)
|
96
|
-
update(result)
|
97
|
-
end
|
98
|
-
alias_method :reload!, :load!
|
99
|
-
|
100
|
-
def save
|
101
|
-
return self if ((!new_record? && @modified_attributes.empty?) || @attrs.empty?)
|
102
|
-
result = if new_record?
|
103
|
-
Yammer.send("create_#{self.base_name}", @attrs)
|
104
|
-
else
|
105
|
-
Yammer.send("update_#{self.base_name}", @id, @modified_attributes)
|
106
|
-
end
|
107
|
-
@modified_attributes = {}
|
108
|
-
self
|
109
|
-
end
|
110
|
-
|
111
|
-
def delete!
|
112
|
-
return if new_record?
|
113
|
-
result = Yammer.send("delete_#{self.base_name}", @id)
|
114
|
-
result.success?
|
115
|
-
end
|
116
|
-
|
117
|
-
private
|
118
|
-
|
119
|
-
def id=(model_id)
|
120
|
-
return if model_id.nil?
|
121
|
-
@id = model_id.to_i
|
122
|
-
@new_record = false
|
123
|
-
end
|
124
|
-
|
125
|
-
protected
|
126
|
-
def update(props={})
|
127
|
-
props.each do |key, value|
|
128
|
-
send("#{key}=", value)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|