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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63e4027af922a5ed4d54a8f98ca2059fad032ca3
4
- data.tar.gz: 3d16953df254c8814ef0df00dbcc3c2becf88448
3
+ metadata.gz: ffcc67dff3749518923397b3a5a31d6897a649f2
4
+ data.tar.gz: c80b243110c65b265661b92cbd5337511cee12be
5
5
  SHA512:
6
- metadata.gz: 0e017365963522dd42d2ddc8aa73552107a3fad243ea5259648ec019ca908baa3e37d66d0ebe543832682fb25d7dc58182aa29b128b63fadef79b5e1229fbb12
7
- data.tar.gz: 836c7c72066d4ee9581560441249fe16f0fdfb4429a37161c7cd7fe8ee1cbdb346689e529ca7b7bd1d5243cd81c8e8718ab7eb2c91e340817094a3353dfcf776
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::Rb
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-rb'
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-rb
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(sourceImage, color_count: 64, quality: 5)
12
- Vibrant.new(sourceImage, color_count: color_count, quality:quality).swatches
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
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Vibrant
3
- VERSION = "0.2.0"
3
+ VERSION = '0.2.1'
4
4
  end
@@ -120,7 +120,6 @@ module Vibrant
120
120
  end
121
121
  end
122
122
  end
123
- p max
124
123
 
125
124
  max
126
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vibrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dondoco7