global_registry 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +10 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/global_registry.gemspec +25 -0
- data/lib/global_registry.rb +22 -0
- data/lib/global_registry/base.rb +79 -0
- data/lib/global_registry/entity.rb +5 -0
- data/lib/global_registry/entity_type.rb +6 -0
- data/lib/global_registry/enum_value.rb +6 -0
- data/lib/global_registry/relationship.rb +6 -0
- data/lib/global_registry/relationship_type.rb +6 -0
- data/lib/global_registry/version.rb +4 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0f47b04456911696d365c5e378a26d337b8a4be3
|
4
|
+
data.tar.gz: 29310a6692cce74a08212a73c3c9e10ed64475be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8e6148787abd29eab9c52ed4e30905adb4a763699118813a099ec460a47350d7eb18e467738ca20017c7de9e2c50b3b00adb0d6cb15ac1a5012fe2ffb051440
|
7
|
+
data.tar.gz: 563af1057ac365b8deafb0c382bf646a038deba8eec5953dae8f87a9600aaee40c439fea50c85c70f96d25e8a747e40d9cf68b52bc7957621ffb66b86fd95a68
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 CruGlobal
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
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, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'global_registry/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "global_registry"
|
8
|
+
gem.version = GlobalRegistry::VERSION
|
9
|
+
gem.authors = ["Josh Starcher"]
|
10
|
+
gem.email = ["josh.starcher@gmail.com"]
|
11
|
+
gem.description = %q{This gem wraps an API for the Global Registry.}
|
12
|
+
gem.summary = %q{Push and pull data from the Global Registry}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency('rest-client', '~> 1.6.7')
|
21
|
+
gem.add_dependency('oj', '~> 2.1.0')
|
22
|
+
gem.add_dependency('activesupport')
|
23
|
+
gem.add_dependency('retryable-rb', '~> 1.1.0')
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
require 'global_registry/base'
|
3
|
+
|
4
|
+
Dir[File.dirname(__FILE__) + '/global_registry/*.rb'].each do |file|
|
5
|
+
require file
|
6
|
+
end
|
7
|
+
|
8
|
+
module GlobalRegistry
|
9
|
+
class << self
|
10
|
+
attr_accessor :base_url, :access_token
|
11
|
+
|
12
|
+
def configure
|
13
|
+
yield self
|
14
|
+
end
|
15
|
+
|
16
|
+
def base_url
|
17
|
+
@base_url ||= "https://api.leadingwithinformation.com/"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'oj'
|
3
|
+
require 'retryable'
|
4
|
+
|
5
|
+
module GlobalRegistry
|
6
|
+
class Base
|
7
|
+
|
8
|
+
def self.find(id)
|
9
|
+
request(:get, {}, path_with_id(id))
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.get(params = {})
|
13
|
+
request(:get, params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.post(params = {})
|
17
|
+
request(:post, params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.put(id, params = {})
|
21
|
+
request(:put, params, path_with_id(id))
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.delete(id)
|
25
|
+
request(:put, {}, path_with_id(id))
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def self.request(method, params, path = nil)
|
30
|
+
raise 'You need to configure GlobalRegistry with your access_token.' unless GlobalRegistry.access_token
|
31
|
+
|
32
|
+
path ||= default_path
|
33
|
+
url = GlobalRegistry.base_url
|
34
|
+
url += '/' unless url.last == '/'
|
35
|
+
url += path
|
36
|
+
|
37
|
+
case method
|
38
|
+
when :post
|
39
|
+
RestClient.post(url, params, authorization: "Bearer #{GlobalRegistry.access_token}", :timeout => -1) { |response, request, result, &block|
|
40
|
+
handle_response(response, request, result)
|
41
|
+
}
|
42
|
+
when :put
|
43
|
+
RestClient.put(url, params, authorization: "Bearer #{GlobalRegistry.access_token}", :timeout => -1) { |response, request, result, &block|
|
44
|
+
handle_response(response, request, result)
|
45
|
+
}
|
46
|
+
else
|
47
|
+
RestClient::Request.execute(:method => method, :url => url, :headers => {params: params, authorization: "Bearer #{GlobalRegistry.access_token}"}, :timeout => -1) { |response, request, result, &block|
|
48
|
+
handle_response(response, request, result)
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.handle_response(response, request, result)
|
54
|
+
case response.code
|
55
|
+
when 200..299
|
56
|
+
Oj.load(response)
|
57
|
+
when 400
|
58
|
+
raise RestClient::BadRequest, response.to_s
|
59
|
+
when 500
|
60
|
+
raise RestClient::InternalServerError, response.to_s
|
61
|
+
else
|
62
|
+
puts response.inspect
|
63
|
+
puts request.inspect
|
64
|
+
raise result.inspect
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.default_path
|
69
|
+
to_s.split('::').last.underscore.pluralize
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.path_with_id(id)
|
73
|
+
"#{default_path}/#{id}"
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: global_registry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Starcher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: oj
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: retryable-rb
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.1.0
|
69
|
+
description: This gem wraps an API for the Global Registry.
|
70
|
+
email:
|
71
|
+
- josh.starcher@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- global_registry.gemspec
|
82
|
+
- lib/global_registry.rb
|
83
|
+
- lib/global_registry/base.rb
|
84
|
+
- lib/global_registry/entity.rb
|
85
|
+
- lib/global_registry/entity_type.rb
|
86
|
+
- lib/global_registry/enum_value.rb
|
87
|
+
- lib/global_registry/relationship.rb
|
88
|
+
- lib/global_registry/relationship_type.rb
|
89
|
+
- lib/global_registry/version.rb
|
90
|
+
homepage: ''
|
91
|
+
licenses: []
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.0.6
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Push and pull data from the Global Registry
|
113
|
+
test_files: []
|