apihub 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 19d974c45dfa0c450c3d4810632aa59f71bb23c7
4
+ data.tar.gz: 779c54682a4c689ae61c4db6e44ee0e55f6cbd53
5
+ SHA512:
6
+ metadata.gz: 17dce255412e8054f2a5d1390ceecf7e37a238c4506f4c1e043afa2c05dc4f4ea68901af899d01a6bac719284344f6324ffbe6ed60585702af78982a4f04d956
7
+ data.tar.gz: e26bc6701df3a83fcee6769167c1bebb6c619539928f2951c4ae7f013b687ea10b487e26fd5dcd4de96fa8e1fa92ba602c5638ff41dcc0a6373917e23682f6bb
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in apihub.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alex MacCaw
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # APIHub
2
+
3
+ A Ruby API client to [https://apihub.co](https://apihub.co).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'apihub'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install apihub
18
+
19
+ ## Usage
20
+
21
+ First authorize requests by setting the API key found on your [account's settings page](https://apihub.co/profile).
22
+
23
+ APIHub.api_key = ENV['SOURCING_KEY']
24
+
25
+ Then you can lookup people by email address:
26
+
27
+ person = APIHub::Person[email: 'info@eribium.org']
28
+
29
+ If the person can't be found, then `nil` will be returned.
30
+
31
+ ## CLI
32
+
33
+ The gem also includes a `apihub` executable, which you can use like this:
34
+
35
+ $ apihub --email info@eribium.org
36
+
37
+ {
38
+ "name": {
39
+ "fullName": "Alex MacCaw",
40
+ "givenName": "Alex",
41
+ "familyName": "MacCaw"
42
+ },
43
+ ...
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'apihub/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "apihub"
8
+ spec.version = APIHub::VERSION
9
+ spec.authors = ["Alex MacCaw"]
10
+ spec.email = ["alex@apihub.co"]
11
+ spec.description = %q{API client for apihub.co}
12
+ spec.summary = %q{API client for apihub.co}
13
+ spec.homepage = "https://github.com/maccman/apihub-ruby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_dependency 'nestful', '~> 1.0.7'
24
+ end
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'apihub'
4
+ require 'json'
5
+ require 'optparse'
6
+
7
+ begin
8
+ require 'awesome_print'
9
+ rescue LoadError
10
+ def ap(value)
11
+ puts JSON.pretty_generate(value)
12
+ end
13
+ end
14
+
15
+ options = {}
16
+ values = {}
17
+
18
+ parser = OptionParser.new do |opts|
19
+ opts.banner = "Usage: apihub [options]"
20
+
21
+ opts.on("--twitter HANDLE", String, "Twitter handle") do |v|
22
+ values[:twitter] = v
23
+ end
24
+
25
+ opts.on("--github HANDLE", String, "GitHub handle") do |v|
26
+ values[:github] = v
27
+ end
28
+
29
+ opts.on("--email EMAIL", String, "Email") do |v|
30
+ values[:email] = v
31
+ end
32
+
33
+ opts.on("--api-key KEY", String, "APIHub") do |v|
34
+ options[:api_key] = v
35
+ end
36
+ end
37
+
38
+ parser.parse!
39
+
40
+ if key = ENV['APIHUB_KEY']
41
+ options[:api_key] ||= key
42
+ end
43
+
44
+ if values == {}
45
+ puts parser
46
+ exit
47
+ end
48
+
49
+ APIHub.api_key = options[:api_key]
50
+
51
+ person = APIHub::Person.find(values, options)
52
+
53
+ if person && person.pending?
54
+ puts 'Person lookup queued'
55
+ elsif person
56
+ ap person.to_hash
57
+ else
58
+ puts 'Person not found'
59
+ end
@@ -0,0 +1,6 @@
1
+ require 'apihub'
2
+ require 'pp'
3
+
4
+ APIHub.api_key = ENV['SOURCING_KEY']
5
+
6
+ pp APIHub::Person[email: 'info@eribium.org']
@@ -0,0 +1,22 @@
1
+ require 'nestful'
2
+ require 'apihub/version'
3
+
4
+ module APIHub
5
+ def self.api_key=(value)
6
+ Base.options Base.options.merge(
7
+ :auth_type => :bearer,
8
+ :password => value
9
+ )
10
+ end
11
+
12
+ def self.key=(value)
13
+ self.api_key = value
14
+ end
15
+
16
+ class Base < Nestful::Resource
17
+ endpoint 'https://api.apihub.co'
18
+ options :format => :json
19
+ end
20
+
21
+ autoload :Person, 'apihub/person'
22
+ end
@@ -0,0 +1,43 @@
1
+ module APIHub
2
+ class Person < Base
3
+ endpoint 'https://profile.apihub.co'
4
+ path '/v1/people'
5
+
6
+ def self.find(values, options = {})
7
+ unless values.is_a?(Hash)
8
+ values = {:id => values}
9
+ end
10
+
11
+ options = options.dup
12
+ params = options.delete(:params) || {}
13
+
14
+ if email = values[:email]
15
+ response = get(uri(:email, email), params, options)
16
+
17
+ elsif twitter = values[:twitter]
18
+ response = get(uri(:twitter, twitter), params, options)
19
+
20
+ elsif github = values[:github]
21
+ response = get(uri(:github, github), params, options)
22
+
23
+ elsif id = values[:id]
24
+ response = get(id, params, options)
25
+
26
+ else
27
+ raise ArgumentError, 'Invalid values'
28
+ end
29
+
30
+ if response.status == 202
31
+ self.new(pending: true)
32
+ else
33
+ self.new(response)
34
+ end
35
+
36
+ rescue Nestful::ResourceNotFound
37
+ end
38
+
39
+ class << self
40
+ alias_method :[], :find
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module APIHub
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apihub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex MacCaw
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: nestful
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.7
55
+ description: API client for apihub.co
56
+ email:
57
+ - alex@apihub.co
58
+ executables:
59
+ - apihub
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - apihub.gemspec
69
+ - bin/apihub
70
+ - examples/email.rb
71
+ - lib/apihub.rb
72
+ - lib/apihub/person.rb
73
+ - lib/apihub/version.rb
74
+ homepage: https://github.com/maccman/apihub-ruby
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.2.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: API client for apihub.co
98
+ test_files: []