ribose 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +539 -970
  4. data/.sample.pryrc +4 -0
  5. data/CHANGELOG.md +5 -0
  6. data/README.md +539 -3
  7. data/bin/console +2 -5
  8. data/lib/ribose.rb +31 -1
  9. data/lib/ribose/actions.rb +10 -0
  10. data/lib/ribose/actions/all.rb +43 -0
  11. data/lib/ribose/actions/base.rb +11 -0
  12. data/lib/ribose/actions/create.rb +44 -0
  13. data/lib/ribose/actions/delete.rb +32 -0
  14. data/lib/ribose/actions/fetch.rb +44 -0
  15. data/lib/ribose/actions/update.rb +35 -0
  16. data/lib/ribose/app_data.rb +15 -0
  17. data/lib/ribose/app_relation.rb +12 -0
  18. data/lib/ribose/base.rb +48 -0
  19. data/lib/ribose/calendar.rb +22 -0
  20. data/lib/ribose/client.rb +31 -0
  21. data/lib/ribose/config.rb +21 -0
  22. data/lib/ribose/configuration.rb +25 -0
  23. data/lib/ribose/connection.rb +39 -0
  24. data/lib/ribose/connection_invitation.rb +51 -0
  25. data/lib/ribose/conversation.rb +87 -0
  26. data/lib/ribose/error.rb +30 -0
  27. data/lib/ribose/feed.rb +11 -0
  28. data/lib/ribose/file_uploader.rb +93 -0
  29. data/lib/ribose/join_space_request.rb +41 -0
  30. data/lib/ribose/leaderboard.rb +19 -0
  31. data/lib/ribose/member.rb +34 -0
  32. data/lib/ribose/message.rb +94 -0
  33. data/lib/ribose/profile.rb +56 -0
  34. data/lib/ribose/request.rb +122 -0
  35. data/lib/ribose/resource_helper.rb +81 -0
  36. data/lib/ribose/response/raise_error.rb +15 -0
  37. data/lib/ribose/rspec.rb +19 -0
  38. data/lib/ribose/session.rb +48 -0
  39. data/lib/ribose/setting.rb +16 -0
  40. data/lib/ribose/space.rb +30 -0
  41. data/lib/ribose/space_file.rb +49 -0
  42. data/lib/ribose/space_invitation.rb +70 -0
  43. data/lib/ribose/stream.rb +15 -0
  44. data/lib/ribose/user.rb +42 -0
  45. data/lib/ribose/version.rb +1 -1
  46. data/lib/ribose/widget.rb +11 -0
  47. data/lib/ribose/wiki.rb +80 -0
  48. data/ribose.gemspec +6 -0
  49. data/spec/fixtures/app_data.json +188 -0
  50. data/spec/fixtures/app_relation.json +19 -0
  51. data/spec/fixtures/app_relations.json +89 -0
  52. data/spec/fixtures/calendar.json +12 -0
  53. data/spec/fixtures/calendars.json +34 -0
  54. data/spec/fixtures/connection_invitation.json +26 -0
  55. data/spec/fixtures/connection_invitation_accepted.json +26 -0
  56. data/spec/fixtures/connection_invitations.json +28 -0
  57. data/spec/fixtures/connection_invitations_created.json +37 -0
  58. data/spec/fixtures/connection_suggestion.json +22 -0
  59. data/spec/fixtures/connections.json +28 -0
  60. data/spec/fixtures/conversation.json +26 -0
  61. data/spec/fixtures/conversation_created.json +31 -0
  62. data/spec/fixtures/conversations.json +34 -0
  63. data/spec/fixtures/empty.json +1 -0
  64. data/spec/fixtures/feeds.json +84 -0
  65. data/spec/fixtures/file_upload_prepared.json +17 -0
  66. data/spec/fixtures/file_uploaded.json +38 -0
  67. data/spec/fixtures/general_information.json +16 -0
  68. data/spec/fixtures/join_space_request_created.json +26 -0
  69. data/spec/fixtures/join_space_request_updated.json +25 -0
  70. data/spec/fixtures/join_space_requests.json +34 -0
  71. data/spec/fixtures/leaderboard.json +21 -0
  72. data/spec/fixtures/login.html +323 -0
  73. data/spec/fixtures/members.json +20 -0
  74. data/spec/fixtures/message.json +22 -0
  75. data/spec/fixtures/messages.json +24 -0
  76. data/spec/fixtures/ping.json +3 -0
  77. data/spec/fixtures/profile.json +10 -0
  78. data/spec/fixtures/sample.png +0 -0
  79. data/spec/fixtures/setting.json +16 -0
  80. data/spec/fixtures/settings.json +18 -0
  81. data/spec/fixtures/space.json +59 -0
  82. data/spec/fixtures/space_created.json +59 -0
  83. data/spec/fixtures/space_file.json +58 -0
  84. data/spec/fixtures/space_invitation.json +32 -0
  85. data/spec/fixtures/space_invitation_updated.json +35 -0
  86. data/spec/fixtures/space_invitations.json +34 -0
  87. data/spec/fixtures/space_mass_invitations.json +46 -0
  88. data/spec/fixtures/spaces.json +61 -0
  89. data/spec/fixtures/stream.json +176 -0
  90. data/spec/fixtures/user_activated.json +6 -0
  91. data/spec/fixtures/widgets.json +50 -0
  92. data/spec/fixtures/wiki.json +79 -0
  93. data/spec/fixtures/wikis.json +197 -0
  94. data/spec/ribose/actions/create_spec.rb +40 -0
  95. data/spec/ribose/actions/delete_spec.rb +24 -0
  96. data/spec/ribose/actions/fetch_spec.rb +32 -0
  97. data/spec/ribose/actions/update_spec.rb +36 -0
  98. data/spec/ribose/app_data_spec.rb +15 -0
  99. data/spec/ribose/app_relation_spec.rb +27 -0
  100. data/spec/ribose/calendar_spec.rb +50 -0
  101. data/spec/ribose/client_spec.rb +48 -0
  102. data/spec/ribose/config_spec.rb +41 -0
  103. data/spec/ribose/connection_invitation_spec.rb +79 -0
  104. data/spec/ribose/connection_spec.rb +26 -0
  105. data/spec/ribose/conversation_spec.rb +84 -0
  106. data/spec/ribose/error_spec.rb +67 -0
  107. data/spec/ribose/feed_spec.rb +14 -0
  108. data/spec/ribose/file_uploader_spec.rb +30 -0
  109. data/spec/ribose/join_space_request_spec.rb +70 -0
  110. data/spec/ribose/leaderboard_spec.rb +13 -0
  111. data/spec/ribose/member_spec.rb +16 -0
  112. data/spec/ribose/message_spec.rb +69 -0
  113. data/spec/ribose/profile_spec.rb +40 -0
  114. data/spec/ribose/request_spec.rb +66 -0
  115. data/spec/ribose/resource_helper_spec.rb +58 -0
  116. data/spec/ribose/session_spec.rb +46 -0
  117. data/spec/ribose/setting_spec.rb +40 -0
  118. data/spec/ribose/space_file_spec.rb +41 -0
  119. data/spec/ribose/space_invitation_spec.rb +117 -0
  120. data/spec/ribose/space_spec.rb +70 -0
  121. data/spec/ribose/stream_spec.rb +14 -0
  122. data/spec/ribose/user_spec.rb +48 -0
  123. data/spec/ribose/widget_spec.rb +14 -0
  124. data/spec/ribose/wiki_spec.rb +67 -0
  125. data/spec/spec_helper.rb +11 -0
  126. data/spec/support/fake_ribose_api.rb +431 -0
  127. data/spec/support/file_upload_stub.rb +76 -0
  128. metadata +190 -3
  129. data/spec/ribose_spec.rb +0 -4
@@ -0,0 +1,76 @@
1
+ require "faraday"
2
+
3
+ module Ribose
4
+ module FileUploadStub
5
+ def stub_ribose_space_file_upload_api(space_id, attributes)
6
+ stub_ribose_aws_s3_file_upload_api
7
+ stub_ribose_file_prepare_api(space_id, attributes)
8
+ stub_ribose_file_upload_notify_api(space_id, attributes)
9
+ end
10
+
11
+ def stub_ribose_file_prepare_api(space_id, attributes)
12
+ stub_api_response(
13
+ :get,
14
+ ribose_prepare_endpoint(space_id, attributes),
15
+ filename: "file_upload_prepared",
16
+ )
17
+ end
18
+
19
+ def stub_ribose_aws_s3_file_upload_api
20
+ stub_request(:post, ribose_endpoint("uploads")).
21
+ with(headers: { "Content-Type"=> /multipart\/form-data/ }).
22
+ to_return(response_with(filename: "empty", status: 200))
23
+ end
24
+
25
+ def stub_ribose_file_upload_notify_api(space_id, attributes)
26
+ stub_api_response(
27
+ :post,
28
+ ribose_file_endpoint(space_id),
29
+ data: build_notify_request_body(attributes),
30
+ filename: "file_uploaded",
31
+ )
32
+ end
33
+
34
+ private
35
+
36
+ def ribose_file_endpoint(space_id)
37
+ ["spaces", space_id, "file", "files"].join("/")
38
+ end
39
+
40
+ def ribose_prepare_endpoint(sid, attrs)
41
+ [ribose_file_endpoint(sid), "prepare?#{prepare_params(attrs)}"].join("/")
42
+ end
43
+
44
+ def prepare_params(attributes)
45
+ Faraday::Utils.build_nested_query(
46
+ extract_file_details(attributes).merge(
47
+ file_info: extract_file_info(attributes),
48
+ ),
49
+ )
50
+ end
51
+
52
+ def build_notify_request_body(attributes)
53
+ extract_file_details(attributes).merge(
54
+ file_info: extract_file_info(attributes),
55
+ key: "uploads/123456789/${filename}",
56
+ )
57
+ end
58
+
59
+ def content_type_form_file(file)
60
+ require "mime/types"
61
+ MIME::Types.type_for(file).first.content_type
62
+ end
63
+
64
+ def extract_file_details(attributes)
65
+ {
66
+ filesize: File.new(attributes[:file]).size,
67
+ filetype: content_type_form_file(attributes[:file]),
68
+ filename: File.basename(attributes[:file]),
69
+ }
70
+ end
71
+
72
+ def extract_file_info(attributes)
73
+ { tag_list: attributes[:tag_list], description: attributes[:description] }
74
+ end
75
+ end
76
+ end
metadata CHANGED
@@ -1,15 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ribose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-08 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sawyer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: mime-types
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mechanize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.7.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.7.5
13
55
  - !ruby/object:Gem::Dependency
14
56
  name: bundler
15
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +94,34 @@ dependencies:
52
94
  - - "~>"
53
95
  - !ruby/object:Gem::Version
54
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.10.4
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.10.4
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.0'
55
125
  description: The Ruby interface for Ribose API
56
126
  email:
57
127
  - operations@ribose.com
@@ -63,7 +133,9 @@ files:
63
133
  - ".hound.yml"
64
134
  - ".rspec"
65
135
  - ".rubocop.yml"
136
+ - ".sample.pryrc"
66
137
  - ".travis.yml"
138
+ - CHANGELOG.md
67
139
  - Gemfile
68
140
  - LICENSE.txt
69
141
  - README.md
@@ -72,10 +144,125 @@ files:
72
144
  - bin/rspec
73
145
  - bin/setup
74
146
  - lib/ribose.rb
147
+ - lib/ribose/actions.rb
148
+ - lib/ribose/actions/all.rb
149
+ - lib/ribose/actions/base.rb
150
+ - lib/ribose/actions/create.rb
151
+ - lib/ribose/actions/delete.rb
152
+ - lib/ribose/actions/fetch.rb
153
+ - lib/ribose/actions/update.rb
154
+ - lib/ribose/app_data.rb
155
+ - lib/ribose/app_relation.rb
156
+ - lib/ribose/base.rb
157
+ - lib/ribose/calendar.rb
158
+ - lib/ribose/client.rb
159
+ - lib/ribose/config.rb
160
+ - lib/ribose/configuration.rb
161
+ - lib/ribose/connection.rb
162
+ - lib/ribose/connection_invitation.rb
163
+ - lib/ribose/conversation.rb
164
+ - lib/ribose/error.rb
165
+ - lib/ribose/feed.rb
166
+ - lib/ribose/file_uploader.rb
167
+ - lib/ribose/join_space_request.rb
168
+ - lib/ribose/leaderboard.rb
169
+ - lib/ribose/member.rb
170
+ - lib/ribose/message.rb
171
+ - lib/ribose/profile.rb
172
+ - lib/ribose/request.rb
173
+ - lib/ribose/resource_helper.rb
174
+ - lib/ribose/response/raise_error.rb
175
+ - lib/ribose/rspec.rb
176
+ - lib/ribose/session.rb
177
+ - lib/ribose/setting.rb
178
+ - lib/ribose/space.rb
179
+ - lib/ribose/space_file.rb
180
+ - lib/ribose/space_invitation.rb
181
+ - lib/ribose/stream.rb
182
+ - lib/ribose/user.rb
75
183
  - lib/ribose/version.rb
184
+ - lib/ribose/widget.rb
185
+ - lib/ribose/wiki.rb
76
186
  - ribose.gemspec
77
- - spec/ribose_spec.rb
187
+ - spec/fixtures/app_data.json
188
+ - spec/fixtures/app_relation.json
189
+ - spec/fixtures/app_relations.json
190
+ - spec/fixtures/calendar.json
191
+ - spec/fixtures/calendars.json
192
+ - spec/fixtures/connection_invitation.json
193
+ - spec/fixtures/connection_invitation_accepted.json
194
+ - spec/fixtures/connection_invitations.json
195
+ - spec/fixtures/connection_invitations_created.json
196
+ - spec/fixtures/connection_suggestion.json
197
+ - spec/fixtures/connections.json
198
+ - spec/fixtures/conversation.json
199
+ - spec/fixtures/conversation_created.json
200
+ - spec/fixtures/conversations.json
201
+ - spec/fixtures/empty.json
202
+ - spec/fixtures/feeds.json
203
+ - spec/fixtures/file_upload_prepared.json
204
+ - spec/fixtures/file_uploaded.json
205
+ - spec/fixtures/general_information.json
206
+ - spec/fixtures/join_space_request_created.json
207
+ - spec/fixtures/join_space_request_updated.json
208
+ - spec/fixtures/join_space_requests.json
209
+ - spec/fixtures/leaderboard.json
210
+ - spec/fixtures/login.html
211
+ - spec/fixtures/members.json
212
+ - spec/fixtures/message.json
213
+ - spec/fixtures/messages.json
214
+ - spec/fixtures/ping.json
215
+ - spec/fixtures/profile.json
216
+ - spec/fixtures/sample.png
217
+ - spec/fixtures/setting.json
218
+ - spec/fixtures/settings.json
219
+ - spec/fixtures/space.json
220
+ - spec/fixtures/space_created.json
221
+ - spec/fixtures/space_file.json
222
+ - spec/fixtures/space_invitation.json
223
+ - spec/fixtures/space_invitation_updated.json
224
+ - spec/fixtures/space_invitations.json
225
+ - spec/fixtures/space_mass_invitations.json
226
+ - spec/fixtures/spaces.json
227
+ - spec/fixtures/stream.json
228
+ - spec/fixtures/user_activated.json
229
+ - spec/fixtures/widgets.json
230
+ - spec/fixtures/wiki.json
231
+ - spec/fixtures/wikis.json
232
+ - spec/ribose/actions/create_spec.rb
233
+ - spec/ribose/actions/delete_spec.rb
234
+ - spec/ribose/actions/fetch_spec.rb
235
+ - spec/ribose/actions/update_spec.rb
236
+ - spec/ribose/app_data_spec.rb
237
+ - spec/ribose/app_relation_spec.rb
238
+ - spec/ribose/calendar_spec.rb
239
+ - spec/ribose/client_spec.rb
240
+ - spec/ribose/config_spec.rb
241
+ - spec/ribose/connection_invitation_spec.rb
242
+ - spec/ribose/connection_spec.rb
243
+ - spec/ribose/conversation_spec.rb
244
+ - spec/ribose/error_spec.rb
245
+ - spec/ribose/feed_spec.rb
246
+ - spec/ribose/file_uploader_spec.rb
247
+ - spec/ribose/join_space_request_spec.rb
248
+ - spec/ribose/leaderboard_spec.rb
249
+ - spec/ribose/member_spec.rb
250
+ - spec/ribose/message_spec.rb
251
+ - spec/ribose/profile_spec.rb
252
+ - spec/ribose/request_spec.rb
253
+ - spec/ribose/resource_helper_spec.rb
254
+ - spec/ribose/session_spec.rb
255
+ - spec/ribose/setting_spec.rb
256
+ - spec/ribose/space_file_spec.rb
257
+ - spec/ribose/space_invitation_spec.rb
258
+ - spec/ribose/space_spec.rb
259
+ - spec/ribose/stream_spec.rb
260
+ - spec/ribose/user_spec.rb
261
+ - spec/ribose/widget_spec.rb
262
+ - spec/ribose/wiki_spec.rb
78
263
  - spec/spec_helper.rb
264
+ - spec/support/fake_ribose_api.rb
265
+ - spec/support/file_upload_stub.rb
79
266
  homepage: https://github.com/riboseinc/ribose-ruby
80
267
  licenses:
81
268
  - MIT
data/spec/ribose_spec.rb DELETED
@@ -1,4 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Ribose do
4
- end