cenit_client 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57c53955a4e4c32717d027500a1e71eb579bd4f3
4
+ data.tar.gz: 0209265cdeea5110b74c3729f58c73931cf2a3de
5
+ SHA512:
6
+ metadata.gz: a3aed32d3d8935d82ccb2afd8e1ca3cc46ce5d8d875d5e3b2fbed8aaef4ff05305b727b4e3f8ba783e6a28f631eb988ae5c3cab87cc4172c18dfdedc21612d76
7
+ data.tar.gz: 912921cbd0f73b269cd4c3bb6539caa21eb37ed20c32f83f8388344ad795d50fa09f463a4ba6a89d058c4e79a644c34cad51880170003477c1c7573babc5c53f
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /.idea/
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ **.orig
12
+ *.swp
13
+ *.swo
14
+ **~
15
+
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'webmock'
4
+ gem 'rspec', :require => 'spec'
5
+
6
+ # Specify your gem's dependencies in cenit_client.gemspec
7
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Cenit, LLC
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # Cenithub::Client
2
+
3
+ Ruby API client for objects to [Cenithub](http://www.cenithub.com)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cenithub-ruby', github: 'asnioby/cenithub-client', require: 'cenithub'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ Add your Cenithub credentials to `config/initializers/cenithub.rb`:
18
+
19
+ ```ruby
20
+ Cenithub.configure do |config|
21
+ config.connection_token = "YOUR TOKEN"
22
+ config.connection_id = "YOUR CONNECTION ID"
23
+ end
24
+ ```
25
+
26
+ You can now send json payload objects to Cenithub by calling:
27
+
28
+ ```ruby
29
+ Cenithub::Client.push(json_payload)
30
+ ```
31
+
32
+ ## Use console
33
+
34
+ You can also use the console to debug or test pushing objects.
35
+
36
+ Start the console like this from your application where you are using Cenithub-ruby.
37
+
38
+ ```shell
39
+ bundle exec cenithub-console
40
+ ```
41
+
42
+ In the console you will have to setup your credentials, then you can push json objects like this:
43
+
44
+ ```ruby
45
+ Cenithub.configure do |config|
46
+ config.connection_token = "YOUR TOKEN"
47
+ config.connection_id = "YOUR ID"
48
+ end
49
+
50
+ pirate_payload = %{{"pirates": [{"id": "1", "name": "Blackbeard"}]}}
51
+
52
+ Cenithub::Client.push(pirate_payload)
53
+ ```
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it ( http://github.com/<my-github-username>/Cenithub-client/fork )
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
62
+
63
+
64
+ ![Cenithub Logo](http://www.cenitsaas.com)
65
+
66
+ This gem is 100% open source an licensed under the terms of the New BSD License.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pathname'
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
5
+ Pathname.new(__FILE__).realpath)
6
+
7
+ require 'rubygems'
8
+ require 'bundler/setup'
9
+
10
+ load Gem.bin_path('cenit_client', 'console')
data/bin/setup ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pathname'
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
5
+ Pathname.new(__FILE__).realpath)
6
+
7
+ require 'rubygems'
8
+ require 'bundler/setup'
9
+
10
+ load Gem.bin_path('cenit_client', 'setup')
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cenit_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.platform = Gem::Platform::RUBY
8
+ spec.name = "cenit_client"
9
+ spec.version = CenitClient::VERSION
10
+ spec.authors = ['Asnioby Hernandez','Miguel Sancho']
11
+ spec.email = ['asnioby@gmail.com','sanchojaf@gmail.com']
12
+ spec.summary = %q{ Ruby client for pushing data to Cenit }
13
+ spec.description = %q{ Ruby client for pushing data to Cenit }
14
+ spec.homepage = "https://github.com/openjaf/cenit_client"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'bin'
19
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+
25
+ spec.add_dependency 'active_model_serializers'
26
+ spec.add_dependency 'httparty'
27
+ end
@@ -0,0 +1,20 @@
1
+ require 'cenit_client/client'
2
+
3
+ module CenitClient
4
+ class << self
5
+ attr_accessor :configuration
6
+ end
7
+
8
+ def self.configure
9
+ self.configuration ||= Configuration.new
10
+ yield(configuration)
11
+ end
12
+
13
+ class Configuration
14
+ attr_accessor :connection_id, :connection_token, :push_url
15
+
16
+ def initialize
17
+ @push_url = 'https://www.cenithub.com/api/v1/push'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,93 @@
1
+ require "cenit_client/version"
2
+ require 'openssl'
3
+ require 'httparty'
4
+ require 'active_model/array_serializer'
5
+
6
+ module CenitClient
7
+ module Client
8
+ def self.push(json_payload, options=self.configuration)
9
+
10
+ res = HTTParty.post(
11
+ options[:push_url],
12
+ {
13
+ body: json_payload,
14
+ headers: {
15
+ 'Content-Type' => 'application/json',
16
+ 'X-Hub-Store' => options[:connection_id],
17
+ 'X-Hub-Access-Token' => options[:connection_token],
18
+ 'X-Hub-Timestamp' => Time.now.utc.to_i.to_s
19
+ }
20
+ }
21
+ )
22
+ validate(res)
23
+ res
24
+ end
25
+
26
+ def self.destroy(resource,id, options=self.configuration)
27
+
28
+ res = HTTParty.delete(
29
+ options[:push_url] + "/#{resource}/#{id}",
30
+ {
31
+ headers: {
32
+ 'Content-Type' => 'application/json',
33
+ 'X-Hub-Store' => options[:connection_id],
34
+ 'X-Hub-Access-Token' => options[:connection_token],
35
+ 'X-Hub-Timestamp' => Time.now.utc.to_i.to_s
36
+ }
37
+ }
38
+ )
39
+ validate(res)
40
+ res
41
+ end
42
+
43
+ def self.show(resource,id, options=self.configuration)
44
+
45
+ res = HTTParty.get(
46
+ options[:push_url] + "/#{resource}/#{id}",
47
+ {
48
+ headers: {
49
+ 'Content-Type' => 'application/json',
50
+ 'X-Hub-Store' => options[:connection_id],
51
+ 'X-Hub-Access-Token' => options[:connection_token],
52
+ 'X-Hub-Timestamp' => Time.now.utc.to_i.to_s
53
+ }
54
+ }
55
+ )
56
+ validate(res)
57
+ res.body
58
+ end
59
+
60
+ def self.index(resource, options=self.configuration)
61
+
62
+ res = HTTParty.get(
63
+ options[:push_url] + "/#{resource}",
64
+ {
65
+ headers: {
66
+ 'Content-Type' => 'application/json',
67
+ 'X-Hub-Store' => options[:connection_id],
68
+ 'X-Hub-Access-Token' => options[:connection_token],
69
+ 'X-Hub-Timestamp' => Time.now.utc.to_i.to_s
70
+ }
71
+ }
72
+ )
73
+ validate(res)
74
+ res.body
75
+ end
76
+
77
+ private
78
+
79
+ def self.configuration
80
+ {
81
+ push_url: Cenithub.configuration.push_url,
82
+ connection_id: Cenithub.configuration.connection_id,
83
+ connection_token: Cenithub.configuration.connection_token
84
+ }
85
+ end
86
+
87
+ def self.validate(res)
88
+ raise PushApiError, "Push not successful. CENIT returned response code #{res.code} and message: #{res.body}" if res.code != 200
89
+ end
90
+
91
+ class PushApiError < StandardError; end
92
+ end
93
+ end
@@ -0,0 +1,3 @@
1
+ module CenitClient
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cenit_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Asnioby Hernandez
8
+ - Miguel Sancho
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-05-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.9'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.9'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: active_model_serializers
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: httparty
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description: " Ruby client for pushing data to Cenit "
71
+ email:
72
+ - asnioby@gmail.com
73
+ - sanchojaf@gmail.com
74
+ executables:
75
+ - console
76
+ - setup
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - ".gitignore"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - cenit_client.gemspec
88
+ - lib/cenit_client.rb
89
+ - lib/cenit_client/client.rb
90
+ - lib/cenit_client/version.rb
91
+ homepage: https://github.com/openjaf/cenit_client
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Ruby client for pushing data to Cenit
115
+ test_files: []