meducation_sdk 0.3.4 → 0.4.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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OTIxZTg2MmU3ZGFlOWZiYmNkODRiN2IzMDBlMWVhYjIyM2JiOTU2YQ==
5
- data.tar.gz: !binary |-
6
- YTRjZmE4MjAxZjRkMjM5YWE0ZjY5MTQyOTcyNWUxN2I4M2RiNjlmMA==
2
+ SHA1:
3
+ metadata.gz: c09b0720421d2ba68de6c57340d067185caa611f
4
+ data.tar.gz: 52d9a6132f82d67b690d22a352db77dc34390290
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MGM0ZjM3MDA3YjA0ZDIzYTY4MmY2OWU1NGJkZTIyNTJmNjY0NmM2MzA0M2Jh
10
- ZjE3ZjVjMjgyODYzYzgxYzc0OWQ5MGUwYTNkZjZhZWVkNmZjMzllZGI3YzI5
11
- ZTEwOGQ1ODhmOGYzYzhjNDRkMWJjOTI2OGYzYjc5MWZhNjYxY2Y=
12
- data.tar.gz: !binary |-
13
- NTE0MGY5YTJkNWFiZDFjYjhjNGFhZTFhOWZmNDQxNGE4MDE1YWVmYjY2OTY5
14
- N2Y4YTZiNmM4MTc4YjIxMWJjYTEyZjc0MTBmYWRkMmFkYjFiOTM1YmU1ZjA1
15
- MDFkZTQ5NTQ5NDI0YTFmNWI5ZDgzMGE1MzlhMDBmNzY5ZGU0NDQ=
6
+ metadata.gz: 3013bd49b1e992c83e86b3db0edfcad2442523fd230fda273d3494b38f81d84f1acc2b229957e4be99061fb4c06bc68932cf465047d3ef15d0d450980e4af75b
7
+ data.tar.gz: 752d37fe42d748437a68c5b289912fd465bb7852f6e0932526c624e6c90e938fe7613344f3c615ffbef055b5bac787b71f66005d2da66379b69e9d0f993e4088
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
+ # 0.4.0 / 2013-12-13
2
+ * [FEATURE] Add lots more resources.
3
+ * [FEATURE] Support pluralisd resources.
4
+
1
5
  # 0.3.4 / 2013-12-13
2
- * [FEATURE] Upgrade to latest loquor to support caching
6
+ * [FEATURE] Upgrade to latest loquor to support caching.
3
7
  * [BUG FIX] Fixed loading of mesh_heading parents.
4
8
 
5
9
  # 0.3.3 / 2013-12-11
@@ -42,15 +42,15 @@ module MeducationSDK
42
42
 
43
43
  private
44
44
  def resource_klass
45
- @resource_name.classify
45
+ @resource_name.camelize
46
46
  end
47
47
 
48
48
  def mock_klass
49
- "#{@resource_name}_mock".classify
49
+ "#{@resource_name}_mock".camelize
50
50
  end
51
51
 
52
52
  def original_klass
53
- "#{@resource_name}_original".classify
53
+ "#{@resource_name}_original".camelize
54
54
  end
55
55
  end
56
56
  end
@@ -0,0 +1,14 @@
1
+ module MeducationSDK
2
+ class Community < Loquor::Resource
3
+ self.path = "/communities"
4
+ end
5
+
6
+ class CommunityMock < Community
7
+ extend Loquor::ResourceMock
8
+
9
+ self.attributes = {
10
+ id: 1,
11
+ name: "Some Community Name"
12
+ }
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ module MeducationSDK
2
+ class CommunityMembership < Loquor::Resource
3
+ self.path = "/community_memberships"
4
+ end
5
+
6
+ class CommunityMembershipMock < CommunityMembership
7
+ extend Loquor::ResourceMock
8
+
9
+ self.attributes = {
10
+ id: 1,
11
+ community_id: 23,
12
+ user_id: 49,
13
+ }
14
+ end
15
+ end
16
+
@@ -0,0 +1,19 @@
1
+ module MeducationSDK
2
+ class EcommerceSubscription < Loquor::Resource
3
+ self.path = "/ecommerce_subscriptions"
4
+
5
+ def user
6
+ @user ||= User.find(user_id)
7
+ end
8
+ end
9
+
10
+ class EcommerceSubscriptionMock < EcommerceSubscription
11
+ extend Loquor::ResourceMock
12
+
13
+ self.attributes = {
14
+ id: 1,
15
+ user_id: 89,
16
+ product_id: 1
17
+ }
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ module MeducationSDK
2
+ class Friendship < Loquor::Resource
3
+ self.path = "/user_friendships"
4
+
5
+ def user
6
+ @user ||= User.find(user_id)
7
+ end
8
+
9
+ def friend
10
+ @friend ||= User.find(friend_id)
11
+ end
12
+ end
13
+
14
+ class FriendshipMock < Friendship
15
+ extend Loquor::ResourceMock
16
+
17
+ self.attributes = {
18
+ id: 1,
19
+ user_id: 8,
20
+ friend_id: 9
21
+ }
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module MeducationSDK
2
+ class Group < Loquor::Resource
3
+ self.path = "/groups"
4
+
5
+ def created_by
6
+ @created_by = User.find(created_by_id)
7
+ end
8
+ end
9
+
10
+ class GroupMock < Group
11
+ extend Loquor::ResourceMock
12
+
13
+ self.attributes = {
14
+ id: 1,
15
+ created_by_id: 23,
16
+ title: "My first group",
17
+ image_url: "http://i.telegraph.co.uk/multimedia/archive/02351/cross-eyed-cat_2351472k.jpg"
18
+ }
19
+ end
20
+ end
21
+
22
+
@@ -0,0 +1,28 @@
1
+ module MeducationSDK
2
+ class GroupDiscussion < Loquor::Resource
3
+ self.path = "/group_discussions"
4
+
5
+ def group
6
+ @group ||= Group.find(group_id)
7
+ end
8
+
9
+ def started_by
10
+ @started_by ||= User.find(started_by_id)
11
+ end
12
+
13
+ def posts
14
+ @posts = GroupDiscussionPost.where(discussion_id: id)
15
+ end
16
+ end
17
+
18
+ class GroupDiscussionMock < GroupDiscussion
19
+ extend Loquor::ResourceMock
20
+
21
+ self.attributes = {
22
+ id: 1,
23
+ group_id: 8,
24
+ started_by: 7
25
+ }
26
+ end
27
+ end
28
+
@@ -0,0 +1,25 @@
1
+ module MeducationSDK
2
+ class GroupDiscussionPost < Loquor::Resource
3
+ self.path = "/group_discussions_posts"
4
+
5
+ def user
6
+ @user ||= User.find(user_id)
7
+ end
8
+
9
+ def discussion
10
+ @discussion ||= GroupDiscussion.find(discussion_id)
11
+ end
12
+ end
13
+
14
+ class GroupDiscussionPostMock < GroupDiscussionPost
15
+ extend Loquor::ResourceMock
16
+
17
+ self.attributes = {
18
+ id: 1,
19
+ user_id: 3,
20
+ discussion_id: 8
21
+ }
22
+ end
23
+ end
24
+
25
+
@@ -0,0 +1,31 @@
1
+ module MeducationSDK
2
+ class GroupInvite < Loquor::Resource
3
+ self.path = "/group_invites"
4
+
5
+ def group
6
+ @group ||= Group.find(group_id)
7
+ end
8
+
9
+ def invited_by
10
+ @invited_by ||= User.find(invited_by_id)
11
+ end
12
+
13
+ def user
14
+ @user ||= User.find(user_id)
15
+ end
16
+ end
17
+
18
+ class GroupInviteMock < GroupInvite
19
+ extend Loquor::ResourceMock
20
+
21
+ self.attributes = {
22
+ id: 1,
23
+ group_id: 8,
24
+ user_id: 8,
25
+ invited_by_id: 12,
26
+ message: "",
27
+ email: ""
28
+ }
29
+ end
30
+ end
31
+
@@ -0,0 +1,23 @@
1
+ module MeducationSDK
2
+ class GroupMembership < Loquor::Resource
3
+ self.path = "/group_memberships"
4
+
5
+ def group
6
+ @group ||= Group.find(group_id)
7
+ end
8
+
9
+ def user
10
+ @user ||= User.find(user_id)
11
+ end
12
+ end
13
+
14
+ class GroupMembershipMock < GroupMembership
15
+ extend Loquor::ResourceMock
16
+
17
+ self.attributes = {
18
+ id: 1,
19
+ group_id: 5,
20
+ user_id: 8
21
+ }
22
+ end
23
+ end
@@ -5,6 +5,10 @@ module MeducationSDK
5
5
  def item
6
6
  @item ||= "MeducationSDK::#{item_type}".constantize.find(item_id)
7
7
  end
8
+
9
+ def user
10
+ @user ||= User.find(user_id)
11
+ end
8
12
  end
9
13
 
10
14
  class ItemCommentMock < ItemComment
@@ -0,0 +1,23 @@
1
+ module MeducationSDK
2
+ class KnowledgeBankAnswer < Loquor::Resource
3
+ self.path = "/knowledge_bank_answers"
4
+
5
+ def question
6
+ @question = KnowledgeBankQuestion.find(question_id)
7
+ end
8
+
9
+ def user
10
+ @user = User.find(user_id)
11
+ end
12
+ end
13
+
14
+ class KnowledgeBankAnswerMock < KnowledgeBankAnswer
15
+ extend Loquor::ResourceMock
16
+
17
+ self.attributes = {
18
+ id: 1,
19
+ question_id: 5,
20
+ user_id: 12
21
+ }
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module MeducationSDK
2
+ class KnowledgeBankQuestion < Loquor::Resource
3
+ self.path = "/knowledge_bank_questions"
4
+
5
+ def user
6
+ @user = User.find(user_id)
7
+ end
8
+ end
9
+
10
+ class KnowledgeBankQuestionMock < KnowledgeBankQuestion
11
+ extend Loquor::ResourceMock
12
+
13
+ self.attributes = {
14
+ id: 1,
15
+ user_id: 12
16
+ }
17
+ end
18
+ end
19
+
@@ -10,6 +10,18 @@ module MeducationSDK
10
10
  @comments ||= ItemComment.where(item_id: id, item_type: "MediaFile")
11
11
  end
12
12
 
13
+ def media_type
14
+ case media_type_id
15
+ when 1; 'slideshow'
16
+ when 2; 'video'
17
+ when 3; 'podcast'
18
+ when 4; 'other'
19
+ when 5; 'image'
20
+ when 6; 'document'
21
+ when 7; 'application'
22
+ end
23
+ end
24
+
13
25
  module State
14
26
  def self.uploaded; 1 end
15
27
  def self.processing; 2 end
@@ -24,6 +36,7 @@ module MeducationSDK
24
36
  self.attributes = {
25
37
  id: 1,
26
38
  user_id: 1,
39
+ media_type_id: 2,
27
40
  title: "Abdominal Ultrasound Tutorial"
28
41
  }
29
42
  end
@@ -0,0 +1,25 @@
1
+ module MeducationSDK
2
+ class Message < Loquor::Resource
3
+ self.path = "/message_threads"
4
+
5
+ def from
6
+ @user ||= User.find(from_id)
7
+ end
8
+
9
+ def thread
10
+ @thread ||= MessageThread.find(thread_id)
11
+ end
12
+ end
13
+
14
+ class MessageMock < Message
15
+ extend Loquor::ResourceMock
16
+
17
+ self.attributes = {
18
+ id: 1,
19
+ thread_id: 20,
20
+ from_id: 10
21
+ }
22
+ end
23
+ end
24
+
25
+
@@ -0,0 +1,22 @@
1
+ module MeducationSDK
2
+ class MessageThread < Loquor::Resource
3
+ self.path = "/message_threads"
4
+
5
+ def contributors
6
+ @contributors ||= MessageThreadContributor.where(thread_id: id)
7
+ end
8
+
9
+ def messages
10
+ @messages ||= Message.where(thread_id: id)
11
+ end
12
+ end
13
+
14
+ class MessageThreadMock < MessageThread
15
+ extend Loquor::ResourceMock
16
+
17
+ self.attributes = {
18
+ id: 1
19
+ }
20
+ end
21
+ end
22
+
@@ -0,0 +1,13 @@
1
+ module MeducationSDK
2
+ class MessageThreadContributor < Loquor::Resource
3
+ self.path = "/message_threads"
4
+ end
5
+
6
+ class MessageThreadContributorMock < MessageThreadContributor
7
+ extend Loquor::ResourceMock
8
+
9
+ self.attributes = {
10
+ id: 1
11
+ }
12
+ end
13
+ end
@@ -1,6 +1,18 @@
1
1
  module MeducationSDK
2
2
  class User < Loquor::Resource
3
3
  self.path = "/users"
4
+
5
+ def community_memberships
6
+ CommunityMembership.where(user_id: 1)
7
+ end
8
+
9
+ def communities
10
+ Community.where(id: community_memberships.map(&:id))
11
+ end
12
+
13
+ def settings
14
+ UserSettings.where(user_id: id).first
15
+ end
4
16
  end
5
17
 
6
18
  class UserMock < User
@@ -8,7 +20,9 @@ module MeducationSDK
8
20
 
9
21
  self.attributes = {
10
22
  id: 1,
11
- name: "Jeremy Walker"
23
+ name: "Jeremy Walker",
24
+ photo_url: "http://i.telegraph.co.uk/multimedia/archive/02351/cross-eyed-cat_2351472k.jpg",
25
+ primary_email_address: "jez.walker@gmail.com"
12
26
  }
13
27
  end
14
28
  end
@@ -0,0 +1,14 @@
1
+ module MeducationSDK
2
+ class UserSettings < Loquor::Resource
3
+ self.path = "/user_settings"
4
+ end
5
+
6
+ class UserSettingsMock < UserSettings
7
+ extend Loquor::ResourceMock
8
+
9
+ self.attributes = {
10
+ id: 1,
11
+ email_on_comment: true
12
+ }
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module MeducationSDK
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -6,15 +6,30 @@ require "meducation_sdk/configuration"
6
6
  require "meducation_sdk/mocker"
7
7
 
8
8
  RESOURCES = %w{
9
+ community
10
+ community_membership
11
+ ecommerce_subscription
12
+ friendship
13
+ group
14
+ group_discussion
15
+ group_discussion_post
16
+ group_invite
17
+ group_membership
9
18
  item_comment
19
+ knowledge_bank_question
20
+ knowledge_bank_answer
10
21
  media_file
11
22
  mesh_heading
23
+ message
24
+ message_thread
25
+ message_thread_contributor
12
26
  mnemonic
13
27
  notification
14
28
  partner
15
29
  premium_tutorial
16
30
  syllabus_item
17
31
  user
32
+ user_settings
18
33
  }
19
34
  RESOURCES.each do |resource|
20
35
  require "meducation_sdk/resources/#{resource}"
@@ -0,0 +1,9 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+ module MeducationSDK
3
+ class ArbitaryTest < Minitest::Test
4
+ def test_shit_happens
5
+ skip
6
+ MediaFile.update(8, title: "Foobar to the Malcy Max")
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meducation_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -98,28 +98,28 @@ dependencies:
98
98
  name: mocha
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  description: Meducation's SDK
@@ -140,17 +140,33 @@ files:
140
140
  - lib/meducation_sdk.rb
141
141
  - lib/meducation_sdk/configuration.rb
142
142
  - lib/meducation_sdk/mocker.rb
143
+ - lib/meducation_sdk/resources/community.rb
144
+ - lib/meducation_sdk/resources/community_membership.rb
145
+ - lib/meducation_sdk/resources/ecommerce_subscription.rb
146
+ - lib/meducation_sdk/resources/friendship.rb
147
+ - lib/meducation_sdk/resources/group.rb
148
+ - lib/meducation_sdk/resources/group_discussion.rb
149
+ - lib/meducation_sdk/resources/group_discussion_post.rb
150
+ - lib/meducation_sdk/resources/group_invite.rb
151
+ - lib/meducation_sdk/resources/group_membership.rb
143
152
  - lib/meducation_sdk/resources/item_comment.rb
153
+ - lib/meducation_sdk/resources/knowledge_bank_answer.rb
154
+ - lib/meducation_sdk/resources/knowledge_bank_question.rb
144
155
  - lib/meducation_sdk/resources/media_file.rb
145
156
  - lib/meducation_sdk/resources/mesh_heading.rb
157
+ - lib/meducation_sdk/resources/message.rb
158
+ - lib/meducation_sdk/resources/message_thread.rb
159
+ - lib/meducation_sdk/resources/message_thread_contributor.rb
146
160
  - lib/meducation_sdk/resources/mnemonic.rb
147
161
  - lib/meducation_sdk/resources/notification.rb
148
162
  - lib/meducation_sdk/resources/partner.rb
149
163
  - lib/meducation_sdk/resources/premium_tutorial.rb
150
164
  - lib/meducation_sdk/resources/syllabus_item.rb
151
165
  - lib/meducation_sdk/resources/user.rb
166
+ - lib/meducation_sdk/resources/user_settings.rb
152
167
  - lib/meducation_sdk/version.rb
153
168
  - meducation_sdk.gemspec
169
+ - test/arbitary_test.rb
154
170
  - test/configuration_test.rb
155
171
  - test/mocker_test.rb
156
172
  - test/resource_test.rb
@@ -169,12 +185,12 @@ require_paths:
169
185
  - lib
170
186
  required_ruby_version: !ruby/object:Gem::Requirement
171
187
  requirements:
172
- - - ! '>='
188
+ - - '>='
173
189
  - !ruby/object:Gem::Version
174
190
  version: '0'
175
191
  required_rubygems_version: !ruby/object:Gem::Requirement
176
192
  requirements:
177
- - - ! '>='
193
+ - - '>='
178
194
  - !ruby/object:Gem::Version
179
195
  version: '0'
180
196
  requirements: []
@@ -184,6 +200,7 @@ signing_key:
184
200
  specification_version: 4
185
201
  summary: The SDK for Meducation
186
202
  test_files:
203
+ - test/arbitary_test.rb
187
204
  - test/configuration_test.rb
188
205
  - test/mocker_test.rb
189
206
  - test/resource_test.rb