clarification 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8daa3c9b734cebcb402ecf17267c816986b9fb63
4
+ data.tar.gz: 5a97cf519409b9d2d93369a959b806935dc35604
5
+ SHA512:
6
+ metadata.gz: 68e625faabe30c5d21402b4d042bcda745db52ea47655663c3d7feb1f5629eef979b4166c961f031e17e461eb37234190679730db868fb284b24ee64c0f05517
7
+ data.tar.gz: a4a44a02633d75efbfe5bd3f4bbffb4cb4e87a4278db92715dd3251ae540166f812ce23a9cb7b4dcef11a77067c6d95ace9bec7870192dad1ee74be89da65362
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in clarification.gemspec
6
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard :rspec, cmd: 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 TODO: Write your name
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,67 @@
1
+ # Clarification - DO NOT INSTALL - IN DEVELOPMENT
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/clarification`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'clarification'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install clarification
20
+
21
+ ## Configuration
22
+
23
+ Configure the gem as you would normally.
24
+
25
+ ```
26
+ Clarification.configure do |config|
27
+ config.api_key = 'a_big_secret_you_got_from_clarifai'
28
+ config.end_points = [:food]
29
+ end
30
+ ```
31
+
32
+ This should also work nicely inside a rails initializer.
33
+
34
+ ## Usage
35
+
36
+ You
37
+
38
+ client = Clarification::Client.new(:faces, :food)
39
+ response = client.analyze(some_public_url)
40
+
41
+ Each endpoint initialized will be called. So this analyze action will call two separate API routes and will count as two uses of your key.
42
+
43
+ ```
44
+ response[:faces].face_count
45
+ # => 3
46
+ response[:food].concepts.first
47
+ # => { concept_name: "cake",
48
+ confidence: .89 }
49
+ ```
50
+
51
+ ## Development
52
+
53
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
54
+
55
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/clarification. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
64
+
65
+ ## Code of Conduct
66
+
67
+ Everyone interacting in the Clarification project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/clarification/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "clarification"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
12
+
13
+ # require "irb"
14
+ # IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "clarification/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "clarification"
8
+ spec.version = Clarification::VERSION
9
+ spec.authors = ["Nichol Alexander"]
10
+ spec.email = ["nichol.alexander@gmail.com"]
11
+
12
+ spec.summary = %q{An unofficial API wrapper for the Clarifai Image and Video Recognition API.}
13
+ spec.description = %q{Alpha Version - configure, access Clarifai set end points, interrogate responses.}
14
+ spec.homepage = "https://github.com/nicholalexander/clarification"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.15"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "pry"
28
+ spec.add_development_dependency "guard"
29
+ spec.add_development_dependency "guard-rspec"
30
+
31
+ end
@@ -0,0 +1,20 @@
1
+ require "clarification/client"
2
+ require "clarification/configuration"
3
+ require "clarification/end_points"
4
+ require "clarification/requester"
5
+ require "clarification/version"
6
+
7
+ require 'net/http'
8
+ require 'uri'
9
+ require 'json'
10
+
11
+ module Clarification
12
+ class << self
13
+ attr_accessor :configuration
14
+
15
+ def configure
16
+ self.configuration ||= Configuration.new
17
+ yield(self.configuration)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,45 @@
1
+ module Clarification
2
+ class Client
3
+
4
+ def initialize
5
+
6
+ end
7
+
8
+ def request(url)
9
+
10
+ r = Requester.new(:food)
11
+ response = r.get(url)
12
+
13
+ end
14
+
15
+
16
+ def make_request
17
+ uri = URI.parse("https://api.clarifai.com/v2/models/bd367be194cf45149e75f01d59f77ba7/outputs")
18
+ request = Net::HTTP::Post.new(uri)
19
+ request.content_type = "application/json"
20
+ request["Authorization"] = "Key f7cc628178994e16b2470ae739ef927a"
21
+ request.body = JSON.dump({
22
+ "inputs" => [
23
+ {
24
+ "data" => {
25
+ "image" => {
26
+ "url" => "https://samples.clarifai.com/food.jpg"
27
+ }
28
+ }
29
+ }
30
+ ]
31
+ })
32
+
33
+ req_options = {
34
+ use_ssl: uri.scheme == "https",
35
+ }
36
+
37
+ response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
38
+ http.request(request)
39
+ end
40
+
41
+ puts response
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ module Clarification
2
+ class Configuration
3
+ attr_accessor :api_key
4
+
5
+ def initialize
6
+ @api_key = 'YOUR_API_KEY'
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Clarification
2
+ BASE_URL = 'https://api.clarifai.com/v2/models/'.freeze
3
+ APPAREL = 'e0be3b9d6a454f0493ac3a30784001ff'.freeze
4
+ CELEBRITY = 'e466caa0619f444ab97497640cefc4dc'.freeze
5
+ COLOR = 'eeed0b6733a644cea07cf4c60f87ebb7'.freeze
6
+ DEMOGRAPHICS = 'c0c0ac362b03416da06ab3fa36fb58e3'.freeze
7
+ FOOD = 'bd367be194cf45149e75f01d59f77ba7'.freeze
8
+ end
@@ -0,0 +1,62 @@
1
+ module Clarification
2
+ class Requester
3
+
4
+ def initialize(model)
5
+ @model = model
6
+ end
7
+
8
+ def get(target_url)
9
+ uri = uri_builder
10
+ body = body_builder(target_url)
11
+ request = request_builder(uri, body)
12
+ options = options_builder(uri)
13
+
14
+ response = Net::HTTP.start(uri.hostname, uri.port, options) do |http|
15
+ http.request(request)
16
+ end
17
+
18
+ return response
19
+ end
20
+
21
+
22
+ private
23
+
24
+ def body_builder(url)
25
+ {
26
+ "inputs": [
27
+ {
28
+ "data": {
29
+ "image": {
30
+ "url": "#{url}"
31
+ }
32
+ }
33
+ }
34
+ ]
35
+ }
36
+ end
37
+
38
+ def uri_builder
39
+ uri = URI.parse("https://api.clarifai.com/v2/models/bd367be194cf45149e75f01d59f77ba7/outputs")
40
+ end
41
+
42
+ def request_builder(uri, body)
43
+ request = Net::HTTP::Post.new(uri)
44
+ request.content_type = "application/json"
45
+ request["Authorization"] = "Key f7cc628178994e16b2470ae739ef927a"
46
+ request.body = JSON.dump(body)
47
+
48
+ return request
49
+ end
50
+
51
+ def options_builder(uri)
52
+ request_options = {
53
+ use_ssl: uri.scheme == "https",
54
+ }
55
+
56
+ return request_options
57
+ end
58
+
59
+
60
+
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ module Clarification
2
+ VERSION = "0.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clarification
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Nichol Alexander
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-09-19 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
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: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
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
+ description: Alpha Version - configure, access Clarifai set end points, interrogate
98
+ responses.
99
+ email:
100
+ - nichol.alexander@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - CODE_OF_CONDUCT.md
109
+ - Gemfile
110
+ - Guardfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - bin/console
115
+ - bin/setup
116
+ - clarification.gemspec
117
+ - lib/clarification.rb
118
+ - lib/clarification/client.rb
119
+ - lib/clarification/configuration.rb
120
+ - lib/clarification/end_points.rb
121
+ - lib/clarification/requester.rb
122
+ - lib/clarification/version.rb
123
+ homepage: https://github.com/nicholalexander/clarification
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.6.13
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: An unofficial API wrapper for the Clarifai Image and Video Recognition API.
147
+ test_files: []