ciql 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ciql/uuid.rb +43 -0
- data/lib/ciql/version.rb +1 -1
- data/lib/ciql.rb +1 -0
- data/spec/ciql/uuid_spec.rb +29 -0
- metadata +15 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b51cce24db2606ed0a9b683e21549063ced9d7b
|
4
|
+
data.tar.gz: 3a844e684f3e9262033249c4ee68ef236ea13cc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46aa844c42a01f8a98177fe4afa8450f154296fded7667341f0f370ff0bd778568dc9d105a893cd8da5108aee5b701d4a8bc5b38720c1cad209828426b0c9348
|
7
|
+
data.tar.gz: c5e4cc303e0df7d73001cadf5522cddbeff0254473a57f599e93d5cad07e1bce174895c63ed39a56d5aa6bcce93bded642d4ce6a8de6d4a0872ca59d543d8af1
|
data/lib/ciql/uuid.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'simple_uuid'
|
2
|
+
|
3
|
+
module Ciql
|
4
|
+
module UUID
|
5
|
+
|
6
|
+
# Create a fake time UUID that sorts as the smallest for a timestamp
|
7
|
+
#
|
8
|
+
# @param [Time] time
|
9
|
+
#
|
10
|
+
# @return [SimpleUUID::UUID]
|
11
|
+
def self.starting(time)
|
12
|
+
create_uuid(time.stamp * 10, 0x8080808080808080)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Create a fake time UUID that sorts as the largest for a timestamp
|
16
|
+
#
|
17
|
+
# @param [Time] time
|
18
|
+
#
|
19
|
+
# @return [SimpleUUID::UUID]
|
20
|
+
def self.ending(time)
|
21
|
+
create_uuid((time.stamp + 1) * 10 - 1, 0x7f7f7f7f7f7f7f7f)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# Create a new UUID
|
27
|
+
#
|
28
|
+
# @param [Fixnum] time, as 0.1 us since unix epoch
|
29
|
+
# @param [Fixnum] seq_and_node
|
30
|
+
#
|
31
|
+
# @return [SimpleUUID::UUID]
|
32
|
+
def self.create_uuid(time, seq_and_node)
|
33
|
+
time += SimpleUUID::UUID::GREGORIAN_EPOCH_OFFSET
|
34
|
+
bytes = [
|
35
|
+
time & 0xFFFF_FFFF,
|
36
|
+
time >> 32,
|
37
|
+
((time >> 48) & 0x0FFF) | 0x1000,
|
38
|
+
seq_and_node.to_s.unpack('NN')
|
39
|
+
].flatten
|
40
|
+
SimpleUUID::UUID.new(bytes.pack('NnnNN'))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/ciql/version.rb
CHANGED
data/lib/ciql.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ciql::UUID do
|
4
|
+
let(:time) { Time.parse('2014-3-17 9:45:12.123456 PST') }
|
5
|
+
|
6
|
+
describe '.starting' do
|
7
|
+
subject { described_class.starting(time) }
|
8
|
+
|
9
|
+
it 'returns the expected UUID for a starting time' do
|
10
|
+
subject.to_guid.should eq 'e3c8da80-adfb-11e3-3932-353935343231'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'encodes the time correctly' do
|
14
|
+
subject.to_time.should eq time
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.ending' do
|
19
|
+
subject { described_class.ending(time) }
|
20
|
+
|
21
|
+
it 'returns the expected UUID for an ending time' do
|
22
|
+
subject.to_guid.should eq 'e3c8da89-adfb-11e3-3931-383732303139'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'encodes the time correctly' do
|
26
|
+
subject.to_time.should eq time
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ciql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Bradford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cql-rb
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.1.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.1.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: simple_uuid
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.4.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.4.0
|
41
41
|
description: A CQL-based Cassandra client for Ruby
|
@@ -45,19 +45,21 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- README.md
|
49
|
+
- lib/ciql.rb
|
48
50
|
- lib/ciql/client/binary.rb
|
49
51
|
- lib/ciql/client/log.rb
|
50
52
|
- lib/ciql/client/thrift.rb
|
51
53
|
- lib/ciql/configuration.rb
|
52
54
|
- lib/ciql/rails.rb
|
53
55
|
- lib/ciql/sanitize.rb
|
56
|
+
- lib/ciql/uuid.rb
|
54
57
|
- lib/ciql/version.rb
|
55
|
-
- lib/ciql.rb
|
56
|
-
- README.md
|
57
58
|
- spec/ciql/client/binary_spec.rb
|
58
59
|
- spec/ciql/client/thrift_spec.rb
|
59
60
|
- spec/ciql/configuration_spec.rb
|
60
61
|
- spec/ciql/sanitize_spec.rb
|
62
|
+
- spec/ciql/uuid_spec.rb
|
61
63
|
- spec/spec_helper.rb
|
62
64
|
homepage: https://github.com/nulu/ciql
|
63
65
|
licenses:
|
@@ -69,17 +71,17 @@ require_paths:
|
|
69
71
|
- lib
|
70
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
73
|
requirements:
|
72
|
-
- -
|
74
|
+
- - ">="
|
73
75
|
- !ruby/object:Gem::Version
|
74
76
|
version: 1.9.2
|
75
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
78
|
requirements:
|
77
|
-
- -
|
79
|
+
- - ">="
|
78
80
|
- !ruby/object:Gem::Version
|
79
81
|
version: '0'
|
80
82
|
requirements: []
|
81
83
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.0
|
84
|
+
rubygems_version: 2.2.0
|
83
85
|
signing_key:
|
84
86
|
specification_version: 4
|
85
87
|
summary: CQL Cassandra client for Ruby
|
@@ -88,4 +90,6 @@ test_files:
|
|
88
90
|
- spec/ciql/client/thrift_spec.rb
|
89
91
|
- spec/ciql/configuration_spec.rb
|
90
92
|
- spec/ciql/sanitize_spec.rb
|
93
|
+
- spec/ciql/uuid_spec.rb
|
91
94
|
- spec/spec_helper.rb
|
95
|
+
has_rdoc:
|