rails_dominant_colors 0.1.4 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57c35635af12a553916052efbdc02189e8d7b79a47a9a4a3162c806ccb3ea698
4
- data.tar.gz: 236f3a4ecc9a5b49b2bd2f05c0ce6d437bcea5c537b919823684542a18b67937
3
+ metadata.gz: cc461431999b438497a0d90347db8c6925b3229ecc914bfc6f8a76649a145b6c
4
+ data.tar.gz: 9c2692cd8a7e6bad4289c72f9922ed9361c012646f6b0b8ee9752c4281d83fdc
5
5
  SHA512:
6
- metadata.gz: 49731f98c73d138480bf9f16d67c992c6b8829eef1b9d304b29e5a869a7548302d8726e62893cb52cda5e7ba37c3deaa978af5986205ba2d2c2513b8edc9fcb3
7
- data.tar.gz: ce6ad4c0c945b0832867886b8d032bd5618be85ad07f0dec80a6eb5db86a3717a62b014a2e595a83461c7b7bdd7f012dc7758d39a728b3934909faa48e30697d
6
+ metadata.gz: 853a1163cae3430115faff75aeb5fa9bb727b5e9fcfe8db3ed1dcd293f0c8e9db40ba42d216f9e4fb721a7133819f3c11bdd9652c3fab6df12ce03934cb71916
7
+ data.tar.gz: 71b484c448f706717d4c188ac296ab24b5a1ab6db5db7bcc267fb2e976af6eb17930732fdd27220cf51db5ff980662357d503b0b96eb43e2e44b56cbf3504701
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails_dominant_colors (0.2.0)
5
+ mini_magick (~> 4.10)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coveralls (0.8.23)
11
+ json (>= 1.8, < 3)
12
+ simplecov (~> 0.16.1)
13
+ term-ansicolor (~> 1.3)
14
+ thor (>= 0.19.4, < 2.0)
15
+ tins (~> 1.6)
16
+ diff-lcs (1.4.4)
17
+ docile (1.3.2)
18
+ json (2.3.1)
19
+ mini_magick (4.10.1)
20
+ rake (13.0.1)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.2)
26
+ rspec-support (~> 3.9.3)
27
+ rspec-expectations (3.9.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.3)
34
+ simplecov (0.16.1)
35
+ docile (~> 1.1)
36
+ json (>= 1.8, < 3)
37
+ simplecov-html (~> 0.10.0)
38
+ simplecov-html (0.10.2)
39
+ sync (0.5.0)
40
+ term-ansicolor (1.7.1)
41
+ tins (~> 1.0)
42
+ thor (1.0.1)
43
+ tins (1.25.0)
44
+ sync
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ bundler (~> 2.0)
51
+ coveralls (~> 0.8)
52
+ rails_dominant_colors!
53
+ rake (~> 13.0)
54
+ rspec (~> 3.9)
55
+ simplecov (~> 0.16)
56
+
57
+ BUNDLED WITH
58
+ 2.1.4
data/README.md CHANGED
@@ -30,33 +30,31 @@ Or install it yourself as:
30
30
  ## Usage
31
31
 
32
32
  ```ruby
33
- opts = {
34
- colors: 5 # Number of colors (default: 5)
35
- }
33
+ colors = 5 # Optional, number of colors (default: 5)
36
34
 
37
- colors = RailsDominantColors::Base64.new('data:image/png;base64,awesome-image', opts)
35
+ dominant_colors = RailsDominantColors::Base64.new('data:image/png;base64,awesome-image', colors)
38
36
 
39
37
  # or
40
38
 
41
- RailsDominantColors::Url.new('https://awesome-url.com/awesome-image.png')
39
+ RailsDominantColors::Url.new('https://awesome-url.com/awesome-image.png', colors)
42
40
 
43
41
  # or
44
42
 
45
- RailsDominantColors::Path.new('/awesome/path/awesome-image.png')
43
+ RailsDominantColors::Path.new('/awesome/path/awesome-image.png', colors)
46
44
 
47
45
  # and
48
46
 
49
- colors.to_hex # => ["#FF007F", "#000000", "#1C000F", "#A0004F", "#000000"]
50
- colors.to_hex_alpha # => ["#FF007FFF", "#00000000", "#1C000FFE", "#A0004FFF", "#0000005F"]
47
+ dominant_colors.to_hex # => ["#FF007F", "#000000", "#1C000F", "#A0004F", "#000000"]
48
+ dominant_colors.to_hex_alpha # => ["#FF007FFF", "#00000000", "#1C000FFE", "#A0004FFF", "#0000005F"]
51
49
 
52
- colors.to_rgb # => [[255, 0, 127], [0, 0, 0], [28, 0, 15], [160, 0, 79], [0, 0, 0]]
53
- colors.to_rgb_alpha # => [[255, 0, 127, 1.0], [0, 0, 0, 0.0], [28, 0, 15, 1.0], [160, 0, 79, 1.0], [0, 0, 0, 0.37]]
50
+ dominant_colors.to_rgb # => [[255, 0, 127], [0, 0, 0], [28, 0, 15], [160, 0, 79], [0, 0, 0]]
51
+ dominant_colors.to_rgb_alpha # => [[255, 0, 127, 1.0], [0, 0, 0, 0.0], [28, 0, 15, 1.0], [160, 0, 79, 1.0], [0, 0, 0, 0.37]]
54
52
 
55
- colors.to_hsl # => [[330, 100, 50], [0, 0, 0], [328, 100, 5], [330, 100, 31], [0, 0, 0]]
56
- colors.to_hsl_alpha # => [[330, 100, 50, 1.0], [0, 0, 0, 0.0], [328, 100, 5, 1.0], [330, 100, 31, 1.0], [0, 0, 0, 0.37]]
53
+ dominant_colors.to_hsl # => [[330, 100, 50], [0, 0, 0], [328, 100, 5], [330, 100, 31], [0, 0, 0]]
54
+ dominant_colors.to_hsl_alpha # => [[330, 100, 50, 1.0], [0, 0, 0, 0.0], [328, 100, 5, 1.0], [330, 100, 31, 1.0], [0, 0, 0, 0.37]]
57
55
 
58
56
  # Awesome bonus
59
- colors.to_pct # => [52.16, 37.45, 9.93, 0.35, 0.1]
57
+ dominant_colors.to_pct # => [52.16, 37.45, 9.93, 0.35, 0.1]
60
58
 
61
59
  ```
62
60
 
@@ -7,16 +7,16 @@ require 'rails_dominant_colors/url'
7
7
 
8
8
  module RailsDominantColors
9
9
  class << self
10
- def base64(source, opts = {})
11
- RailsDominantColors::Base64.new(source, opts)
10
+ def base64(source, colors = 5)
11
+ RailsDominantColors::Base64.new(source, colors)
12
12
  end
13
13
 
14
- def url(source, opts = {})
15
- RailsDominantColors::Url.new(source, opts)
14
+ def url(source, colors = 5)
15
+ RailsDominantColors::Url.new(source, colors)
16
16
  end
17
17
 
18
- def path(source, opts = {})
19
- RailsDominantColors::Path.new(source, opts)
18
+ def path(source, colors = 5)
19
+ RailsDominantColors::Path.new(source, colors)
20
20
  end
21
21
  end
22
22
  end
@@ -13,9 +13,9 @@ module RailsDominantColors
13
13
 
14
14
  attr_reader(:source, :colors)
15
15
 
16
- def initialize(source, opts = {})
16
+ def initialize(source, colors)
17
17
  @source = source
18
- @colors = opts.fetch(:colors) { 5 }
18
+ @colors = colors
19
19
  end
20
20
 
21
21
  def to_hex_alpha
@@ -4,10 +4,10 @@ require 'base64'
4
4
 
5
5
  module RailsDominantColors
6
6
  class Base64 < Base
7
- def initialize(source, opts = {})
7
+ def initialize(source, colors)
8
8
  raise(EmptySource) if source.nil? || source.empty?
9
9
 
10
- super(process(source), opts)
10
+ super(process(source), colors)
11
11
  end
12
12
 
13
13
  private
@@ -2,12 +2,12 @@
2
2
 
3
3
  module RailsDominantColors
4
4
  class Path < Base
5
- def initialize(source, opts = {})
5
+ def initialize(source, colors)
6
6
  raise(EmptySource) if source.nil? || source.empty?
7
7
  raise(FileNotFound) unless file_exist?(source)
8
8
  raise(NotAnImage) unless file_is_image?(source)
9
9
 
10
- super(source, opts)
10
+ super(source, colors)
11
11
  end
12
12
 
13
13
  private
@@ -4,10 +4,10 @@ require 'net/http'
4
4
 
5
5
  module RailsDominantColors
6
6
  class Url < Base
7
- def initialize(source, opts = {})
7
+ def initialize(source, colors)
8
8
  raise(EmptySource) if source.nil? || source.empty?
9
9
 
10
- super(process(source), opts)
10
+ super(process(source), colors)
11
11
  end
12
12
 
13
13
  def process(source)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsDominantColors
4
- VERSION = '0.1.4'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_dominant_colors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris BRESCIANI
@@ -109,6 +109,7 @@ files:
109
109
  - ".rubocop.yml"
110
110
  - ".travis.yml"
111
111
  - Gemfile
112
+ - Gemfile.lock
112
113
  - LICENSE.txt
113
114
  - README.md
114
115
  - Rakefile