syncano 3.1.1.beta

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 (57) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/Gemfile +4 -0
  4. data/Guardfile +5 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +304 -0
  7. data/Rakefile +7 -0
  8. data/lib/generators/syncano/install_generator.rb +17 -0
  9. data/lib/generators/syncano/templates/initializers/syncano.rb +4 -0
  10. data/lib/syncano.rb +92 -0
  11. data/lib/syncano/batch_queue.rb +58 -0
  12. data/lib/syncano/batch_queue_element.rb +33 -0
  13. data/lib/syncano/clients/base.rb +115 -0
  14. data/lib/syncano/clients/rest.rb +69 -0
  15. data/lib/syncano/clients/sync.rb +132 -0
  16. data/lib/syncano/errors.rb +13 -0
  17. data/lib/syncano/jimson_client.rb +34 -0
  18. data/lib/syncano/packets/auth.rb +7 -0
  19. data/lib/syncano/packets/base.rb +64 -0
  20. data/lib/syncano/packets/call.rb +34 -0
  21. data/lib/syncano/packets/call_response.rb +33 -0
  22. data/lib/syncano/packets/error.rb +19 -0
  23. data/lib/syncano/packets/message.rb +30 -0
  24. data/lib/syncano/packets/notification.rb +39 -0
  25. data/lib/syncano/packets/ping.rb +12 -0
  26. data/lib/syncano/query_builder.rb +144 -0
  27. data/lib/syncano/resources/admin.rb +26 -0
  28. data/lib/syncano/resources/api_key.rb +46 -0
  29. data/lib/syncano/resources/base.rb +375 -0
  30. data/lib/syncano/resources/collection.rb +186 -0
  31. data/lib/syncano/resources/data_object.rb +304 -0
  32. data/lib/syncano/resources/folder.rb +34 -0
  33. data/lib/syncano/resources/notifications/base.rb +103 -0
  34. data/lib/syncano/resources/notifications/create.rb +20 -0
  35. data/lib/syncano/resources/notifications/destroy.rb +20 -0
  36. data/lib/syncano/resources/notifications/message.rb +9 -0
  37. data/lib/syncano/resources/notifications/update.rb +24 -0
  38. data/lib/syncano/resources/project.rb +42 -0
  39. data/lib/syncano/resources/role.rb +11 -0
  40. data/lib/syncano/resources/subscription.rb +12 -0
  41. data/lib/syncano/resources/user.rb +47 -0
  42. data/lib/syncano/response.rb +22 -0
  43. data/lib/syncano/sync_connection.rb +110 -0
  44. data/lib/syncano/version.rb +4 -0
  45. data/spec/admins_spec.rb +16 -0
  46. data/spec/api_keys_spec.rb +34 -0
  47. data/spec/collections_spec.rb +67 -0
  48. data/spec/data_objects_spec.rb +113 -0
  49. data/spec/folders_spec.rb +39 -0
  50. data/spec/notifications_spec.rb +43 -0
  51. data/spec/projects_spec.rb +35 -0
  52. data/spec/roles_spec.rb +13 -0
  53. data/spec/spec_helper.rb +13 -0
  54. data/spec/sync_resources_spec.rb +35 -0
  55. data/spec/syncano_spec.rb +9 -0
  56. data/syncano.gemspec +32 -0
  57. metadata +250 -0
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Syncano::Resource::Folder' do
4
+ before(:all) do
5
+ @project = @client.projects.last || @client.projects.create(name: 'Test project')
6
+ @collection = @project.collections.last || @project.collections.create(name: 'Test collection')
7
+ end
8
+
9
+ it 'should create new folder in Syncano' do
10
+ folder_name = "Test folder ##{Time.now.to_i}"
11
+ count_before = @collection.folders.count
12
+ folder = @collection.folders.create(name: folder_name)
13
+ count_after = @collection.folders.count
14
+
15
+ (count_after - count_before).should == 1
16
+ @collection.folders.last[:name].should == folder_name
17
+ end
18
+
19
+ it 'should get folders' do
20
+ @collection.folders.all.each do |folder|
21
+ folder.id.should_not be_nil
22
+ folder[:name].should_not be_nil
23
+ end
24
+ end
25
+
26
+ it 'should get one folder' do
27
+ folder = @collection.folders.last
28
+ @collection.folders.find(folder[:name])[:name].should == folder[:name]
29
+ @collection.folders.find_by_name(folder[:name])[:name].should == folder[:name]
30
+ end
31
+
32
+ it 'should destroy folder' do
33
+ count_before = @collection.folders.count
34
+ @collection.folders.last.destroy
35
+ count_after = @collection.folders.count
36
+
37
+ (count_before - count_after).should == 1
38
+ end
39
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Handling notifications' do
4
+ before(:all) do
5
+ @project = @sync_client.projects.last || @sync_client.projects.create(name: 'Test project')
6
+ @collection = @project.collections.last || @project.collections.create(name: 'Test collection')
7
+ @object = @collection.data_objects.last || @collection.data_objects.create(title: 'Test object')
8
+ @object.update(title: 'Test object')
9
+ sleep 3
10
+
11
+ @sync_client.append_callback(:test) do |notification|
12
+ p "Notification received: #{notification.inspect}"
13
+ end
14
+ end
15
+
16
+ it 'should subscribe to project' do
17
+ @project.subscribe
18
+ p 'Notification should be seen'
19
+ @object.update(title: 'Test object 2')
20
+ sleep 3
21
+ end
22
+
23
+ it 'should unsubscribe from project' do
24
+ @project.unsubscribe
25
+ p 'Notification should not be seen'
26
+ @object.update(title: 'Test object 3')
27
+ sleep 3
28
+ end
29
+
30
+ it 'should subscribe to collection' do
31
+ @collection.subscribe
32
+ p 'Notification should be seen'
33
+ @object.update(title: 'Test object 4')
34
+ sleep 3
35
+ end
36
+
37
+ it 'should unsubscribe from collection' do
38
+ @collection.unsubscribe
39
+ p 'Notification should not be seen'
40
+ @object.update(title: 'Test object 5')
41
+ sleep 3
42
+ end
43
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Syncano::Resource::Project' do
4
+ it 'should create new project in Syncano' do
5
+ count_before = @client.projects.count
6
+ @client.projects.create(name: 'Test project', description: 'Just testing')
7
+ count_after = @client.projects.count
8
+
9
+ (count_after - count_before).should == 1
10
+ @client.projects.last[:name].should == 'Test project'
11
+ end
12
+
13
+ it 'should get projects' do
14
+ projects = @client.projects.all
15
+ projects.each do |project|
16
+ project.id.should_not be_nil
17
+ project[:name].should_not be_nil
18
+ end
19
+ end
20
+
21
+ it 'should get one project' do
22
+ projects = @client.projects.all
23
+
24
+ project = @client.projects.find(projects.last.id)
25
+ project[:name].should == projects.last[:name]
26
+ end
27
+
28
+ it 'should destroy project' do
29
+ count_before = @client.projects.count
30
+ @client.projects.last.destroy
31
+ count_after = @client.projects.count
32
+
33
+ (count_before - count_after).should == 1
34
+ end
35
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Syncano::Resource::Role' do
4
+ it 'should get roles' do
5
+ roles = @client.roles.all
6
+ roles.count.should_not == 0
7
+
8
+ roles.each do |role|
9
+ role.id.should_not be_nil
10
+ role[:name].should_not be_nil
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'syncano'
2
+ require 'mocha/api'
3
+
4
+ RSpec.configure do |config|
5
+ config.mock_framework = :mocha
6
+ config.before(:all) do
7
+ @syncano_api_key = ENV['SYNCANO_API_KEY'] || raise('Set SYNCANO_API_KEY environment variable!')
8
+ @syncano_instance_name = ENV['SYNCANO_INSTANCE_NAME'] || raise('Set SYNCANO_INSTANCE_NAME environment variable!')
9
+
10
+ @client = ::Syncano.client(instance_name: @syncano_instance_name, api_key: @syncano_api_key)
11
+ @sync_client = ::Syncano.sync_client(instance_name: @syncano_instance_name, api_key: @syncano_api_key)
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Using resources through sync api' do
4
+ it 'should create new project in Syncano' do
5
+ count_before = @sync_client.projects.count
6
+ @sync_client.projects.create(name: 'Test project', description: 'Just testing')
7
+ count_after = @sync_client.projects.count
8
+
9
+ (count_after - count_before).should == 1
10
+ @sync_client.projects.last[:name].should == 'Test project'
11
+ end
12
+
13
+ it 'should get projects' do
14
+ projects = @sync_client.projects.all
15
+ projects.each do |project|
16
+ project.id.should_not be_nil
17
+ project[:name].should_not be_nil
18
+ end
19
+ end
20
+
21
+ it 'should get one project' do
22
+ projects = @sync_client.projects.all
23
+
24
+ project = @sync_client.projects.find(projects.last.id)
25
+ project[:name].should == projects.last[:name]
26
+ end
27
+
28
+ it 'should destroy project' do
29
+ count_before = @sync_client.projects.count
30
+ @sync_client.projects.last.destroy
31
+ count_after = @sync_client.projects.count
32
+
33
+ (count_before - count_after).should == 1
34
+ end
35
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Syncano do
4
+ it 'should allow to init a client' do
5
+ expect(@client).to be_a(Syncano::Clients::Rest)
6
+ @client.instance_name.should == @syncano_instance_name
7
+ @client.api_key.should == @syncano_api_key
8
+ end
9
+ end
data/syncano.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'syncano/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'syncano'
8
+ spec.version = Syncano::VERSION
9
+ spec.authors = ['Piotr Zadrożny']
10
+ spec.email = ['piotr.zadrozny@mindpower.pl']
11
+ spec.summary = 'A Ruby client library for Syncano'
12
+ spec.description = 'A Ruby client that provides convenient interface for the Syncano api.'
13
+ spec.homepage = 'https://github.com/Syncano/syncano-ruby'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'jimson-client'
22
+ spec.add_dependency 'activesupport'
23
+ spec.add_dependency 'multi_json', '~> 1.10'
24
+ spec.add_dependency 'eventmachine'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.6'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'yard'
29
+ spec.add_development_dependency 'rspec'
30
+ spec.add_development_dependency 'mocha'
31
+ spec.add_development_dependency 'guard-rspec'
32
+ end
metadata ADDED
@@ -0,0 +1,250 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: syncano
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.1.1.beta
5
+ platform: ruby
6
+ authors:
7
+ - Piotr Zadrożny
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jimson-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: eventmachine
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: mocha
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: A Ruby client that provides convenient interface for the Syncano api.
154
+ email:
155
+ - piotr.zadrozny@mindpower.pl
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - Gemfile
162
+ - Guardfile
163
+ - LICENSE.txt
164
+ - README.md
165
+ - Rakefile
166
+ - lib/generators/syncano/install_generator.rb
167
+ - lib/generators/syncano/templates/initializers/syncano.rb
168
+ - lib/syncano.rb
169
+ - lib/syncano/batch_queue.rb
170
+ - lib/syncano/batch_queue_element.rb
171
+ - lib/syncano/clients/base.rb
172
+ - lib/syncano/clients/rest.rb
173
+ - lib/syncano/clients/sync.rb
174
+ - lib/syncano/errors.rb
175
+ - lib/syncano/jimson_client.rb
176
+ - lib/syncano/packets/auth.rb
177
+ - lib/syncano/packets/base.rb
178
+ - lib/syncano/packets/call.rb
179
+ - lib/syncano/packets/call_response.rb
180
+ - lib/syncano/packets/error.rb
181
+ - lib/syncano/packets/message.rb
182
+ - lib/syncano/packets/notification.rb
183
+ - lib/syncano/packets/ping.rb
184
+ - lib/syncano/query_builder.rb
185
+ - lib/syncano/resources/admin.rb
186
+ - lib/syncano/resources/api_key.rb
187
+ - lib/syncano/resources/base.rb
188
+ - lib/syncano/resources/collection.rb
189
+ - lib/syncano/resources/data_object.rb
190
+ - lib/syncano/resources/folder.rb
191
+ - lib/syncano/resources/notifications/base.rb
192
+ - lib/syncano/resources/notifications/create.rb
193
+ - lib/syncano/resources/notifications/destroy.rb
194
+ - lib/syncano/resources/notifications/message.rb
195
+ - lib/syncano/resources/notifications/update.rb
196
+ - lib/syncano/resources/project.rb
197
+ - lib/syncano/resources/role.rb
198
+ - lib/syncano/resources/subscription.rb
199
+ - lib/syncano/resources/user.rb
200
+ - lib/syncano/response.rb
201
+ - lib/syncano/sync_connection.rb
202
+ - lib/syncano/version.rb
203
+ - spec/admins_spec.rb
204
+ - spec/api_keys_spec.rb
205
+ - spec/collections_spec.rb
206
+ - spec/data_objects_spec.rb
207
+ - spec/folders_spec.rb
208
+ - spec/notifications_spec.rb
209
+ - spec/projects_spec.rb
210
+ - spec/roles_spec.rb
211
+ - spec/spec_helper.rb
212
+ - spec/sync_resources_spec.rb
213
+ - spec/syncano_spec.rb
214
+ - syncano.gemspec
215
+ homepage: https://github.com/Syncano/syncano-ruby
216
+ licenses:
217
+ - MIT
218
+ metadata: {}
219
+ post_install_message:
220
+ rdoc_options: []
221
+ require_paths:
222
+ - lib
223
+ required_ruby_version: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - ">="
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ">"
231
+ - !ruby/object:Gem::Version
232
+ version: 1.3.1
233
+ requirements: []
234
+ rubyforge_project:
235
+ rubygems_version: 2.2.2
236
+ signing_key:
237
+ specification_version: 4
238
+ summary: A Ruby client library for Syncano
239
+ test_files:
240
+ - spec/admins_spec.rb
241
+ - spec/api_keys_spec.rb
242
+ - spec/collections_spec.rb
243
+ - spec/data_objects_spec.rb
244
+ - spec/folders_spec.rb
245
+ - spec/notifications_spec.rb
246
+ - spec/projects_spec.rb
247
+ - spec/roles_spec.rb
248
+ - spec/spec_helper.rb
249
+ - spec/sync_resources_spec.rb
250
+ - spec/syncano_spec.rb