swatchman 0.2.0 → 0.3.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: 5c18c4e66eee494aceafd3883bdcc598592b21c92017b434249721cf5bf34f8f
4
- data.tar.gz: 95954764b4bafc08349f528010ef300cbd75d0c819323e1cd078c1584bcfbb2f
3
+ metadata.gz: 123a0d53d09c7a5d82634bdd74163bdfe66458bd2ab55ffeb25619af2fea868f
4
+ data.tar.gz: 3b3f31d8e91d481dada9e6c2ed685705841525b72a36764675f1c81efc1b231e
5
5
  SHA512:
6
- metadata.gz: 718c4f337fb4b9d4d4433d6f0f631078809db1f7f1eca172e04588a1deadc6a77bfe6e7e4dcca27f4c49c71082e284e2fe4a044efa4173ee7a04ee44517af2eb
7
- data.tar.gz: f7e1a23bcb6a65fd75bf99a4c49036473aef5e41e46c5a7691cae94c62de5ebe2d7e8a249c25352973a382281833d61e2986a179ab6ff53a48027c07d46bd0d7
6
+ metadata.gz: 6d5adf0436186d170d2b666b1e75a1973b91d802dbb7affe03380dcd8fda11307dacf8b63385a456ed98d5d4f37191a57beeefc4d8a018ffa2ad9d39a8939f93
7
+ data.tar.gz: 4437d61665ceb29e5eb08633b13549a79d70371cc83a788b44e0a12e92a3450c500a47c1135fec32caae5dc046b98ab9618ac85c7780b103710f941a5975d826
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.1
data/Gemfile CHANGED
@@ -9,4 +9,4 @@ group :test do
9
9
  end
10
10
 
11
11
  gem "rake", "~> 12.0"
12
- gem 'rubocop', '~> 1.8', require: false
12
+ gem 'rubocop', '~> 1.8', require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swatchman (0.1.0)
4
+ swatchman (0.2.0)
5
5
  mini_magick (~> 4.11.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -24,8 +24,9 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- Swatchman will return 3 swatches by default. Specify the `swatches` named parameter to adjust the number of swatches returned.
27
+ Swatchman will return 3 swatches by default. Specify the `size` named parameter when calling the `palette` method to adjust the number of swatches returned.
28
28
 
29
+ `swatch` has a method for calculating the percentage which recieves one paramater being the `total` this can be retrieved through `palette.total`.
29
30
  ### From a URL
30
31
 
31
32
  ```ruby
@@ -15,6 +15,10 @@ module Swatchman
15
15
  end.reverse.slice(0, size)
16
16
  end
17
17
 
18
+ def total
19
+ @total ||= histogram_swatches.map(&:frequency).reduce(:+).to_f
20
+ end
21
+
18
22
  private
19
23
 
20
24
  attr_reader :histogram
@@ -26,9 +30,5 @@ module Swatchman
26
30
  Swatch.new(color, frequency.to_i)
27
31
  end
28
32
  end
29
-
30
- def total
31
- @total ||= histogram_swatches.map(&:frequency).reduce(:+).to_f
32
- end
33
33
  end
34
- end
34
+ end
@@ -6,5 +6,9 @@ module Swatchman
6
6
  @color = color.downcase
7
7
  @frequency = frequency
8
8
  end
9
+
10
+ def percentage(total)
11
+ (frequency / total) * 100
12
+ end
9
13
  end
10
- end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Swatchman
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swatchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Hill
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-11 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - ".gitignore"
36
+ - ".ruby-version"
36
37
  - ".travis.yml"
37
38
  - CODE_OF_CONDUCT.md
38
39
  - Gemfile