fotofetch 0.1.0 → 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/Gemfile.lock +7 -7
- data/README.md +33 -15
- data/fotofetch.gemspec +1 -1
- data/lib/fotofetch/version.rb +1 -1
- data/pkg/fotofetch-0.1.0.gem +0 -0
- data/test/fotofetch_test.rb +5 -0
- metadata +5 -6
- data/notes.markdown +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8fffabd192e16ce9a554bbe27c720925c3d831bd
|
|
4
|
+
data.tar.gz: 7b3eb4a2e53e7b280b140a42b05696d633908315
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 (
|
|
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.
|
|
13
|
+
domain_name (0.5.20160310)
|
|
14
14
|
unf (>= 0.0.5, < 1.0.0)
|
|
15
|
-
fastimage (
|
|
16
|
-
addressable (~> 2
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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"
|
data/lib/fotofetch/version.rb
CHANGED
data/pkg/fotofetch-0.1.0.gem
CHANGED
|
Binary file
|
data/test/fotofetch_test.rb
CHANGED
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:
|
|
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:
|
|
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:
|
|
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, './')
|