unsplash_image 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 27977f3506d7d69b51a21fe2d1cc0a521fc5fa5d6b90ffa37bbdda9d001e8774
4
- data.tar.gz: dae359ff65d6f3edec2534581a1db3f97a2f951f9101359fec2a4066d19f1c95
3
+ metadata.gz: 8b7ddef2272d5f672ffca89e34aa489d14a3d650d9231507b1a7c36f4e691e27
4
+ data.tar.gz: 00b61f02431292c30016be945784d2bb8fd91e42feafd36272b8ac5748b74ba4
5
5
  SHA512:
6
- metadata.gz: adddf72e64434d5825eeec312dcbcf6e21131420b348ae36f026d3b2ba054d160d834640e6c67bceb05f993074183fef2b524fb77a796ef23fedc03854104292
7
- data.tar.gz: 60a6289114199d9f7eb89d25866500f328307fb590162f82afba1f9aa528708f95563a3d1d0631cc657c6b1a7b999fa8149b747e6ba61bd8ad9839970629d1cb
6
+ metadata.gz: ae2bc4d0d81bd78cdd7b8a75ea0bca782efbc9fa40b86c9c98c42c689e11b1911bbcaa1703652bbe4e7e3677244b2bc33fd288fdf4cad9b775bfd00a2c17b83c
7
+ data.tar.gz: 7b7d7e60cfdb763e52316e8e7d501ebfba57b63f38722ce4b48062bc8c80a2394a1ff8ba69ccdd1abb8d0b699dbfb70288ed1790272f75c7c2a5cfddce53c631
data/README.md CHANGED
@@ -10,23 +10,23 @@ This is the easiest way to fill your Rails app with real photos.
10
10
 
11
11
  1. as Rails helper to generate dummy images:
12
12
  ```ruby
13
- <%= image_tag unsplash_image_url(size: '300x200', tags: 'cat, dog') %>
13
+ <%= image_tag unsplash_image_url(size: '300x200', tags: 'cat, dog') %>
14
14
 
15
- <%= image_tag unsplash_image_url(size: '800x600', tags: 'building') %>
15
+ <%= image_tag unsplash_image_url(size: '800x600', tags: 'building') %>
16
16
 
17
- <%= image_tag unsplash_image_url(tags: 'nature') %>
17
+ <%= image_tag unsplash_image_url(tags: 'nature') %>
18
18
  ```
19
19
 
20
20
  2. as a tool to download images from Unsplash.com and use them for your seeds or specs.
21
21
 
22
22
  ```bash
23
- unsplash_image download --path images/cats --tags cat -n 20
23
+ unsplash_image download --path images/cats --tags cat -n 20
24
24
  ```
25
25
 
26
26
  3. If you need to have a `File` object with a random image.
27
27
 
28
28
  ```ruby
29
- file = UnsplashImage.tempfile(size: '500x500', tags: 'cat')
29
+ file = UnsplashImage.tempfile(size: '500x500', tags: 'cat')
30
30
  ```
31
31
 
32
32
  ### CLI
@@ -49,14 +49,14 @@ You can get random image url inside your views using `unsplash_image_url`.
49
49
 
50
50
  Example:
51
51
  ```erb
52
- <%= image_tag unsplash_image_url(size: '300x200', tags: 'cat, dog') %>
52
+ <%= image_tag unsplash_image_url(size: '300x200', tags: 'cat, dog') %>
53
53
  ```
54
54
 
55
55
  Also you can get it as a file with `UnsplashImage.tempfile`.
56
56
 
57
57
  Example:
58
58
  ```ruby
59
- file = UnsplashImage.tempfile(size: '500x500', tags: 'cat')
59
+ file = UnsplashImage.tempfile(size: '500x500', tags: 'cat')
60
60
  ```
61
61
 
62
62
  ## Installation
@@ -78,6 +78,10 @@ To use CLI anywhere in the system you can install gem globally:
78
78
  gem install unsplash_image
79
79
  ```
80
80
 
81
+ ## Unit Tests
82
+
83
+ We have simple tests, just run: `ruby test/unsplash_image_test.rb`.
84
+
81
85
  ## Contributing
82
86
 
83
87
  You are welcome to contribute. See list of `TODO's` below.
@@ -4,7 +4,7 @@ require "tempfile"
4
4
  module UnsplashImage
5
5
  module Download
6
6
  def tempfile(size: nil, filename: "image.jpeg", tags: nil)
7
- file = Tempfile.new(filename)
7
+ file = Tempfile.new(filename, binmode: true)
8
8
  begin
9
9
  file.write(URI.parse(UnsplashImage::Helper.unsplash_image_url(size: size, tags: tags)).read)
10
10
  file.rewind
@@ -4,10 +4,10 @@ module UnsplashImage
4
4
 
5
5
  BASE = "https://source.unsplash.com/random".freeze
6
6
 
7
- def unsplash_image_url(size:, tags: nil)
7
+ def unsplash_image_url(size: nil, tags: nil)
8
8
  options = [BASE]
9
9
 
10
- options << size
10
+ options << size if size
11
11
  options << "?#{tags}" if tags
12
12
 
13
13
  options.join("/")
@@ -1,3 +1,3 @@
1
1
  module UnsplashImage
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unsplash_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-11 00:00:00.000000000 Z
12
+ date: 2022-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor