rbbb 0.1.0.pre.3

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.
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "time"
4
+
5
+ module RBBB
6
+ # Strict parsing and canonical serialization for authoritative UTC times.
7
+ module Timestamp
8
+ # Normative precision is one millisecond. Finer input is rejected rather
9
+ # than truncated so that a millisecond-native implementation replays the
10
+ # same command stream to the same closing times.
11
+ PRECISION_DIGITS = 3
12
+ NANOSECONDS_PER_UNIT = 10**(9 - PRECISION_DIGITS)
13
+
14
+ # Date, "T", time, optional fraction of at most PRECISION_DIGITS digits,
15
+ # and a mandatory zone designator. Ruby's Time.iso8601 silently treats a
16
+ # zone-less string as host-local time, which would let the host's TZ
17
+ # setting change auction outcomes.
18
+ FORMAT = /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,#{PRECISION_DIGITS}})?(?:Z|[+-]\d{2}:\d{2})\z/
19
+
20
+ module_function
21
+
22
+ def parse(value)
23
+ time = case value
24
+ when Time
25
+ value
26
+ when String
27
+ unless value.match?(FORMAT)
28
+ raise ArgumentError,
29
+ "timestamp must carry an explicit UTC offset and at most #{PRECISION_DIGITS} fractional digits"
30
+ end
31
+
32
+ Time.iso8601(value)
33
+ else
34
+ raise ArgumentError, "timestamp must be an ISO 8601 string or Time"
35
+ end
36
+
37
+ unless (time.nsec % NANOSECONDS_PER_UNIT).zero?
38
+ raise ArgumentError, "timestamp precision must not exceed #{PRECISION_DIGITS} fractional digits"
39
+ end
40
+
41
+ time.getutc.freeze
42
+ end
43
+
44
+ # Canonical form: UTC with "Z", the fraction omitted when zero and
45
+ # otherwise trimmed of trailing zeros, never more than PRECISION_DIGITS.
46
+ def dump(time)
47
+ return nil unless time
48
+
49
+ formatted = time.getutc.iso8601(PRECISION_DIGITS)
50
+ formatted.sub!(/0+Z\z/, "Z")
51
+ formatted.sub!(/\.Z\z/, "Z")
52
+ formatted
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RBBB
4
+ VERSION = "0.1.0.pre.3"
5
+ SPECIFICATION_VERSION = "0.1.0-draft"
6
+ RELEASE_STATUS = "experimental"
7
+ end
data/lib/rbbb.rb ADDED
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rbbb/version"
4
+
5
+ # Namespace for the R Triple B Ruby reference implementation.
6
+ module RBBB
7
+ # Largest integer any RFC 0001 field may carry: 2**53 - 1. It is the largest
8
+ # integer that is exact in all of JSON, IEEE 754 doubles, and 64-bit
9
+ # integers, so every conforming implementation can represent every value.
10
+ # Amounts, versions, priorities, and extension seconds all share it.
11
+ MAX_SAFE_INTEGER = (2**53) - 1
12
+
13
+ class Error < StandardError; end
14
+ class InvalidConfiguration < Error; end
15
+ class InvalidMoney < Error; end
16
+ class InvalidState < Error; end
17
+ class UnsupportedFeature < Error; end
18
+ end
19
+
20
+ require_relative "rbbb/money"
21
+ require_relative "rbbb/increment_schedule"
22
+ require_relative "rbbb/timestamp"
23
+ require_relative "rbbb/configuration"
24
+ require_relative "rbbb/event"
25
+ require_relative "rbbb/decision"
26
+ require_relative "rbbb/state"
27
+ require_relative "rbbb/engine"
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbbb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre.3
5
+ platform: ruby
6
+ authors:
7
+ - R Triple B contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ description: |-
42
+ An evaluation build of the pure-Ruby reference implementation for the
43
+ language-neutral RBBB bidding specification. It is not production ready.
44
+ email:
45
+ - will@mclemoreauction.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files:
49
+ - README.md
50
+ - LICENSE
51
+ files:
52
+ - LICENSE
53
+ - README.md
54
+ - lib/rbbb.rb
55
+ - lib/rbbb/configuration.rb
56
+ - lib/rbbb/decision.rb
57
+ - lib/rbbb/engine.rb
58
+ - lib/rbbb/event.rb
59
+ - lib/rbbb/increment_schedule.rb
60
+ - lib/rbbb/money.rb
61
+ - lib/rbbb/state.rb
62
+ - lib/rbbb/timestamp.rb
63
+ - lib/rbbb/version.rb
64
+ homepage: https://github.com/willtmc/rbbb
65
+ licenses:
66
+ - MIT
67
+ metadata:
68
+ allowed_push_host: https://rubygems.org
69
+ bug_tracker_uri: https://github.com/willtmc/rbbb/issues
70
+ changelog_uri: https://github.com/willtmc/rbbb/blob/v0.1.0.pre.3/CHANGELOG.md
71
+ documentation_uri: https://github.com/willtmc/rbbb/blob/v0.1.0.pre.3/ruby/engine/README.md
72
+ homepage_uri: https://github.com/willtmc/rbbb
73
+ rbbb_release_status: experimental
74
+ rbbb_rfc: '0001'
75
+ rbbb_specification_version: 0.1.0-draft
76
+ rubygems_mfa_required: 'true'
77
+ source_code_uri: https://github.com/willtmc/rbbb/tree/v0.1.0.pre.3/ruby/engine
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '3.2'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">"
90
+ - !ruby/object:Gem::Version
91
+ version: 1.3.1
92
+ requirements: []
93
+ rubygems_version: 3.4.19
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Experimental Ruby reference engine for deterministic auction bidding
97
+ test_files: []