active_uxid 1.0.3 → 1.0.4

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: 7c9e877324685040eaccc2853d70c73ebd63cf4f
4
- data.tar.gz: 37746f142994446134fd083d2afa48b1e5801b2c
3
+ metadata.gz: adba934e86aea61e08652d5d89ebe9f8a1b88141
4
+ data.tar.gz: 990e14ab42cc2ce10d8c9859db614f17fd93e5c2
5
5
  SHA512:
6
- metadata.gz: 69f643b10dfa00a01bcea7982ec826b29435a126a8fa46881f0a35352334cd6979baf76d6db168b68fba1927f2987b34d6c248895b0c7ba6aa794b07876d8e03
7
- data.tar.gz: e583c353c3efb0f1bb3f5102325658e26f98b5a5a2b6ac548f4d8d5448ab9e0db56fb735b2d992ae462fe58069f448afb652bb4b356910c559a5a26e5cf47a36
6
+ metadata.gz: 9fce81f1babe2f16126d0b2f8019d8c57704f95b17a5be066ca21641cac3834f7410305066a45ae6d8ea292893915a21af07c1fde56c3a1d1bb4e7ad0fa485da
7
+ data.tar.gz: 1bfc2e086ff1fce0325059c6ed55983eb4e90ad2e0c55b52a3565db535b11225005006da38ecaf5b9411322f0dab87f77d1f6f04c543142a41c1ac5bc2500c4c
data/README.md CHANGED
@@ -34,7 +34,7 @@ Or install it yourself as:
34
34
  `../config/initalizers/active_uxid.rb`
35
35
 
36
36
  ```ruby
37
- ActiveUxid::Settings.configure do |config|
37
+ ActiveUxid.configure do |config|
38
38
  config.encoding_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
39
39
  config.encoding_length = 26
40
40
  config.encoding_salt = 1369136
data/active_uxid.gemspec CHANGED
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_runtime_dependency 'activerecord'
26
26
  spec.add_runtime_dependency 'activesupport'
27
- spec.add_runtime_dependency 'dry-configurable'
28
27
 
29
28
  spec.add_development_dependency 'bundler'
30
29
  spec.add_development_dependency 'rake'
data/lib/active_uxid.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- %w[version settings].each do |file_name|
3
+ %w[version configuration].each do |file_name|
4
4
  require "active_uxid/#{file_name}"
5
5
  end
6
6
 
@@ -3,10 +3,9 @@
3
3
  module ActiveUxid
4
4
  class Base
5
5
 
6
- ENCODING_BASE ||= ActiveUxid::Settings.config.encoding_chars.length
7
- ENCODING_CHARS ||= ActiveUxid::Settings.config.encoding_chars
8
- ENCODING_LENGTH ||= ActiveUxid::Settings.config.encoding_length
9
- ENCODING_SALT ||= ActiveUxid::Settings.config.encoding_salt
6
+ ENCODING_CHARS ||= ActiveUxid.configuration.encoding_chars
7
+ ENCODING_LENGTH ||= ActiveUxid.configuration.encoding_length
8
+ ENCODING_SALT ||= ActiveUxid.configuration.encoding_salt
10
9
 
11
10
  end
12
11
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveUxid
4
+ class Configuration
5
+
6
+ attr_accessor :encoding_chars, :encoding_length, :encoding_salt
7
+
8
+ def initialize
9
+ @encoding_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
10
+ @encoding_length = 26
11
+ @encoding_salt = 1369136
12
+ end
13
+
14
+ end
15
+
16
+ def self.configuration
17
+ @configuration ||= Configuration.new
18
+ end
19
+
20
+ def self.configuration=(config)
21
+ @configuration = config
22
+ end
23
+
24
+ def self.configure
25
+ yield(configuration)
26
+ end
27
+
28
+ end
@@ -3,6 +3,8 @@
3
3
  module ActiveUxid
4
4
  class Hash < ActiveUxid::Base
5
5
 
6
+ ENCODING_BASE ||= ENCODING_CHARS.length
7
+
6
8
  def initialize(id)
7
9
  @id = id
8
10
  end
@@ -13,7 +13,7 @@ module ActiveUxid
13
13
  def uxid_encode
14
14
  (1..ENCODING_LENGTH).reduce('') do |str, num|
15
15
  shift = 128 - 5 * num
16
- str + ENCODING_CHARS[(uxid_octect >> shift) & 0x1f]
16
+ "#{str}#{ENCODING_CHARS[(uxid_octect >> shift) & 0x1f]}"
17
17
  end
18
18
  end
19
19
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRegulation
4
- VERSION ||= '1.0.3'
4
+ VERSION ||= '1.0.4'
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ActiveUxid::Settings.configure do |config|
3
+ ActiveUxid.configure do |config|
4
4
  config.encoding_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
5
5
  config.encoding_length = 26
6
6
  config.encoding_salt = 1369136
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.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: dry-configurable
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -195,17 +181,16 @@ files:
195
181
  - Gemfile
196
182
  - README.md
197
183
  - Rakefile
198
- - _config.yml
199
184
  - active_uxid.gemspec
200
185
  - bin/console
201
186
  - bin/rake
202
187
  - bin/setup
203
188
  - lib/active_uxid.rb
204
189
  - lib/active_uxid/base.rb
190
+ - lib/active_uxid/configuration.rb
205
191
  - lib/active_uxid/hash.rb
206
192
  - lib/active_uxid/record/hash.rb
207
193
  - lib/active_uxid/record/ulid.rb
208
- - lib/active_uxid/settings.rb
209
194
  - lib/active_uxid/ulid.rb
210
195
  - lib/active_uxid/version.rb
211
196
  - lib/generators/active_uxid/install_generator.rb
data/_config.yml DELETED
@@ -1 +0,0 @@
1
- theme: jekyll-theme-cayman
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'dry-configurable'
4
-
5
- module ActiveUxid
6
- class Settings
7
- extend Dry::Configurable
8
-
9
- setting :encoding_chars, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
10
- setting :encoding_length, 26
11
- setting :encoding_salt, 1369136
12
-
13
- end
14
- end