fotofetch 0.1.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0af691137a1f90911465307669bdc22ec978018
4
- data.tar.gz: 9fdfcebcdd775ec9d1c8c9fd0e5248326a2edbd9
3
+ metadata.gz: 8fffabd192e16ce9a554bbe27c720925c3d831bd
4
+ data.tar.gz: 7b3eb4a2e53e7b280b140a42b05696d633908315
5
5
  SHA512:
6
- metadata.gz: fdb59a2834c51cff47448a555378261724ffa7fc7e877b42af3c0b0134586edf38381fc771bd4d314bd07d679904324a40afe7faad56fe15a517ed8a29c72457
7
- data.tar.gz: f6f976ff5b0857d5567ba2e64024eb39406f85051690fa08e98d0682926c108961aa17de51a1f125587e0d780527e54ad880b2b02ef90a4139ca4e66ef0ff1a0
6
+ metadata.gz: f70669001c0e5daec9d20da73ccbfca4e983c4d6d8e0fa15d0854eab06cad9b6b518d8100e255fca53942bfdba9e6714615692d8b0c9cf6401e4a8b8f2e565a8
7
+ data.tar.gz: b77e22d40be89d9d5d80120486a8baf13bbd6158148bf83c7a248632376eb952505e396a775ab6f2142cfe2a9dd4c878d04e0d21158b76f783f807c6722796d9
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fotofetch (0.1.0)
5
- fastimage
4
+ fotofetch (1.1.0)
5
+ fastimage (~> 2.0.0)
6
6
  mechanize
7
7
 
8
8
  GEM
@@ -10,10 +10,10 @@ GEM
10
10
  specs:
11
11
  addressable (2.4.0)
12
12
  byebug (8.2.1)
13
- domain_name (0.5.25)
13
+ domain_name (0.5.20160310)
14
14
  unf (>= 0.0.5, < 1.0.0)
15
- fastimage (1.8.1)
16
- addressable (~> 2.3, >= 2.3.5)
15
+ fastimage (2.0.0)
16
+ addressable (~> 2)
17
17
  http-cookie (1.0.2)
18
18
  domain_name (~> 0.5)
19
19
  mechanize (2.7.4)
@@ -25,7 +25,7 @@ GEM
25
25
  nokogiri (~> 1.6)
26
26
  ntlm-http (~> 0.1, >= 0.1.1)
27
27
  webrobots (>= 0.0.9, < 0.2)
28
- mime-types (2.99)
28
+ mime-types (2.99.1)
29
29
  mini_portile2 (2.0.0)
30
30
  minitest (5.8.3)
31
31
  net-http-digest_auth (1.4)
@@ -36,7 +36,7 @@ GEM
36
36
  rake (10.4.2)
37
37
  unf (0.1.4)
38
38
  unf_ext
39
- unf_ext (0.0.7.1)
39
+ unf_ext (0.0.7.2)
40
40
  webrobots (0.1.2)
41
41
 
42
42
  PLATFORMS
data/README.md CHANGED
@@ -1,15 +1,6 @@
1
1
  # Fotofetch
2
2
 
3
- Arguments for fetch_links method are: search value, optional number of links returned,
4
- and optional dimension restrictions (width, height).
5
- If a dimension argument is positive, it will look for pictures larger than that,
6
- and if the number is negative, results will be restricted to those smaller than that.
7
- Initiate an instance to use: @fetcher = Fotofetch::Fetch.new
8
- The fetch_links method will return results like: http:example.com/image.jpg)
9
- To find a 1 small photo of Jupiter, call @fetcher.fetch_links("jupiter", 1, -500, -500).
10
- To find 3 large photos of Jupiter, call @fetcher.fetch_links("jupiter", 3, 1500, 1500).
11
- To grab just the first provided photo, call @fetcher.fetch_links("jupiter").
12
- If a small or large enough image is not found, dimension restrictions will be disregarded.
3
+ This gem allows the simple searching for and saving of images to your app. Various photo-searching API's will provide more consistent results, but this is a quick way to find images matching a query. For instance, I use it to fetch movie posters for a movie suggestions [site](http://www.nonshittymovies.com), which dynamically creates the content on each page load.
13
4
 
14
5
  ## Installation
15
6
 
@@ -27,15 +18,42 @@ Or install it yourself as:
27
18
 
28
19
  $ gem install fotofetch
29
20
 
30
- ## Usage
21
+ ## Basic Usage
22
+
23
+ - Initiate an instance of Fotofetch:
24
+ ```ruby
25
+ @fetcher = Fotofetch::Fetch.new
26
+ ```
27
+ - To fetch an image of a Tesla Model S:
28
+ ```ruby
29
+ link = @fetcher.fetch_links("tesla model s")
30
+ ```
31
+ - To save the link to your file directory
32
+ ```ruby
33
+ @ff.save_images(link, './')
34
+ ```
35
+ The 'save_images' method takes two arguments: link(s) and the file path for where to save.
31
36
 
32
- TODO: Write usage instructions here
37
+ ## More Specific Queries
38
+ Arguments for the 'fetch_links' method are: search value (required), number of links returned (optional), and two dimension restrictions arguments (optional: width, height).
33
39
 
34
- ## Development
40
+ If a dimension argument is positive, it will look for pictures larger than that,
41
+ and if the number is negative, results will be restricted to those smaller than that. Note that adding dimensions restrictions to your query will slow it down.
35
42
 
36
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+ - To find a 1 small photo of Jupiter less than 500px x 500px:
44
+ ```ruby
45
+ @fetcher.fetch_links("jupiter", 1, -500, -500)
46
+ ```
47
+ To find 3 large photos of Jupiter:
48
+ ```ruby
49
+ links = @fetcher.fetch_links("jupiter", 3, 1500, 1500)
50
+ ```
51
+ And to save all of those links:
52
+ ```ruby
53
+ @fetcher.save_images(links, './')
54
+ ```
55
+ If a small or large enough image is not found, dimension restrictions will be disregarded.
37
56
 
38
- 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).
39
57
 
40
58
  ## Contributing
41
59
 
data/fotofetch.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_runtime_dependency "mechanize"
31
- spec.add_runtime_dependency "fastimage"
31
+ spec.add_runtime_dependency "fastimage", "~> 2.0.0"
32
32
  spec.add_development_dependency "bundler", "~> 1.10"
33
33
  spec.add_development_dependency "rake", "~> 10.0"
34
34
  spec.add_development_dependency "minitest"
@@ -1,3 +1,3 @@
1
1
  module Fotofetch
2
- VERSION = "0.1.0"
2
+ VERSION = "1.1.0"
3
3
  end
Binary file
@@ -80,4 +80,9 @@ class FotofetchTest < Minitest::Test
80
80
  assert size[1] < 900
81
81
  end
82
82
 
83
+ def test_it_dimensions_are_disregarded_if_no_matches_found
84
+ link = @ff.fetch_links("mars", 1, 10000, 10000).values
85
+ assert link
86
+ end
87
+
83
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fotofetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Olson
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: fastimage
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -112,7 +112,6 @@ files:
112
112
  - fotofetch.gemspec
113
113
  - lib/fotofetch.rb
114
114
  - lib/fotofetch/version.rb
115
- - notes.markdown
116
115
  - pkg/fotofetch-0.1.0.gem
117
116
  - test/fotofetch_test.rb
118
117
  - test/test_helper.rb
data/notes.markdown DELETED
@@ -1,10 +0,0 @@
1
- rake for tests
2
- uses fastimage to check for image size
3
-
4
- methods:
5
-
6
- fetch_links(topic, amount?, optional dimension restrictions) returns an array of relevant photo links
7
- links = fetch_links('tesla', 2, true)
8
-
9
- save_images(urls, filepath)
10
- save_images(links, './')