snowflaked 0.1.0-aarch64-linux-musl → 0.1.2-aarch64-linux-musl

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: 69bbfce9d5ff1a78b595470bca7bea5b194b7b104bc4c785b9668f006de0032b
4
- data.tar.gz: 1b0724d4bc6b2486624eb6ee6181d8a72eaf38cf1d5f3380d8718ce6644d0482
3
+ metadata.gz: 9fe93aa2acf923164fb9f2ef7e7f695701e86b650c34ead37da03c77fe58be18
4
+ data.tar.gz: 476fbfb2ca896bc4ade99a1a9ac80437b2d4fcc32cad2ea052d227cfe2ade936
5
5
  SHA512:
6
- metadata.gz: 2980e4b2ffc4359f716263cbb547c84bdb16e62e236e3b8c766d56f0c031c9510d1289f6681000f0f0885cec38d2c7831126fe631571a6cc83048b27f5d20a75
7
- data.tar.gz: 11597bd7ac80f732b25736e33017707f0e9944131c37f56a5a7897dbdae2032ccd221be351b3693854185f85c68ab127822044af64b6425131acffa50197d663
6
+ metadata.gz: fe0a011a5cab72ae7013888941a5971208d01bbcf0aceedee8aff031c69f80b0fcfb640da8a398110bc44b4838515d69b6e0912bd25a18aa3d8d1d7b7a94cbf2
7
+ data.tar.gz: 1ff5e44f919e0a937ebf8cd68c296ed4915b744e1c68806807f18401adbb5c02dab3cf2044dfdac5336c051187cdb2e459c88be88390de81168191ea406ceee5
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Snowflaked
2
2
 
3
+ [![CI](https://github.com/luizkowalski/snowflaked/actions/workflows/ci.yml/badge.svg)](https://github.com/luizkowalski/snowflaked/actions/workflows/ci.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/snowflaked.svg)](https://badge.fury.io/rb/snowflaked)
5
+ [![Downloads](https://img.shields.io/gem/dt/snowflaked.svg)](https://rubygems.org/gems/snowflaked)
6
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
7
+
3
8
  A high-performance, thread-safe Snowflake ID generator for Ruby, powered by Rust.
4
9
 
5
10
  Snowflake IDs are 64-bit unique identifiers that encode a timestamp, machine ID, and sequence number. They're time-sortable (IDs created later are always larger), making them ideal for distributed systems where you need unique IDs without coordination between machines. Unlike UUIDs, Snowflake IDs are smaller, sortable, and index-friendly for databases.
@@ -38,16 +43,22 @@ class CreateUsers < ActiveRecord::Migration[8.1]
38
43
  def change
39
44
  create_table :users do |t|
40
45
  t.snowflake :external_id
46
+ t.bigint :uid
41
47
  end
42
48
  end
43
49
  end
44
50
  ```
45
51
 
52
+ Columns created with `t.snowflake` are automatically detected and will have Snowflake IDs generated for them.
53
+
54
+ > [!WARNING]
55
+ > SQLite does not support column comments, which Snowflaked uses to auto-detect snowflake columns other than `:id`. When using SQLite, you must explicitly declare snowflake columns using the `snowflake_id` helper in your model.
56
+
46
57
  If you want to generate Snowflake IDs for additional columns, you can do so by using the `snowflake_id` method, without having to migrate the table:
47
58
 
48
59
  ```ruby
49
60
  class User < ApplicationRecord
50
- snowflake_id :external_id
61
+ snowflake_id :uid
51
62
  end
52
63
  ```
53
64
 
@@ -72,7 +83,7 @@ end
72
83
  ```ruby
73
84
  Snowflaked.configure do |config|
74
85
  config.machine_id = 42
75
- config.epoch = Time.utc(2020, 1, 1)
86
+ config.epoch = Time.utc(1989, 1, 3) # When not configured, the epoch is set to the Unix epoch (January 1, 1970)
76
87
  end
77
88
  ```
78
89
 
Binary file
Binary file
Binary file
Binary file
@@ -19,7 +19,7 @@ module Snowflaked
19
19
  def _snowflake_columns_from_comments
20
20
  return [] unless table_exists?
21
21
 
22
- columns.select { |c| c.comment == Snowflaked::SchemaDefinitions::COMMENT }.map { |c| c.name.to_sym }
22
+ columns.filter_map { |col| col.name.to_sym if col.comment == Snowflaked::SchemaDefinitions::COMMENT }
23
23
  end
24
24
  end
25
25
 
@@ -4,18 +4,13 @@ module Snowflaked
4
4
  module SchemaDefinitions
5
5
  COMMENT = "snowflaked"
6
6
 
7
- module TableDefinition
8
- def snowflake(name, **options)
9
- options[:comment] = Snowflaked::SchemaDefinitions::COMMENT
10
- column(name, :snowflake, **options)
7
+ module SnowflakeColumn
8
+ def snowflake(name, **)
9
+ column(name, :snowflake, comment: COMMENT, **)
11
10
  end
12
11
  end
13
12
 
14
- module Table
15
- def snowflake(name, **options)
16
- options[:comment] = Snowflaked::SchemaDefinitions::COMMENT
17
- column(name, :snowflake, **options)
18
- end
19
- end
13
+ TableDefinition = SnowflakeColumn
14
+ Table = SnowflakeColumn
20
15
  end
21
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snowflaked
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/snowflaked.rb CHANGED
@@ -1,7 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "snowflaked/version"
4
- require_relative "snowflaked/snowflaked"
4
+
5
+ # Load precompiled extension for the current Ruby version
6
+ begin
7
+ ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION)
8
+ require "snowflaked/#{ruby_version}/snowflaked"
9
+ rescue LoadError
10
+ require "snowflaked/snowflaked"
11
+ end
12
+
5
13
  require "socket"
6
14
 
7
15
  require_relative "snowflaked/railtie" if defined?(Rails::Railtie)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snowflaked
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: aarch64-linux-musl
6
6
  authors:
7
7
  - Luiz Eduardo Kowalski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-08 00:00:00.000000000 Z
11
+ date: 2026-01-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby gem for generating Twitter Snowflake IDs using a high-performance
14
14
  Rust backend. Thread-safe with configurable machine ID and custom epoch support.