fotofetch 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/fotofetch.rb +2 -2
- data/lib/fotofetch/version.rb +1 -1
- data/pkg/fotofetch-1.1.1.gem +0 -0
- data/test/fotofetch_test.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46802facb22655cc2d53909538474e27cbcba3f0
|
4
|
+
data.tar.gz: 1a23a7e8b2bbccd6b9d7f896c551411d08d74f17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c825f85257c44408be9d9d6c5256e034f2edef6f87623364f67ec2e97c9253d99d2ad1afd5dde7f889960adaccc3177b89da443882fc4891458817f33cde903
|
7
|
+
data.tar.gz: f657ff62922cd82a7f0d9aab304dc9a4fe3a71bb836ee942a8f6cd0d6ca39cac8f47469eb4ace1b262039dcaa68f967d9b05a04d4347d7a8b731a11e9b72344e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,9 +28,9 @@ Or install it yourself as:
|
|
28
28
|
```ruby
|
29
29
|
link = @fetcher.fetch_links("tesla model s")
|
30
30
|
```
|
31
|
-
- To save the link to your file directory
|
31
|
+
- To save the link to your file directory (links must be in an array, so call .values):
|
32
32
|
```ruby
|
33
|
-
@ff.save_images(link, './')
|
33
|
+
@ff.save_images(link.values, './')
|
34
34
|
```
|
35
35
|
The 'save_images' method takes two arguments: link(s) and the file path for where to save.
|
36
36
|
|
@@ -50,7 +50,7 @@ links = @fetcher.fetch_links("jupiter", 3, 1500, 1500)
|
|
50
50
|
```
|
51
51
|
And to save all of those links:
|
52
52
|
```ruby
|
53
|
-
@fetcher.save_images(links, './')
|
53
|
+
@fetcher.save_images(links.values, './')
|
54
54
|
```
|
55
55
|
If a small or large enough image is not found, dimension restrictions will be disregarded.
|
56
56
|
|
data/lib/fotofetch.rb
CHANGED
@@ -5,8 +5,8 @@ require 'fastimage'
|
|
5
5
|
|
6
6
|
module Fotofetch
|
7
7
|
class Fetch
|
8
|
-
|
9
8
|
def fetch_links(topic, amount=1, width= +9999, height= +9999)
|
9
|
+
@query = topic
|
10
10
|
@results = []
|
11
11
|
scrape(topic, amount, width, height)
|
12
12
|
end
|
@@ -69,7 +69,7 @@ module Fotofetch
|
|
69
69
|
# takes an array of links
|
70
70
|
def save_images(urls, file_path)
|
71
71
|
urls.each_with_index do |url, i|
|
72
|
-
open("
|
72
|
+
open("#{@query.gsub(' ', '-')}_#{i}.jpg", 'wb') do |file|
|
73
73
|
file << open(url).read
|
74
74
|
end
|
75
75
|
end
|
data/lib/fotofetch/version.rb
CHANGED
data/pkg/fotofetch-1.1.1.gem
CHANGED
Binary file
|
data/test/fotofetch_test.rb
CHANGED
@@ -29,9 +29,9 @@ class FotofetchTest < Minitest::Test
|
|
29
29
|
link = @ff.fetch_links("tesla", 1).values
|
30
30
|
@ff.save_images(link, './')
|
31
31
|
|
32
|
-
assert File.exist?('
|
33
|
-
refute File.zero?('
|
34
|
-
File.delete('
|
32
|
+
assert File.exist?('tesla_0.jpg')
|
33
|
+
refute File.zero?('tesla_0.jpg')
|
34
|
+
File.delete('tesla_0.jpg')
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_it_checks_image_size
|