vibrant 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -17
- data/lib/vibrant.rb +24 -2
- data/lib/vibrant/version.rb +1 -1
- data/lib/vibrant/vibrant.rb +0 -1
- 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: ffcc67dff3749518923397b3a5a31d6897a649f2
|
4
|
+
data.tar.gz: c80b243110c65b265661b92cbd5337511cee12be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bd252f8a02cae5ca3771f1cf4c76127ffc9ca8394db10df5f83d6793af68ca5b5f20efae8aed7d90041715bbe5d3027385fe4d2c7bb202e56123014bbc546bf
|
7
|
+
data.tar.gz: fea90672489df1e05a43b5429671686ec1630247a15af18c4ad62ac5081a72bf83ffba01f657955b22195bf57b943e6510cffee0319c6238a21bcce043ebc656
|
data/README.md
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/vibrant-rb.svg)](https://badge.fury.io/rb/vibrant-rb)
|
2
2
|
|
3
|
-
# Vibrant
|
3
|
+
# Vibrant
|
4
4
|
|
5
5
|
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/vibrant/rb`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
6
|
|
7
|
-
TODO: Delete this and the text above, and describe your gem
|
8
|
-
|
9
7
|
## Installation
|
10
8
|
|
11
9
|
Add this line to your application's Gemfile:
|
12
10
|
|
13
11
|
```ruby
|
14
|
-
gem 'vibrant
|
12
|
+
gem 'vibrant'
|
15
13
|
```
|
16
14
|
|
17
15
|
And then execute:
|
@@ -20,21 +18,10 @@ And then execute:
|
|
20
18
|
|
21
19
|
Or install it yourself as:
|
22
20
|
|
23
|
-
$ gem install vibrant
|
21
|
+
$ gem install vibrant
|
24
22
|
|
25
23
|
## Usage
|
26
24
|
|
27
|
-
### Install
|
28
|
-
|
29
|
-
```
|
30
|
-
gem install vibrant
|
31
|
-
```
|
32
|
-
or
|
33
|
-
```
|
34
|
-
gem 'vibrant'
|
35
|
-
```
|
36
|
-
|
37
|
-
### Use
|
38
25
|
```
|
39
26
|
|
40
27
|
# path or file
|
@@ -48,7 +35,6 @@ dark_muted = vibrant.dark_muted.hex
|
|
48
35
|
light_vibrant = vibrant.light_vibrant.hex
|
49
36
|
light_muted = vibrant.light_muted.hex
|
50
37
|
```
|
51
|
-
TODO: Write usage instructions here
|
52
38
|
|
53
39
|
## Development
|
54
40
|
|
data/lib/vibrant.rb
CHANGED
@@ -2,14 +2,36 @@
|
|
2
2
|
|
3
3
|
require 'vibrant/version'
|
4
4
|
require 'rmagick'
|
5
|
+
require 'tempfile'
|
5
6
|
|
6
7
|
require 'vibrant/swatch'
|
7
8
|
require 'vibrant/vibrant'
|
8
9
|
|
9
10
|
module Vibrant
|
10
11
|
|
11
|
-
def self.read(
|
12
|
-
|
12
|
+
def self.read(file_or_path, color_count: 64, quality: 5, use_tempfile: false)
|
13
|
+
if use_tempfile
|
14
|
+
if file_or_path.is_a?(String)
|
15
|
+
open(file_or_path, 'r') do |file|
|
16
|
+
_read_with_temp(file, color_count: color_count, quality: quality)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
_read_with_temp(file_or_path, color_count: color_count, quality: quality)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
_read(file_or_path, color_count: color_count, quality: quality)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self._read_with_temp(file, color_count: 64, quality: 5)
|
27
|
+
Tempfile.open(['vibrant']) do |tempfile|
|
28
|
+
tempfile.write(file.read)
|
29
|
+
read(tempfile.path)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self._read(file_or_path, color_count: 64, quality: 5)
|
34
|
+
Vibrant.new(file_or_path, color_count: color_count, quality: quality).swatches
|
13
35
|
end
|
14
36
|
|
15
37
|
end
|
data/lib/vibrant/version.rb
CHANGED
data/lib/vibrant/vibrant.rb
CHANGED