guesswhat 1.0.1 → 1.1.0
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 +4 -4
- data/README.md +20 -5
- data/lib/guesswhat.rb +8 -5
- data/lib/guesswhat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55578b290af95649fb5f3076b5db95ceaf5d65d8
|
4
|
+
data.tar.gz: 65dcd49655aff07e339ae42c2d77a9b4346f11f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c55217d30f71a55c8927919a8ebfb8202a5d770c31165ab977c45049d4e5feb3f24e78d26119a60754203e77ede96dd95d877b162c3d0836ad5bb1ccc5dc1683
|
7
|
+
data.tar.gz: 7cc91e9a7ceb6d41010c55c8e1ad339c3a37ad9aec05452a93f2b3f95bcc614d136874a58f96e26ee919f5cc11ee805ecf6345677e3168dd8b9a4c0f25da8e5d
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Guesswhat
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Guesswhat is essentially a tool that allows you to get images from Google Image Search based on the item category you are passing in.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,24 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
```ruby
|
24
|
+
Guesswhat::Product.image("shoes") #=> URL with a picture of a shoe
|
25
|
+
Guesswhat::Product.image("bluepants") #=> URL with a picture of a bluepants
|
26
|
+
```
|
27
|
+
|
28
|
+
|
29
|
+
###Guesswhat::Product.image(input)
|
30
|
+
---------------
|
31
|
+
***COMING SOON***
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Guesswhat::Product.image(input).size #Specifiying the size of the image
|
35
|
+
Guesswhat::Product.image(input).color #Specifiying the color of the image
|
36
|
+
Guesswhat::Product.image(input).type #Specifiying the type of the image such as png, jpg, svg...
|
37
|
+
Guesswhat::Product.image(input).limit #Specifiying the number of images needed
|
38
|
+
Guesswhat::Product.image(input).have #Specifiying what item to include from the search
|
39
|
+
Guesswhat::Product.image(input).exclude #Specifiying what item to exclude from the search
|
40
|
+
```
|
26
41
|
|
27
42
|
## Development
|
28
43
|
|
@@ -32,5 +47,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
47
|
|
33
48
|
## Contributing
|
34
49
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ThinkTankShark/guesswhat. 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.
|
36
51
|
|
data/lib/guesswhat.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
-
|
1
|
+
require "guesswhat/version"
|
2
2
|
require 'rest-client'
|
3
3
|
|
4
4
|
module Guesswhat
|
5
5
|
class Product
|
6
6
|
|
7
|
-
def self.image(item)
|
7
|
+
def self.image(item = "shoe", size = "xlarge", limit = 10, type = "png",color = "color")
|
8
|
+
|
9
|
+
key = "AIzaSyBvSuUjfRZ0ImQP6KEgDdQEtdUoB1nWQY8"
|
8
10
|
|
9
11
|
#Default URL for finding images from google
|
10
|
-
url = "https://www.googleapis.com/customsearch/v1?q=#{item}&cx=008288361057280940904%3Acaao_sbv0xy&fileType
|
12
|
+
url = "https://www.googleapis.com/customsearch/v1?q=#{item}&cx=008288361057280940904%3Acaao_sbv0xy&fileType=#{}&imgColorType=#{}&filter=1&imgSize=#{size}&num=#{limit}&searchType=image&key=#{key}"
|
11
13
|
response = JSON.parse(RestClient.get url)
|
12
14
|
|
15
|
+
rand_index = rand(1-50) + 1
|
13
16
|
#Finding the first image from Google Images
|
14
|
-
if response["items"][
|
15
|
-
image_url = response["items"][
|
17
|
+
if response["items"][rand_index]["link"] != nil
|
18
|
+
image_url = response["items"][rand_index]["link"]
|
16
19
|
else
|
17
20
|
image_url = nil
|
18
21
|
end
|
data/lib/guesswhat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guesswhat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sepand Assadi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|