yam 0.0.6 → 1.0.0

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.
Files changed (88) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.travis.yml +5 -0
  3. data/.yardopts +10 -0
  4. data/AUTHORS +1 -0
  5. data/CHANGELOG.md +7 -0
  6. data/CONTRIBUTING.md +0 -7
  7. data/Gemfile +27 -1
  8. data/README.md +190 -67
  9. data/Rakefile +9 -3
  10. data/certs/public.pem +20 -0
  11. data/lib/yammer.rb +47 -0
  12. data/lib/yammer/api.rb +29 -0
  13. data/lib/yammer/api/autocomplete.rb +39 -0
  14. data/lib/yammer/api/group.rb +92 -0
  15. data/lib/yammer/api/group_membership.rb +46 -0
  16. data/lib/yammer/api/invitation.rb +39 -0
  17. data/lib/yammer/api/like.rb +57 -0
  18. data/lib/yammer/api/message.rb +227 -0
  19. data/lib/yammer/api/network.rb +35 -0
  20. data/lib/yammer/api/notification.rb +32 -0
  21. data/lib/yammer/api/open_graph_object.rb +92 -0
  22. data/lib/yammer/api/pending_attachment.rb +64 -0
  23. data/lib/yammer/api/search.rb +42 -0
  24. data/lib/yammer/api/subscription.rb +32 -0
  25. data/lib/yammer/api/thread.rb +37 -0
  26. data/lib/yammer/api/topic.rb +37 -0
  27. data/lib/yammer/api/user.rb +168 -0
  28. data/lib/yammer/api_handler.rb +27 -0
  29. data/lib/yammer/api_response.rb +57 -0
  30. data/lib/yammer/base.rb +208 -0
  31. data/lib/yammer/client.rb +100 -0
  32. data/lib/yammer/configurable.rb +81 -0
  33. data/lib/yammer/error.rb +75 -0
  34. data/lib/yammer/group.rb +27 -0
  35. data/lib/yammer/group_membership.rb +25 -0
  36. data/lib/yammer/http_adapter.rb +100 -0
  37. data/lib/yammer/identity_map.rb +56 -0
  38. data/lib/yammer/message.rb +32 -0
  39. data/lib/yammer/message_body.rb +27 -0
  40. data/lib/yammer/pending_attachment.rb +19 -0
  41. data/lib/yammer/thread.rb +58 -0
  42. data/lib/yammer/user.rb +66 -0
  43. data/lib/yammer/version.rb +32 -0
  44. data/{lib/yam/configuration.rb → spec/api/autocomplete_spec.rb} +18 -23
  45. data/spec/api/group_membership_spec.rb +48 -0
  46. data/spec/api/group_spec.rb +76 -0
  47. data/spec/api/invitation_spec.rb +60 -0
  48. data/spec/api/like_spec.rb +46 -0
  49. data/spec/api/message_spec.rb +136 -0
  50. data/spec/api/network_spec.rb +41 -0
  51. data/{lib/yam/client.rb → spec/api/notification_spec.rb} +22 -4
  52. data/spec/api/open_graph_object_spec.rb +67 -0
  53. data/spec/api/pending_attachment_spec.rb +56 -0
  54. data/{lib/yam/constants.rb → spec/api/search_spec.rb} +21 -8
  55. data/spec/api/subscription_spec.rb +41 -0
  56. data/{lib/yam.rb → spec/api/thread_spec.rb} +19 -12
  57. data/{lib/yam/request.rb → spec/api/topic_spec.rb} +19 -15
  58. data/spec/api/user_spec.rb +108 -0
  59. data/spec/api_response.rb +86 -0
  60. data/spec/client_spec.rb +364 -0
  61. data/spec/error_spec.rb +88 -0
  62. data/spec/fixtures/group.json +1 -0
  63. data/spec/fixtures/message.json +1 -0
  64. data/spec/fixtures/messages_in_thread.json +1 -0
  65. data/spec/fixtures/portal_thread.json +1 -0
  66. data/spec/fixtures/private_thread.json +1 -0
  67. data/spec/fixtures/public_thread.json +1 -0
  68. data/spec/fixtures/user.json +1 -0
  69. data/spec/fixtures/users_followed.json +1 -0
  70. data/spec/fixtures/users_following.json +1 -0
  71. data/spec/http_adapter_spec.rb +109 -0
  72. data/spec/identity_map_spec.rb +127 -0
  73. data/spec/mocks/attachment.txt +1 -0
  74. data/spec/model/base_spec.rb +196 -0
  75. data/spec/model/group_membership_spec.rb +57 -0
  76. data/spec/model/group_spec.rb +73 -0
  77. data/spec/model/message_spec.rb +74 -0
  78. data/spec/model/thread_spec.rb +91 -0
  79. data/spec/model/user_spec.rb +222 -0
  80. data/spec/spec_helper.rb +39 -14
  81. data/yam.gemspec +50 -28
  82. metadata +270 -187
  83. metadata.gz.sig +0 -0
  84. data/lib/yam/api.rb +0 -53
  85. data/lib/yam/connection.rb +0 -57
  86. data/lib/yam/version.rb +0 -20
  87. data/spec/yam/client_spec.rb +0 -50
  88. data/spec/yam_spec.rb +0 -87
metadata.gz.sig ADDED
Binary file
data/lib/yam/api.rb DELETED
@@ -1,53 +0,0 @@
1
- # Copyright (c) Microsoft Corporation
2
- # All rights reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
12
- # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
13
- # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
14
- #
15
- # See the Apache Version 2.0 License for specific language governing
16
- # permissions and limitations under the License.
17
-
18
- # API setup and configuration
19
- require 'yam/configuration'
20
- require 'yam/connection'
21
- require 'yam/request'
22
-
23
- module Yam
24
- class API
25
- include Connection
26
- include Request
27
- attr_reader *Configuration::VALID_OPTIONS_KEYS
28
- attr_reader :oauth_token, :endpoint
29
-
30
- class_eval do
31
- Configuration::VALID_OPTIONS_KEYS.each do |key|
32
- define_method "#{key}=" do |arg|
33
- self.instance_variable_set("@#{key}", arg)
34
- Yam.send("#{key}=", arg)
35
- end
36
- end
37
- end
38
-
39
- def initialize(oauth_token, endpoint)
40
- @oauth_token = oauth_token
41
- @endpoint = endpoint
42
- setup({})
43
- end
44
-
45
- def setup(options={})
46
- options = Yam.options.merge(options)
47
-
48
- Configuration::VALID_OPTIONS_KEYS.each do |key|
49
- send("#{key}=", options[key])
50
- end
51
- end
52
- end
53
- end
@@ -1,57 +0,0 @@
1
- # Copyright (c) Microsoft Corporation
2
- # All rights reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
12
- # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
13
- # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
14
- #
15
- # See the Apache Version 2.0 License for specific language governing
16
- # permissions and limitations under the License.
17
-
18
- require 'faraday'
19
- require 'faraday_middleware/request/oauth2'
20
- require 'faraday_middleware/response/mashify'
21
- require 'faraday_middleware/response/parse_json'
22
- require 'yam/constants'
23
-
24
- module Yam
25
- module Connection
26
- extend self
27
- include Yam::Constants
28
-
29
- def default_options(options={})
30
- {
31
- :headers => {
32
- ACCEPT => 'application/json',
33
- ACCEPT_CHARSET => 'utf-8',
34
- USER_AGENT => user_agent
35
- },
36
- :ssl => { :verify => true },
37
- :url => options.fetch(:endpoint) { endpoint }
38
- }.merge(options)
39
- end
40
-
41
- # Returns a Faraday::Connection object
42
- def connection(options = {})
43
- conn_options = default_options(options)
44
- clear_cache unless options.empty?
45
- puts "OPTIONS:#{conn_options.inspect}" if ENV['DEBUG']
46
-
47
- @connection ||= Faraday.new(conn_options) do |conn|
48
- conn.use Faraday::Response::Mashify
49
- conn.use FaradayMiddleware::ParseJson
50
- conn.response :raise_error
51
- conn.use FaradayMiddleware::OAuth2, oauth_token
52
- conn.request :url_encoded
53
- conn.adapter adapter
54
- end
55
- end
56
- end
57
- end
data/lib/yam/version.rb DELETED
@@ -1,20 +0,0 @@
1
- # Copyright (c) Microsoft Corporation
2
- # All rights reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
12
- # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
13
- # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
14
- #
15
- # See the Apache Version 2.0 License for specific language governing
16
- # permissions and limitations under the License.
17
-
18
- module Yam
19
- VERSION = '0.0.6'
20
- end
@@ -1,50 +0,0 @@
1
- # Copyright (c) Microsoft Corporation
2
- # All rights reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
12
- # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
13
- # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
14
- #
15
- # See the Apache Version 2.0 License for specific language governing
16
- # permissions and limitations under the License.
17
-
18
- require 'spec_helper'
19
-
20
- describe Yam::Client, '#get' do
21
- it 'makes requests' do
22
- access_token = 'ABC123'
23
- endpoint_with_token = "#{ENDPOINT}?access_token=#{access_token}"
24
- stub_request(:get, endpoint_with_token).
25
- with(:headers => { 'Authorization'=>'Token token="ABC123"' })
26
-
27
- instance = Yam::Client.new(access_token, ENDPOINT)
28
- instance.get('/')
29
-
30
- expect(a_request(:get, endpoint_with_token).
31
- with(:headers => { 'Authorization'=>'Token token="ABC123"' })).
32
- to have_been_made
33
- end
34
- end
35
-
36
- describe Yam::Client, '#post' do
37
- it 'makes requests' do
38
- access_token = 'ABC123'
39
- endpoint_with_token = "#{ENDPOINT}?access_token=#{access_token}"
40
- stub_request(:post, endpoint_with_token).
41
- with(:headers => { 'Authorization'=>'Token token="ABC123"' })
42
-
43
- instance = Yam::Client.new(access_token, ENDPOINT)
44
- instance.post('/')
45
-
46
- expect(a_request(:post, endpoint_with_token).
47
- with(:headers => { 'Authorization'=>'Token token="ABC123"' })).
48
- to have_been_made
49
- end
50
- end
data/spec/yam_spec.rb DELETED
@@ -1,87 +0,0 @@
1
- # Copyright (c) Microsoft Corporation
2
- # All rights reserved.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
12
- # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
13
- # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
14
- #
15
- # See the Apache Version 2.0 License for specific language governing
16
- # permissions and limitations under the License.
17
-
18
- require 'spec_helper'
19
-
20
- class TestClass
21
- end
22
-
23
- describe Yam do
24
- after do
25
- Yam.set_defaults
26
- end
27
-
28
- it 'responds to \'new\' message' do
29
- Yam.should respond_to :new
30
- end
31
-
32
- it 'receives \'new\' and initialize an instance' do
33
- access_token = 'ABC123'
34
-
35
- instance = Yam.new(access_token, Yam::Configuration::DEFAULT_API_ENDPOINT)
36
-
37
- instance.should be_a Yam::Client
38
- end
39
-
40
- it 'delegates to a Yam::Client instance' do
41
- access_token = 'ABC123'
42
- Yam::Client.any_instance.stubs(:stubbed_method)
43
-
44
- instance = Yam.new(access_token, Yam::Configuration::DEFAULT_API_ENDPOINT)
45
- instance.stubbed_method
46
-
47
- Yam::Client.any_instance.should have_received(:stubbed_method)
48
- end
49
-
50
- describe 'setting configuration options' do
51
- it 'returns the default adapter' do
52
- adapter = Yam.adapter
53
-
54
- adapter.should == Yam::Configuration::DEFAULT_ADAPTER
55
- end
56
-
57
- it 'allows setting the adapter' do
58
- Yam.adapter = :typhoeus
59
-
60
- Yam.adapter.should == :typhoeus
61
- end
62
-
63
- it 'returns the default end point' do
64
- Yam.endpoint.should == Yam::Configuration::DEFAULT_API_ENDPOINT
65
- end
66
-
67
- it 'allows setting the endpoint' do
68
- Yam.endpoint = 'http://www.example.com'
69
- Yam.endpoint.should == 'http://www.example.com'
70
- end
71
-
72
- it 'returns the default user agent' do
73
- Yam.user_agent.should == Yam::Configuration::DEFAULT_USER_AGENT
74
- end
75
-
76
- it 'allows setting the user agent' do
77
- Yam.user_agent = 'New User Agent'
78
-
79
- Yam.user_agent.should == 'New User Agent'
80
- end
81
-
82
- it 'allows setting the current api client' do
83
- Yam.should respond_to :api_client=
84
- Yam.should respond_to :api_client
85
- end
86
- end
87
- end