active_uxid 1.0.10 → 1.0.11

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
  SHA1:
3
- metadata.gz: f268252b89f510be74aee33cf4f05c3c7d42ed92
4
- data.tar.gz: 41a5e44b636ec6d8c93e9fe6a19228ecde6dc8f0
3
+ metadata.gz: 9562a3022031637a6274b83a1e2314c06bb15376
4
+ data.tar.gz: e9393cde490974f5929bd68ba32df0ef2b025dab
5
5
  SHA512:
6
- metadata.gz: 788be6648a7c161283f8296be871f09e4928990f9543dc90190f9998b068ae32aa897fc318e749165c6dd64282cdcf13751508fd52e54bd8ff4ff0c15482f357
7
- data.tar.gz: 1696f6915cb835be739f48c56bdf1a092669707270993438b075dafbbee6b00b50d4cfc6a01cf9ecab67e50d4c36a25d64f2b8b63f7ae6f64cd25469e9b8b180
6
+ metadata.gz: bedd95ff15abb5b98db5a3539fef901f3584abe6434339e51ca0e8a9ca0a67f169e02bc7895baf0542d41b1b7c7dceff00ae0ab2bfb7a85221d54bb5d674660b
7
+ data.tar.gz: 8f77b5888cf9f60e887ab4a20374b10a6cad55c5f823c4a253398534dfd0ef334db2d2f02706607a97e60fc3597aa196035eca1c8925b81c52b1b264e13234a3
data/lib/active_uxid.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- %w[version configuration].each do |file_name|
3
+ %w[version configuration base].each do |file_name|
4
4
  require "active_uxid/#{file_name}"
5
5
  end
6
6
 
7
- %w[base hash ulid].each_with_index do |file_name, i|
8
- require "active_uxid/record/#{file_name}" unless i.zero?
7
+ %w[hash ulid].each do |file_name|
8
+ require "active_uxid/record/#{file_name}"
9
9
  require "active_uxid/#{file_name}"
10
10
  end
11
11
 
@@ -3,9 +3,17 @@
3
3
  module ActiveUxid
4
4
  class Base
5
5
 
6
- ENCODING_CHARS ||= ActiveUxid.configuration.encoding_chars
7
- ENCODING_LENGTH = ActiveUxid.configuration.encoding_length
8
- ENCODING_SALT ||= ActiveUxid.configuration.encoding_salt
6
+ def initialize
7
+ @config = ActiveUxid.configuration
8
+ end
9
+
10
+ %w[encoding_chars encoding_length encoding_salt].each do |setting|
11
+ define_method(setting) { @config.send(setting) }
12
+ end
13
+
14
+ def encoding_base
15
+ encoding_chars.length
16
+ end
9
17
 
10
18
  end
11
19
  end
@@ -1,14 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveUxid
4
- class Ulid
5
-
6
- ENCODING_CHARS ||= ActiveUxid.configuration.encoding_chars
7
- ENCODING_LENGTH = ActiveUxid.configuration.encoding_length
8
-
9
- def initialize
10
- @encoding_length = ActiveUxid.configuration.encoding_length
11
- end
4
+ class Ulid < ActiveUxid::Base
12
5
 
13
6
  def self.encode
14
7
  klass = new
@@ -16,9 +9,9 @@ module ActiveUxid
16
9
  end
17
10
 
18
11
  def uxid_encode
19
- (1..@encoding_length).reduce('') do |str, num|
12
+ (1..encoding_length).reduce('') do |str, num|
20
13
  shift = 128 - 5 * num
21
- "#{str}#{ENCODING_CHARS[(uxid_octect >> shift) & 0x1f]}"
14
+ "#{str}#{encoding_chars[(uxid_octect >> shift) & 0x1f]}"
22
15
  end
23
16
  end
24
17
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRegulation
4
- VERSION ||= '1.0.10'
4
+ VERSION ||= '1.0.11'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_uxid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez