boring_avatar 1.1.0 → 1.2.0

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
  SHA256:
3
- metadata.gz: 4b35dafd67e8e5a4aa93d5bcb6add2cef21edb46c9b40006ab8d2c64d2fecb50
4
- data.tar.gz: 9f6302fcd596af87ece50f1a9432418d984ce20ab1570b998daa206f278b41ba
3
+ metadata.gz: 3d151685da16183ab2eb32f482d6840817b361f5fcd35235d8f880b3ed0cb7ca
4
+ data.tar.gz: 5eb897db226b9d5471967a7804a622e7c1c05dc505bb6b910209feff1acc1891
5
5
  SHA512:
6
- metadata.gz: ce9657797944976cbea5e2b27d2eaaf6cb55e063794b335459fad009f3760d2f0e48994f222fab691406f4d9ce6cf0010f602d23dce2b6fa34663cccff89985c
7
- data.tar.gz: 3d034ce1f618e2289c084f56bb558aac19f5b9b6209d442a7b56b0599dea30c3d5f818b591e4757455c7424717dd2c5fe3dd45c314bf68f524baf7b2829e1903
6
+ metadata.gz: c133b5572416f5db3a7c2febe146d87cec5e6aa93663292b2cc09c7c9d0fecf48527f5f47c8c887cae52127873c8f1c543bb8a18bff72f1466124c41fde58dfc
7
+ data.tar.gz: f6c922f0e84380775cc038afb15e6bfef2a5b079171e54f85841f381e9320c7664135d9b45aefb2b96e7afac2a5256e8f5280d47cfde448d76625323be8cbab1
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.0.1
1
+ ruby 3.3.4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0 / 2024-08-02
4
+
5
+ - Use same number generation algorithm as JS implementation by @andriusch
6
+
7
+ ## 1.1.1 / 2023-06-30
8
+
9
+ - Fix for Beam avatar when random color was nil
10
+
3
11
  ## 1.1.0 / 2023-06-27
4
12
 
5
13
  - Ensure default options are set when nil
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boring_avatar (1.1.0)
4
+ boring_avatar (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -11,6 +11,7 @@ GEM
11
11
 
12
12
  PLATFORMS
13
13
  arm64-darwin-21
14
+ arm64-darwin-23
14
15
  x86_64-darwin-19
15
16
  x86_64-darwin-20
16
17
  x86_64-linux
@@ -21,7 +21,7 @@ module BoringAvatar
21
21
  @size = size.nil? ? SIZE : size
22
22
  @opts = opts
23
23
  @num_from_name = Util.get_number(name)
24
- @range = colors.length
24
+ @range = @colors.length
25
25
  end
26
26
 
27
27
  def generate
@@ -4,14 +4,15 @@ require "json"
4
4
 
5
5
  module Util
6
6
  class << self
7
- def get_number(name)
8
- name.chars
9
- .map(&:ord)
10
- .inject(:+)
7
+ def get_number(string)
8
+ string.chars.reduce(0) do |sum, char|
9
+ sum = (sum << 5) - sum + char.ord
10
+ [sum].pack("L").unpack("l").first
11
+ end.abs
11
12
  end
12
13
 
13
14
  def get_random_color(colors, number, range)
14
- colors[number % range]
15
+ colors[number % range] || colors.last
15
16
  end
16
17
 
17
18
  def get_unit(number, range, index = nil)
@@ -1,3 +1,3 @@
1
1
  module BoringAvatar
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boring_avatar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-27 00:00:00.000000000 Z
11
+ date: 2024-08-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a simple Ruby implementation of Boring Avatars library
14
14
  email:
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  requirements: []
64
- rubygems_version: 3.2.15
64
+ rubygems_version: 3.5.16
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Generate Boring Avatars