connect_client 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 460029dfcd69d9484e5d837413729c6af0f367a4
4
- data.tar.gz: 6fcdd8d2971ee039a7802149bbef1f01425a8b7d
3
+ metadata.gz: 683a804acba4b229a9419fe6edab311a94bc636b
4
+ data.tar.gz: 22e11a9ec22e2d8ff27d98835fc986e6b1d9698b
5
5
  SHA512:
6
- metadata.gz: 4b125694e79616329f51ef699ba25ef10c872859c23b0f3ddd1faebda1ea5d75480275108b8f25ac1bea473ecac56ddf2a7f661d07315034621b9c10bad7e682
7
- data.tar.gz: 454245a5d86c45a52a0f8024ba84a35e308ce6b3748cc326aaedd799093a85f979753fdd511f32092bad54c98b08004c6dffbe55492f287b78ef22e94c9aed2c
6
+ metadata.gz: 73958e1001bdc8d10e0524d3c7af743542c5e63a321543df94be34b10d9d7e433cdf6afcc99170ddee5920013c1fb525f0344e0573b887cc1bd7b7a0d9a09090
7
+ data.tar.gz: 5ac1394f77793c2ca194afbf532f91f93240e4aa5437427e3495591ffadd0af4df1ee44906b0a1b6e1453a02de11df733d259bad5d945f8b447f233ef2f18af9
data/.gitignore CHANGED
@@ -1,38 +1,38 @@
1
- *.gem
2
- *.rbc
3
- *.sublime*
4
- .idea/*
5
- Gemfile.lock
6
- /.config
7
- /coverage/
8
- /InstalledFiles
9
- /pkg/
10
- /spec/reports/
11
- /test/tmp/
12
- /test/version_tmp/
13
- /tmp/
14
-
15
- ## Specific to RubyMotion:
16
- .dat*
17
- .repl_history
18
- build/
19
-
20
- ## Documentation cache and generated files:
21
- /.yardoc/
22
- /_yardoc/
23
- /doc/
24
- /rdoc/
25
-
26
- ## Environment normalisation:
27
- /.bundle/
28
- /vendor/bundle
29
- /lib/bundler/man/
30
-
31
- # for a library or gem, you might want to ignore these files since the code is
32
- # intended to run in multiple environments; otherwise, check them in:
33
- # Gemfile.lock
34
- # .ruby-version
35
- # .ruby-gemset
36
-
37
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
38
- .rvmrc
1
+ *.gem
2
+ *.rbc
3
+ *.sublime*
4
+ .idea/*
5
+ Gemfile.lock
6
+ /.config
7
+ /coverage/
8
+ /InstalledFiles
9
+ /pkg/
10
+ /spec/reports/
11
+ /test/tmp/
12
+ /test/version_tmp/
13
+ /tmp/
14
+
15
+ ## Specific to RubyMotion:
16
+ .dat*
17
+ .repl_history
18
+ build/
19
+
20
+ ## Documentation cache and generated files:
21
+ /.yardoc/
22
+ /_yardoc/
23
+ /doc/
24
+ /rdoc/
25
+
26
+ ## Environment normalisation:
27
+ /.bundle/
28
+ /vendor/bundle
29
+ /lib/bundler/man/
30
+
31
+ # for a library or gem, you might want to ignore these files since the code is
32
+ # intended to run in multiple environments; otherwise, check them in:
33
+ # Gemfile.lock
34
+ # .ruby-version
35
+ # .ruby-gemset
36
+
37
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
38
+ .rvmrc
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "https://rubygems.org"
2
-
1
+ source "https://rubygems.org"
2
+
3
3
  gemspec
data/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Connect
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Connect
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md CHANGED
@@ -1,45 +1,45 @@
1
- # Connect Ruby SDK
2
-
3
- [![Join the chat at https://gitter.im/getconnect/connect-rb](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/getconnect/connect-rb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
-
5
- ## Getting Access
6
-
7
- Sign up at [https://getconnect.io](https://getconnect.io) to generate and retrieve your API keys so that you can start using the SDK.
8
-
9
- ## Install
10
-
11
- ### Install with Bundler
12
-
13
- ```ssh
14
- gem 'connect_client'
15
- bundle install
16
- ```
17
-
18
- ### Install from RubyGems
19
-
20
- ```ssh
21
- gem install connect_client
22
- ```
23
-
24
- ## Documentation
25
-
26
- All of the documentation can be found at [http://docs.getconnect.io](http://docs.getconnect.io).
27
-
28
- ## Support
29
-
30
- Get your questions answered and join in with the connect community at [http://docs.getconnect.io/v1.0/discuss](http://docs.getconnect.io/v1.0/discuss).
31
-
32
- ## Contributing
33
-
34
- We love open source, so we are happy to accept pull requests and will endeavor to fix the issues and include the enhancements that the community raise.
35
-
36
- ## Building
37
-
38
- To build, and run locally:
39
-
40
- ```ssh
41
- git clone https://github.com/getconnect/connect-rb connect-rb
42
- cd connect-rb
43
- bundle install
44
- rake
45
- ```
1
+ # Connect Ruby SDK
2
+
3
+ [![Join the chat at https://gitter.im/getconnect/connect-rb](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/getconnect/connect-rb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+
5
+ ## Getting Access
6
+
7
+ Sign up at [https://getconnect.io](https://getconnect.io) to generate and retrieve your API keys so that you can start using the SDK.
8
+
9
+ ## Install
10
+
11
+ ### Install with Bundler
12
+
13
+ ```ssh
14
+ gem 'connect_client'
15
+ bundle install
16
+ ```
17
+
18
+ ### Install from RubyGems
19
+
20
+ ```ssh
21
+ gem install connect_client
22
+ ```
23
+
24
+ ## Documentation
25
+
26
+ All of the documentation can be found at [http://docs.getconnect.io](http://docs.getconnect.io).
27
+
28
+ ## Support
29
+
30
+ Get your questions answered and join in with the connect community at [http://docs.getconnect.io/v1.0/discuss](http://docs.getconnect.io/v1.0/discuss).
31
+
32
+ ## Contributing
33
+
34
+ We love open source, so we are happy to accept pull requests and will endeavor to fix the issues and include the enhancements that the community raise.
35
+
36
+ ## Building
37
+
38
+ To build, and run locally:
39
+
40
+ ```ssh
41
+ git clone https://github.com/getconnect/connect-rb connect-rb
42
+ cd connect-rb
43
+ bundle install
44
+ rake
45
+ ```
data/Rakefile CHANGED
@@ -1,22 +1,22 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- namespace :test do
5
- desc 'Run the tests'
6
- Rake::TestTask.new(:spec) do |t|
7
- t.libs = ['lib', 'spec']
8
- t.warning = false
9
- t.verbose = true
10
- t.test_files = FileList['spec/connect_client/http/*_spec.rb', 'spec/connect_client/*_spec.rb', 'spec/*_spec.rb']
11
- end
12
-
13
- desc 'Run the synchrony tests'
14
- Rake::TestTask.new(:synchrony => :spec) do |t|
15
- t.libs = ['lib', 'spec']
16
- t.warning = false
17
- t.verbose = true
18
- t.test_files = FileList['spec/connect_client/http/synchrony/*_spec.rb']
19
- end
20
- end
21
-
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ namespace :test do
5
+ desc 'Run the tests'
6
+ Rake::TestTask.new(:spec) do |t|
7
+ t.libs = ['lib', 'spec']
8
+ t.warning = false
9
+ t.verbose = true
10
+ t.test_files = FileList['spec/connect_client/http/*_spec.rb', 'spec/connect_client/*_spec.rb', 'spec/*_spec.rb']
11
+ end
12
+
13
+ desc 'Run the synchrony tests'
14
+ Rake::TestTask.new(:synchrony => :spec) do |t|
15
+ t.libs = ['lib', 'spec']
16
+ t.warning = false
17
+ t.verbose = true
18
+ t.test_files = FileList['spec/connect_client/http/synchrony/*_spec.rb']
19
+ end
20
+ end
21
+
22
22
  task :default => "test:synchrony"
@@ -1,25 +1,25 @@
1
- require_relative "lib/connect_client/version"
2
-
3
- Gem::Specification.new do |gem|
4
- gem.name = "connect_client"
5
- gem.version = ConnectClient::VERSION
6
- gem.authors = ["Team Connect"]
7
- gem.email = "team@getconnect.io"
8
- gem.homepage = "https://github.com/getconnect/connect-rb"
9
- gem.summary = "Connect SDK"
10
- gem.description = "Ruby Connect SDK for interacting with the Connect API"
11
- gem.license = "MIT"
12
-
13
- gem.add_dependency 'json'
14
-
15
- gem.add_development_dependency 'webmock'
16
- gem.add_development_dependency 'minitest'
17
- gem.add_development_dependency 'eventmachine'
18
- gem.add_development_dependency 'em-http-request'
19
- gem.add_development_dependency 'em-synchrony'
20
-
21
- gem.files = `git ls-files`.split($/)
22
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
23
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
- gem.require_paths = ['lib']
1
+ require_relative "lib/connect_client/version"
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "connect_client"
5
+ gem.version = ConnectClient::VERSION
6
+ gem.authors = ["Team Connect"]
7
+ gem.email = "team@getconnect.io"
8
+ gem.homepage = "https://github.com/getconnect/connect-rb"
9
+ gem.summary = "Connect SDK"
10
+ gem.description = "Ruby Connect SDK for interacting with the Connect API"
11
+ gem.license = "MIT"
12
+
13
+ gem.add_dependency 'json'
14
+
15
+ gem.add_development_dependency 'webmock'
16
+ gem.add_development_dependency 'minitest'
17
+ gem.add_development_dependency 'eventmachine'
18
+ gem.add_development_dependency 'em-http-request'
19
+ gem.add_development_dependency 'em-synchrony'
20
+
21
+ gem.files = `git ls-files`.split($/)
22
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
23
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
+ gem.require_paths = ['lib']
25
25
  end
@@ -1,41 +1,41 @@
1
- require_relative 'connect_client/client'
2
- require_relative 'connect_client/configuration'
3
-
4
- module ConnectClient
5
- class << self
6
-
7
- def configure
8
- config = Configuration.new
9
- yield(config)
10
-
11
- @client = ConnectClient::Client.new config
12
- end
13
-
14
- def reset
15
- @client = nil
16
- end
17
-
18
- def method_missing(method, *args, &block)
19
- return super unless client.respond_to?(method)
20
- client.send(method, *args, &block)
21
- end
22
-
23
- def respond_to?(method)
24
- return (!@client.nil? && @client.respond_to?(method)) || super
25
- end
26
-
27
- private
28
-
29
- def client
30
- raise UnconfiguredError if @client.nil?
31
-
32
- @client
33
- end
34
- end
35
-
36
- class UnconfiguredError < StandardError
37
- def message
38
- "Connect must configured before it can be used, please call Connect.configure"
39
- end
40
- end
1
+ require_relative 'connect_client/client'
2
+ require_relative 'connect_client/configuration'
3
+
4
+ module ConnectClient
5
+ class << self
6
+
7
+ def configure
8
+ config = Configuration.new
9
+ yield(config)
10
+
11
+ @client = ConnectClient::Client.new config
12
+ end
13
+
14
+ def reset
15
+ @client = nil
16
+ end
17
+
18
+ def method_missing(method, *args, &block)
19
+ return super unless client.respond_to?(method)
20
+ client.send(method, *args, &block)
21
+ end
22
+
23
+ def respond_to?(method)
24
+ return (!@client.nil? && @client.respond_to?(method)) || super
25
+ end
26
+
27
+ private
28
+
29
+ def client
30
+ raise UnconfiguredError if @client.nil?
31
+
32
+ @client
33
+ end
34
+ end
35
+
36
+ class UnconfiguredError < StandardError
37
+ def message
38
+ "Connect must configured before it can be used, please call Connect.configure"
39
+ end
40
+ end
41
41
  end
@@ -1,43 +1,43 @@
1
- require_relative 'http/event_endpoint'
2
- require_relative 'event'
3
-
4
- module ConnectClient
5
- class Client
6
-
7
- def initialize(config)
8
- @end_point = ConnectClient::Http::EventEndpoint.new config
9
- end
10
-
11
- def push(collection_name_or_batches, event_or_events = nil)
12
- has_multiple_events = event_or_events.is_a?(Array)
13
- has_collection_name = collection_name_or_batches.is_a?(String)
14
- is_batch = !has_collection_name || has_multiple_events
15
-
16
- if is_batch
17
- batch = create_batch(has_collection_name, collection_name_or_batches, event_or_events)
18
- @end_point.push_batch batch
19
- else
20
- @end_point.push(collection_name_or_batches, ConnectClient::Event.new(event_or_events))
21
- end
22
- end
23
-
24
- private
25
-
26
- def create_batch(has_collection_name, collection_name_or_batches, event_or_events)
27
-
28
- batches = has_collection_name ?
29
- { collection_name_or_batches.to_sym => event_or_events } :
30
- collection_name_or_batches
31
-
32
- create_event = Proc.new do |event_data|
33
- ConnectClient::Event.new event_data
34
- end
35
-
36
- map_all_events = Proc.new do |col_name, events|
37
- [col_name, events.map(&create_event)]
38
- end
39
-
40
- Hash[batches.map(&map_all_events)]
41
- end
42
- end
1
+ require_relative 'http/event_endpoint'
2
+ require_relative 'event'
3
+
4
+ module ConnectClient
5
+ class Client
6
+
7
+ def initialize(config)
8
+ @end_point = ConnectClient::Http::EventEndpoint.new config
9
+ end
10
+
11
+ def push(collection_name_or_batches, event_or_events = nil)
12
+ has_multiple_events = event_or_events.is_a?(Array)
13
+ has_collection_name = collection_name_or_batches.is_a?(String)
14
+ is_batch = !has_collection_name || has_multiple_events
15
+
16
+ if is_batch
17
+ batch = create_batch(has_collection_name, collection_name_or_batches, event_or_events)
18
+ @end_point.push_batch batch
19
+ else
20
+ @end_point.push(collection_name_or_batches, ConnectClient::Event.new(event_or_events))
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def create_batch(has_collection_name, collection_name_or_batches, event_or_events)
27
+
28
+ batches = has_collection_name ?
29
+ { collection_name_or_batches.to_sym => event_or_events } :
30
+ collection_name_or_batches
31
+
32
+ create_event = Proc.new do |event_data|
33
+ ConnectClient::Event.new event_data
34
+ end
35
+
36
+ map_all_events = Proc.new do |col_name, events|
37
+ [col_name, events.map(&create_event)]
38
+ end
39
+
40
+ Hash[batches.map(&map_all_events)]
41
+ end
42
+ end
43
43
  end