universalid 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +387 -1094
- data/Rakefile +16 -2
- data/config/default.yml +1 -1
- data/config/example.yml +2 -2
- data/lib/universalid/encoder.rb +21 -0
- data/lib/universalid/extensions/active_record/base_message_pack_type.rb +15 -0
- data/lib/universalid/extensions/active_record/base_packer.rb +170 -0
- data/lib/universalid/extensions/active_record/base_unpacker.rb +61 -0
- data/lib/universalid/extensions/active_record/relation_message_pack_type.rb +20 -0
- data/lib/universalid/extensions/active_support/time_with_zone_message_pack_type.rb +18 -0
- data/lib/universalid/extensions/global_id/global_id_model.rb +28 -0
- data/lib/universalid/extensions/global_id/global_id_uid_extension.rb +43 -0
- data/lib/universalid/extensions/global_id/message_pack_type.rb +16 -0
- data/lib/universalid/extensions/signed_global_id/message_pack_type.rb +12 -0
- data/lib/{universal_id → universalid}/message_pack_types/ruby/composites/open_struct.rb +2 -0
- data/lib/universalid/message_pack_types/ruby/scalars/bigdecimal.rb +10 -0
- data/lib/{universal_id → universalid}/message_pack_types/ruby/scalars/date.rb +2 -0
- data/lib/{universal_id → universalid}/message_pack_types/ruby/scalars/date_time.rb +2 -0
- data/lib/{universal_id → universalid}/message_pack_types.rb +3 -5
- data/lib/universalid/packer.rb +19 -0
- data/lib/{universal_id → universalid}/prepack_database_options.rb +4 -4
- data/lib/{universal_id → universalid}/prepack_options.rb +2 -12
- data/lib/{universal_id → universalid}/prepacker.rb +3 -3
- data/lib/{universal_id → universalid}/refinements/open_struct_refinement.rb +2 -0
- data/lib/universalid/refinements.rb +3 -0
- data/lib/{universal_id → universalid}/settings.rb +3 -2
- data/lib/{universal_id → universalid}/version.rb +1 -1
- data/lib/universalid.rb +28 -1
- data/lib/uri/uid.rb +17 -7
- metadata +128 -50
- data/lib/universal_id/contrib/active_record/base_message_pack_type.rb +0 -11
- data/lib/universal_id/contrib/active_record/base_packer.rb +0 -130
- data/lib/universal_id/contrib/active_record/base_unpacker.rb +0 -50
- data/lib/universal_id/contrib/active_record/relation_message_pack_type.rb +0 -16
- data/lib/universal_id/contrib/active_record.rb +0 -4
- data/lib/universal_id/contrib/active_support/time_with_zone_message_pack_type.rb +0 -14
- data/lib/universal_id/contrib/active_support.rb +0 -3
- data/lib/universal_id/contrib/global_id/global_id_model.rb +0 -24
- data/lib/universal_id/contrib/global_id/global_id_uid_extension.rb +0 -36
- data/lib/universal_id/contrib/global_id/message_pack_type.rb +0 -15
- data/lib/universal_id/contrib/global_id.rb +0 -3
- data/lib/universal_id/contrib/rails.rb +0 -6
- data/lib/universal_id/contrib/signed_global_id/message_pack_type.rb +0 -8
- data/lib/universal_id/contrib/signed_global_id.rb +0 -3
- data/lib/universal_id/encoder.rb +0 -27
- data/lib/universal_id/refinements.rb +0 -8
- data/lib/universal_id.rb +0 -29
- /data/lib/{universal_id → universalid}/message_pack_factory.rb +0 -0
- /data/lib/{universal_id → universalid}/message_pack_types/ruby/composites/module.rb +0 -0
- /data/lib/{universal_id → universalid}/message_pack_types/ruby/composites/set.rb +0 -0
- /data/lib/{universal_id → universalid}/message_pack_types/ruby/composites/struct.rb +0 -0
- /data/lib/{universal_id → universalid}/message_pack_types/ruby/scalars/complex.rb +0 -0
- /data/lib/{universal_id → universalid}/message_pack_types/ruby/scalars/range.rb +0 -0
- /data/lib/{universal_id → universalid}/message_pack_types/ruby/scalars/rational.rb +0 -0
- /data/lib/{universal_id → universalid}/message_pack_types/ruby/scalars/regexp.rb +0 -0
- /data/lib/{universal_id → universalid}/message_pack_types/uri/uid/type.rb +0 -0
- /data/lib/{universal_id → universalid}/refinements/array_refinement.rb +0 -0
- /data/lib/{universal_id → universalid}/refinements/hash_refinement.rb +0 -0
- /data/lib/{universal_id → universalid}/refinements/set_refinement.rb +0 -0
data/lib/universal_id/encoder.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "base64"
|
4
|
-
require "brotli"
|
5
|
-
|
6
|
-
# This module provides the ability to encode and decode objects into a compressed, URL-safe string
|
7
|
-
module UniversalID::Encoder
|
8
|
-
class << self
|
9
|
-
def encode(object, options = {})
|
10
|
-
object = UniversalID::Prepacker.prepack(object, options)
|
11
|
-
|
12
|
-
# This is basically the same call as UniversalID::MessagePackFactory.pack(object),
|
13
|
-
# but it uses a pool of pre-initialized packers/unpackers instead of creating a new one each time
|
14
|
-
packed = UniversalID::MessagePackFactory.msgpack_pool.dump(object)
|
15
|
-
deflated = Brotli.deflate(packed)
|
16
|
-
Base64.urlsafe_encode64 deflated, padding: false
|
17
|
-
end
|
18
|
-
|
19
|
-
def decode(string)
|
20
|
-
decoded = Base64.urlsafe_decode64(string)
|
21
|
-
inflated = Brotli.inflate(decoded)
|
22
|
-
# This is basically the same call as UniversalID::MessagePackFactory.unpack(object),
|
23
|
-
# but it uses a pool of pre-initialized packers/unpackers instead of creating a new one each time
|
24
|
-
UniversalID::MessagePackFactory.msgpack_pool.load inflated
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module UniversalID::Refinements; end
|
4
|
-
|
5
|
-
require_relative "refinements/array_refinement"
|
6
|
-
require_relative "refinements/hash_refinement"
|
7
|
-
require_relative "refinements/set_refinement"
|
8
|
-
require_relative "refinements/open_struct_refinement"
|
data/lib/universal_id.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "date"
|
4
|
-
require "forwardable"
|
5
|
-
require "ostruct"
|
6
|
-
require "uri"
|
7
|
-
|
8
|
-
module UniversalID
|
9
|
-
module Contrib; end
|
10
|
-
|
11
|
-
class << self
|
12
|
-
attr_writer :logger
|
13
|
-
|
14
|
-
def logger
|
15
|
-
@logger ||= defined?(Rails) ? Rails.logger : Logger.new(File::NULL)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
require_relative "universal_id/version"
|
21
|
-
require_relative "universal_id/refinements"
|
22
|
-
require_relative "universal_id/settings"
|
23
|
-
require_relative "universal_id/encoder"
|
24
|
-
require_relative "uri/uid"
|
25
|
-
require_relative "universal_id/prepacker"
|
26
|
-
require_relative "universal_id/prepack_options"
|
27
|
-
require_relative "universal_id/message_pack_factory"
|
28
|
-
|
29
|
-
UniversalID::Settings.instance # initialize settings
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|