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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d29807c01eb1a5031d9273e88fc0182d917d234
4
- data.tar.gz: 92a16efd43ca495da6fc5cd0b332516d2189dcda
3
+ metadata.gz: 55578b290af95649fb5f3076b5db95ceaf5d65d8
4
+ data.tar.gz: 65dcd49655aff07e339ae42c2d77a9b4346f11f5
5
5
  SHA512:
6
- metadata.gz: 2c54888e774d1c55e78adedb124b9d67d8cf7b65ffd492373adfd0fe6e5a27548ad651e9f66a54e8532aa49fa6f4baba4b796ae55e589c6328224072fc3f0e1a
7
- data.tar.gz: dc5477a6943e9a9b69de11ce975dfec87174536da13a1aca2033768b7f2039a3397f90f96b4fe7e8524884de75fc520ca52962b967a81c0d9b795d39742bbb99
6
+ metadata.gz: c55217d30f71a55c8927919a8ebfb8202a5d770c31165ab977c45049d4e5feb3f24e78d26119a60754203e77ede96dd95d877b162c3d0836ad5bb1ccc5dc1683
7
+ data.tar.gz: 7cc91e9a7ceb6d41010c55c8e1ad339c3a37ad9aec05452a93f2b3f95bcc614d136874a58f96e26ee919f5cc11ee805ecf6345677e3168dd8b9a4c0f25da8e5d
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Guesswhat
2
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/guesswhat`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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/[USERNAME]/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.
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
- # require "guesswhat/version"
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=png&filter=1&imgSize=xlarge&num=1&safe=high&searchType=image&key=AIzaSyBvSuUjfRZ0ImQP6KEgDdQEtdUoB1nWQY8"
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"][0]["link"] != nil
15
- image_url = response["items"][0]["link"]
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
@@ -1,3 +1,3 @@
1
1
  module Guesswhat
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
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.1
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-05 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler