tinplate 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +68 -7
- data/README.md +18 -3
- data/lib/tinplate/errors.rb +14 -7
- data/lib/tinplate/tineye.rb +2 -2
- data/lib/tinplate/version.rb +1 -1
- data/tinplate.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e28c63b93bf4a54f865668ea7d4119eb39945de
|
4
|
+
data.tar.gz: 0dd7df55fab4b1b0a4c8f6deae490ac81a65b10f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84dd4c2fbf019950ef4bc46a605d18c9a62e5b10f55cd1d19b78df9b4336345b9dd453a686b9786935635444e86bc73213842f6428402e0b73a4158e41d11e27
|
7
|
+
data.tar.gz: 32570d242649e6a0d853905e515c26ecbeac83459b38df47694ba7f19d90bcaa7108abcf585dd3da2261db970d119ceb5ed3206c9897e7303036114977de97c0
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,13 +1,74 @@
|
|
1
|
-
# Contributor Code of Conduct
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
2
|
|
3
|
-
|
3
|
+
## Our Pledge
|
4
4
|
|
5
|
-
|
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.
|
6
11
|
|
7
|
-
|
12
|
+
## Our Standards
|
8
13
|
|
9
|
-
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
10
16
|
|
11
|
-
|
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
|
12
22
|
|
13
|
-
|
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 [INSERT 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/README.md
CHANGED
@@ -18,6 +18,21 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install tinplate
|
20
20
|
|
21
|
+
## Configuration
|
22
|
+
|
23
|
+
First you've got to let Tinplate know what your TinEye API keys are. In a Rails app, for example, this would go in an initializer, e.g. `config/intitializers/tinplate.rb`:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Tinplate.configure do |config|
|
27
|
+
config.public_key = "YOUR PUBLIC API KEY"
|
28
|
+
config.private_key = "YOUR PRIVATE API KEY"
|
29
|
+
config.test = false
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
If `test` is set to `true` (which is also the default), Tinplate will use [TinEye's test keys and sandbox environment](https://services.tineye.com/developers/tineyeapi/sandbox.html).
|
34
|
+
|
35
|
+
|
21
36
|
## Usage
|
22
37
|
|
23
38
|
There are only three API actions available: `search`, `remaining_searches` (to check the status of your account), and `image_count` (if you're curious how many total images TinEye has indexed).
|
@@ -72,16 +87,16 @@ backlinks:
|
|
72
87
|
}
|
73
88
|
]
|
74
89
|
```
|
75
|
-
|
90
|
+
|
76
91
|
## Development
|
77
92
|
|
78
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
|
93
|
+
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.
|
79
94
|
|
80
95
|
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).
|
81
96
|
|
82
97
|
## Contributing
|
83
98
|
|
84
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
99
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/unsplash/tinplate. 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.
|
85
100
|
|
86
101
|
|
87
102
|
## License
|
data/lib/tinplate/errors.rb
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
module Tinplate
|
2
2
|
class Error < StandardError
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
def self.from_response(code, type, message)
|
4
|
+
klass = case message
|
5
|
+
when /503 Service Unavailable/ then Tinplate::ServiceUnavailable
|
6
|
+
when /service is busy due to high load/ then Tinplate::ServiceUnavailable
|
7
|
+
when /Image too simple/ then Tinplate::NoSignatureError
|
8
|
+
when /purchase another bundle/ then Tinplate::NoCreditsRemaining
|
9
|
+
else
|
10
|
+
Tinplate::Error
|
11
|
+
end
|
6
12
|
|
7
|
-
|
8
|
-
@code = code
|
9
|
-
@type = @type
|
10
|
-
@message = message
|
13
|
+
klass.new(message)
|
11
14
|
end
|
12
15
|
end
|
16
|
+
|
17
|
+
class ServiceUnvailable < Error; end
|
18
|
+
class NoSignatureError < Error; end
|
19
|
+
class NoCreditsRemaining < Error; end
|
13
20
|
end
|
data/lib/tinplate/tineye.rb
CHANGED
@@ -33,7 +33,7 @@ module Tinplate
|
|
33
33
|
response = ::JSON.parse(connection.get("#{action}/", params).body)
|
34
34
|
|
35
35
|
if response["code"] != 200
|
36
|
-
raise Tinplate::Error.
|
36
|
+
raise Tinplate::Error.from_response(response["code"], response["messages"][0], response["messages"][1])
|
37
37
|
end
|
38
38
|
|
39
39
|
response
|
@@ -42,7 +42,7 @@ module Tinplate
|
|
42
42
|
def connection
|
43
43
|
@conn ||= Faraday.new(url: "http://api.tineye.com/rest/") do |faraday|
|
44
44
|
faraday.request :url_encoded
|
45
|
-
faraday.response :logger
|
45
|
+
faraday.response :logger
|
46
46
|
faraday.adapter Faraday.default_adapter
|
47
47
|
end
|
48
48
|
end
|
data/lib/tinplate/version.rb
CHANGED
data/tinplate.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["aaron@crew.co"]
|
11
11
|
|
12
12
|
spec.summary = %q{A wrapper around the TinEye API.}
|
13
|
-
spec.homepage = "https://github.com/
|
13
|
+
spec.homepage = "https://github.com/unsplash/tinplate"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinplate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Klaassen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -104,7 +104,7 @@ files:
|
|
104
104
|
- lib/tinplate/tineye.rb
|
105
105
|
- lib/tinplate/version.rb
|
106
106
|
- tinplate.gemspec
|
107
|
-
homepage: https://github.com/
|
107
|
+
homepage: https://github.com/unsplash/tinplate
|
108
108
|
licenses:
|
109
109
|
- MIT
|
110
110
|
metadata: {}
|