Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUID continuation #4453

Merged
merged 75 commits into from
Nov 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
3b1bae7
Add `UUID`.
mirek Jun 1, 2016
f0bb4d8
Rearrange structure to separate RFC4122 logic.
mirek Jun 2, 2016
a9019b6
Updates.
mirek Jun 3, 2016
cbfd749
Merge branch 'master' into uuid
mirek Aug 16, 2016
a2e23a3
Merge branch 'master' into uuid
mirek Oct 9, 2016
3d69d69
Merge remote-tracking branch 'origin/master' into uuid
May 23, 2017
133e84d
remove uuid from prelude; update for moden build for crystal
May 23, 2017
c6a9604
Merge remote-tracking branch 'origin/master' into uuid
May 23, 2017
0ca59d6
Use `should` and `eq` instead of checking against true
jkthorne May 24, 2017
2d881d9
fix typo
jkthorne May 24, 2017
e48a7d5
Doc fix
jkthorne May 24, 2017
a48e4fb
Change the implimintation of UUID::EMPTY
jkthorne May 25, 2017
64e64f7
Update Docs
jkthorne May 25, 2017
df3fd11
Merge branch 'master' into uuid
May 25, 2017
55ad17a
Change formatting form to_s to methods
May 26, 2017
c1cf14d
Merge branch 'uuid' of github.com:wontruefree/crystal into uuid
May 26, 2017
8295cfa
wip
May 26, 2017
b7c17f3
wip
May 30, 2017
c6b781c
remove trasition to Random
jkthorne May 31, 2017
8fee1b6
add bytes to initialize
jkthorne May 31, 2017
f72b57b
remove class level variant functions
jkthorne May 31, 2017
7139655
Merge branch 'master' into uuid
jkthorne May 31, 2017
f3fce3d
update hex pair check to use String std
Jun 1, 2017
dfbc0c1
Merge branch 'master' into uuid
jkthorne Jun 3, 2017
a71f569
Merge branch 'uuid' of github.com:wontruefree/crystal into uuid
jkthorne Jun 3, 2017
41302ca
Merge remote-tracking branch 'upstream/master' into uuid
Jun 6, 2017
0f7d36f
cleanup some code left over from wip
Jun 7, 2017
9242f73
Merge remote-tracking branch 'upstream/master' into uuid
Jun 9, 2017
baa9277
move to initialize from new and be more explicit about the setup
Jun 9, 2017
e34308e
Merge branch 'uuid' of github.com:wontruefree/crystal into uuid
Jun 9, 2017
5dce117
Merge remote-tracking branch 'upstream/master' into uuid
Jun 20, 2017
ad9a37f
Merge remote-tracking branch 'upstream/master' into uuid
Jun 23, 2017
509ff75
Merge remote-tracking branch 'upstream/master' into uuid
Jun 27, 2017
e55718d
Merge remote-tracking branch 'upstream/master' into uuid
Jul 5, 2017
4cfd90e
Merge remote-tracking branch 'upstream/master' into uuid
Jul 7, 2017
79f5b7d
Merge remote-tracking branch 'upstream/master' into uuid
Jul 28, 2017
7b4b9ad
condense uuid files
Jul 28, 2017
2cae97a
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Aug 6, 2017
f369a34
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Aug 8, 2017
b325f3d
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Aug 13, 2017
ac2d176
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Aug 24, 2017
9290bf7
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Sep 16, 2017
6044754
Move uuid functions into one file.
jkthorne Sep 16, 2017
627a8e1
linter
jkthorne Sep 17, 2017
cc14710
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Oct 8, 2017
8ff542e
remove secure_random
jkthorne Oct 8, 2017
8639668
linter
jkthorne Oct 8, 2017
8d25980
remove Random uuid
jkthorne Oct 9, 2017
8062232
remove `<<` and extra `==` methods
jkthorne Oct 9, 2017
8f47d38
revert linter commits
jkthorne Oct 10, 2017
d79b51f
use safer copy for UUID initilaize
jkthorne Oct 10, 2017
9828bd7
add safer copy with slice intialize
jkthorne Oct 11, 2017
0366f78
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Oct 11, 2017
409fe5b
rework UUID intialize and add more tests
jkthorne Oct 12, 2017
e3bee29
change string to be made without unsafe methods
jkthorne Oct 12, 2017
49a6372
reorder methods and make to_slice safe
jkthorne Oct 17, 2017
17ddbbf
add specs for default initialize
jkthorne Oct 17, 2017
f282061
remove periods from comments
jkthorne Oct 20, 2017
a80ff09
remove periods from error messages
jkthorne Oct 20, 2017
b4f1340
remove whitespace
jkthorne Oct 21, 2017
4669f9a
revert comment changes
jkthorne Oct 21, 2017
1c3e811
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Oct 22, 2017
3addefc
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Oct 27, 2017
30db4ad
changing to Random for performance
jkthorne Oct 27, 2017
eec5ece
Revert "changing to Random for performance"
jkthorne Oct 27, 2017
494d20b
add random over new
jkthorne Oct 27, 2017
6a25156
move class methods together
jkthorne Oct 27, 2017
264f729
Merge remote-tracking branch 'upstream/master' into uuid
jkthorne Oct 30, 2017
6a143fa
change uuid to use secure random
jkthorne Oct 30, 2017
1c8db2b
Make UUID immutable, and not overwrite the version and variant
RX14 Nov 7, 2017
3712820
Docs fixes
RX14 Nov 7, 2017
f6f6070
Add constructor to initialize from UUID
RX14 Nov 8, 2017
122f84b
Remove magic equality with String
RX14 Nov 8, 2017
c496177
UUID#to_s cleanup
RX14 Nov 8, 2017
9c49e7b
Clarify doc for UUID.new(UUID, ...)
RX14 Nov 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions spec/std/uuid_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ describe "UUID" do
end

it "can be built from strings" do
UUID.new("c20335c3-7f46-4126-aae9-f665434ad12b").should eq("c20335c3-7f46-4126-aae9-f665434ad12b")
UUID.new("c20335c37f464126aae9f665434ad12b").should eq("c20335c3-7f46-4126-aae9-f665434ad12b")
UUID.new("C20335C3-7F46-4126-AAE9-F665434AD12B").should eq("c20335c3-7f46-4126-aae9-f665434ad12b")
UUID.new("C20335C37F464126AAE9F665434AD12B").should eq("c20335c3-7f46-4126-aae9-f665434ad12b")
UUID.new("urn:uuid:1ed1ee2f-ef9a-4f9c-9615-ab14d8ef2892").should eq("1ed1ee2f-ef9a-4f9c-9615-ab14d8ef2892")
UUID.new("c20335c3-7f46-4126-aae9-f665434ad12b").to_s.should eq("c20335c3-7f46-4126-aae9-f665434ad12b")
UUID.new("c20335c37f464126aae9f665434ad12b").to_s.should eq("c20335c3-7f46-4126-aae9-f665434ad12b")
UUID.new("C20335C3-7F46-4126-AAE9-F665434AD12B").to_s.should eq("c20335c3-7f46-4126-aae9-f665434ad12b")
UUID.new("C20335C37F464126AAE9F665434AD12B").to_s.should eq("c20335c3-7f46-4126-aae9-f665434ad12b")
UUID.new("urn:uuid:1ed1ee2f-ef9a-4f9c-9615-ab14d8ef2892").to_s.should eq("1ed1ee2f-ef9a-4f9c-9615-ab14d8ef2892")
end
end

Expand Down Expand Up @@ -109,15 +109,6 @@ describe "UUID" do
it "urn" do
UUID.new("1ed1ee2f-ef9a-4f9c-9615-ab14d8ef2892").urn.should eq "urn:uuid:1ed1ee2f-ef9a-4f9c-9615-ab14d8ef2892"
end

it "compares to strings" do
uuid = UUID.new "c3b46146eb794e18877b4d46a10d1517"
uuid.should eq("c3b46146eb794e18877b4d46a10d1517")
uuid.should eq("c3b46146-eb79-4e18-877b-4d46a10d1517")
uuid.should eq("C3B46146-EB79-4E18-877B-4D46A10D1517")
uuid.should eq("urn:uuid:C3B46146-EB79-4E18-877B-4D46A10D1517")
uuid.should eq("urn:uuid:c3b46146-eb79-4e18-877b-4d46a10d1517")
end
end

it "fails on invalid arguments when creating" do
Expand Down
7 changes: 1 addition & 6 deletions src/uuid.cr
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,7 @@ struct UUID
@bytes.to_unsafe
end

# Returns `true` if `other` string represents the same UUID, `false` otherwise.
def ==(other : String)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this?

Copy link
Contributor

@RX14 RX14 Nov 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I said exactly my reasoning above, it's magic, and costly, and unexpected.

Considering also the constraint that x == y implies x.hash == y.hash then we'd have to implement hash using to_s too, which is costly even if you don't use this.

self == UUID.new other
end

# Returns `true` if `other` 16-byte slice represents the same UUID, `false` otherwise.
# Returns `true` if `other` UUID represents the same UUID, `false` otherwise.
def ==(other : UUID)
to_slice == other.to_slice
end
Expand Down