ulid 1.1.1 → 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: 230543f0c4e5df603c672392ff904ee3d7750c3aef49191afe747b0fd897d9a8
4
- data.tar.gz: e36bc8ed67aae24ab46e96d6a17de084c4f1a387a5f1d9527422d3e64be23439
3
+ metadata.gz: c6d32b5f061971e975a65735d0d99c70c5c881e025d3e53325414d010f54d8f8
4
+ data.tar.gz: 1dae11d7a1c57c7851ab29269d9fb7319c5af028e43ee0438a4b9d578fac7589
5
5
  SHA512:
6
- metadata.gz: e7ca4e1e1abbc036fe57fdaa0d4195b7f90bc39c0db58a1cc4b51578b3527d92980e49aee197743ff641cf20112aa9afce60f9f265bced12b73b7e4e0f7c4c06
7
- data.tar.gz: 809c3242b413c8e52397350fb4f36c71cb1b59f3a70054ad72c1ea2a713e5373ed9f9231a29a2329999c33430cdd2a5a4f9c4f728a1715f587faba2ee61b5b8e
6
+ metadata.gz: fb53e67529dedec160c2fa2d80cd905874835ab545b2bfa769bc3fbf235f06e0c53051d90801ef11f1239efced45548820b5babd74b912f98af5d228d14c1995
7
+ data.tar.gz: c1dcd2873822f7524b4644aee637f1f32e88736a816aa6d9dbe036cadf1480d1c92901fee6e98318977d08c697f8c16ef122ce37e78b0d12c805ca4fb6dd6771
@@ -4,7 +4,10 @@ Style/Documentation:
4
4
  Style/TrailingCommaInArguments:
5
5
  EnforcedStyleForMultiline: comma
6
6
 
7
- Style/TrailingCommaInLiteral:
7
+ Style/TrailingCommaInArrayLiteral:
8
+ EnforcedStyleForMultiline: comma
9
+
10
+ Style/TrailingCommaInHashLiteral:
8
11
  EnforcedStyleForMultiline: comma
9
12
 
10
13
  Metrics/AbcSize:
@@ -19,5 +22,5 @@ Metrics/LineLength:
19
22
  Metrics/MethodLength:
20
23
  Enabled: false
21
24
 
22
- Lint/RescueWithoutErrorClass:
25
+ Style/RescueStandardError:
23
26
  Enabled: false
@@ -1,17 +1,21 @@
1
+ # 1.2.0
2
+
3
+ - PR #20 - Use an array to improve speed / reduce memory allocations. Thanks, @jamescook
4
+
1
5
  # 1.1.1
2
6
 
3
- - PR #19 - Remove Timecop gem
7
+ - PR #19 - Remove Timecop gem. Thanks, @bquorning
4
8
 
5
- - PR #18 - Remove Mocha gem
9
+ - PR #18 - Remove Mocha gem. Thanks, @bquorning
6
10
 
7
11
  - PR #17 - Add post_install_message to install sysrandom gem
8
12
 
9
- - PR #16 - Remove circular require warning
13
+ - PR #16 - Remove circular require warning. Thanks, @pocke
10
14
 
11
15
  # 1.1.0
12
16
 
13
- - PR #14 - Ruby 2.5+ does not need sysrandom
17
+ - PR #14 - Ruby 2.5+ does not need sysrandom. Thanks, @sakuro
14
18
 
15
19
  # 1.0.0
16
20
 
17
- - PR #10 - Fix time encoding by @dcuddeback
21
+ - PR #10 - Fix time encoding. Thanks, @dcuddeback
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ulid (1.1.0)
4
+ ulid (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
+ ![Ruby](https://github.com/rafaelsales/ulid/workflows/Ruby/badge.svg)
2
+ [![Gem Downloads](http://img.shields.io/gem/dt/ulid.svg)](https://rubygems.org/gems/ulid)
3
+ [![GitHub License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/rafaelsales/ulid)
4
+
1
5
  # ulid
2
6
  Universally Unique Lexicographically Sortable Identifier implementation for Ruby
3
7
 
8
+ Official specification page: https://github.com/ulid/spec
9
+
4
10
  <h1 align="center">
5
11
  <br>
6
12
  <br>
@@ -10,10 +16,6 @@ Universally Unique Lexicographically Sortable Identifier implementation for Ruby
10
16
  <br>
11
17
  </h1>
12
18
 
13
- ![Ruby](https://github.com/rafaelsales/ulid/workflows/Ruby/badge.svg)
14
- [![Gem Downloads](http://img.shields.io/gem/dt/ulid.svg)](https://rubygems.org/gems/ulid)
15
- [![GitHub License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/rafaelsales/ulid)
16
-
17
19
  # Universally Unique Lexicographically Sortable Identifier
18
20
 
19
21
  UUID can be suboptimal for many uses-cases because:
@@ -1,3 +1,5 @@
1
+ # frozen-string-literal: true
2
+
1
3
  if RUBY_VERSION >= '2.5'
2
4
  require 'securerandom'
3
5
  else
@@ -6,11 +8,12 @@ end
6
8
 
7
9
  module ULID
8
10
  module Generator
9
- ENCODING = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'.freeze # Crockford's Base32
11
+ ENCODING = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'.bytes.freeze # Crockford's Base32
10
12
  RANDOM_BYTES = 10
11
13
  ENCODED_LENGTH = 26
12
14
  BIT_LENGTH = 128
13
15
  BITS_PER_B32_CHAR = 5
16
+ ZERO = '0'.ord
14
17
 
15
18
  MASK = 0x1f
16
19
 
@@ -26,17 +29,17 @@ module ULID
26
29
 
27
30
  private
28
31
 
29
- def encode(n, length)
30
- e = '0' * length
32
+ def encode(input, length)
33
+ e = Array.new(length, ZERO)
31
34
  i = length - 1
32
35
 
33
- while n > 0
34
- e[i] = ENCODING[n & MASK]
35
- n >>= 5
36
+ while input > 0
37
+ e[i] = ENCODING[input & MASK]
38
+ input >>= 5
36
39
  i -= 1
37
40
  end
38
41
 
39
- e
42
+ e.pack('c*')
40
43
  end
41
44
 
42
45
  def octo_word(time = Time.now)
@@ -1,3 +1,3 @@
1
1
  module ULID
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -10,7 +10,6 @@ describe ULID do
10
10
  end
11
11
 
12
12
  it 'is sortable' do
13
- ulid1, ulid2 = nil
14
13
  input_time = Time.now
15
14
  ulid1 = ULID.generate(input_time)
16
15
  ulid2 = ULID.generate(input_time + 1)
@@ -1,5 +1,4 @@
1
-
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'ulid/version'
5
4
 
@@ -17,8 +16,8 @@ Gem::Specification.new do |spec|
17
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
17
  spec.require_paths = ['lib']
19
18
 
20
- spec.post_install_message = %q[
19
+ spec.post_install_message = '
21
20
  ulid gem needs to install sysrandom gem if you use Ruby 2.4 or older.
22
21
  Execute `gem install sysrandom` or add `gem "sysrandom"` to Gemfile.
23
- ]
22
+ '
24
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ulid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Sales
@@ -17,8 +17,6 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".circleci/config.yml"
21
- - ".github/workflows/gempush.yml"
22
20
  - ".github/workflows/ruby.yml"
23
21
  - ".gitignore"
24
22
  - ".rubocop.yml"
@@ -1,50 +0,0 @@
1
- # Ruby CircleCI 2.0 configuration file
2
- #
3
- # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
- #
5
- version: 2
6
- jobs:
7
- build:
8
- docker:
9
- # specify the version you desire here
10
- - image: circleci/2.5.3-stretch
11
-
12
- working_directory: ~/repo
13
-
14
- steps:
15
- - checkout
16
-
17
- # Download and cache dependencies
18
- - restore_cache:
19
- keys:
20
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
21
- # fallback to using the latest cache if no exact match is found
22
- - v1-dependencies-
23
-
24
- - run:
25
- name: install dependencies
26
- command: |
27
- bundle install --jobs=4 --retry=3 --path vendor/bundle
28
-
29
- - save_cache:
30
- paths:
31
- - ./vendor/bundle
32
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
33
-
34
- # run tests!
35
- - run:
36
- name: run tests
37
- command: |
38
- mkdir /tmp/test-results
39
- TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
40
- circleci tests split --split-by=timings)"
41
-
42
- bundle exec test
43
- $TEST_FILES
44
-
45
- # collect reports
46
- - store_test_results:
47
- path: /tmp/test-results
48
- - store_artifacts:
49
- path: /tmp/test-results
50
- destination: test-results
@@ -1,32 +0,0 @@
1
- name: Ruby Gem
2
-
3
- on:
4
- pull_request:
5
- branches:
6
- - master
7
- push:
8
- branches:
9
- - master
10
-
11
- jobs:
12
- build:
13
- name: Build + Publish
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v2
18
- - name: Set up Ruby 2.6
19
- uses: actions/setup-ruby@v1
20
- with:
21
- ruby-version: 2.6.x
22
-
23
- - name: Publish to RubyGems
24
- run: |
25
- mkdir -p $HOME/.gem
26
- touch $HOME/.gem/credentials
27
- chmod 0600 $HOME/.gem/credentials
28
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29
- gem build *.gemspec
30
- gem push *.gem
31
- env:
32
- GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}