jylis-rb 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -4
- data/doc/Jylis.html +43 -39
- data/doc/Jylis/Connection.html +1 -1
- data/doc/Jylis/Connection/HostMissingError.html +1 -1
- data/doc/Jylis/Connection/UnsupportedSchemaError.html +1 -1
- data/doc/Jylis/DataType.html +1 -1
- data/doc/Jylis/DataType/Base.html +1 -1
- data/doc/Jylis/DataType/GCOUNT.html +1 -1
- data/doc/Jylis/DataType/MVREG.html +1 -1
- data/doc/Jylis/DataType/PNCOUNT.html +1 -1
- data/doc/Jylis/DataType/TLOG.html +97 -53
- data/doc/Jylis/DataType/TLOG/Result.html +1 -1
- data/doc/Jylis/DataType/TLOG/Row.html +167 -1
- data/doc/Jylis/DataType/TREG.html +38 -16
- data/doc/Jylis/DataType/TREG/Result.html +167 -1
- data/doc/Jylis/DataType/UJSON.html +1 -1
- data/doc/Jylis/Helpers.html +115 -0
- data/doc/Jylis/Helpers/Timestamp.html +288 -0
- data/doc/_index.html +1 -1
- data/doc/file.README.html +26 -5
- data/doc/file.license.html +1 -1
- data/doc/index.html +26 -5
- data/doc/method_list.html +32 -0
- data/doc/top-level-namespace.html +1 -1
- data/lib/jylis-rb/data_types/tlog.rb +18 -2
- data/lib/jylis-rb/data_types/treg.rb +14 -1
- data/lib/jylis-rb/jylis.rb +2 -0
- data/lib/jylis-rb/version.rb +1 -1
- metadata +4 -2
data/doc/file.license.html
CHANGED
@@ -60,7 +60,7 @@
|
|
60
60
|
<div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2018 Alex McLain<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the "Software"), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.</div></div>
|
61
61
|
|
62
62
|
<div id="footer">
|
63
|
-
Generated on
|
63
|
+
Generated on Tue Jun 5 17:01:51 2018 by
|
64
64
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
65
65
|
0.9.14 (ruby-2.5.1).
|
66
66
|
</div>
|
data/doc/index.html
CHANGED
@@ -118,7 +118,7 @@ $ cd jylis-rb
|
|
118
118
|
|
119
119
|
<p>Ensure the tests pass:</p>
|
120
120
|
|
121
|
-
<pre class="code ruby"><code class="ruby">$ rake
|
121
|
+
<pre class="code ruby"><code class="ruby">$ bundle exec rake
|
122
122
|
</code></pre>
|
123
123
|
|
124
124
|
<p>Install the gem from the working source code:</p>
|
@@ -258,9 +258,9 @@ for the exact format of your particular query.</p>
|
|
258
258
|
<p>Unordered JSON
|
259
259
|
<sup>[link[https://jemc.github.io/jylis/docs/types/ujson/]]</sup></p>
|
260
260
|
|
261
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_ujson'><span class='object_link'><a href="Jylis.html#ujson-class_method" title="Jylis.ujson (method)">ujson</a></span></span><span class='period'>.</span><span class='id identifier rubyid_set'><span class='object_link'><a href="Jylis/DataType/UJSON.html#set-instance_method" title="Jylis::DataType::UJSON#set (method)">set</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>users</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>alice</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>admin</span><span class='
|
262
|
-
<span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_ujson'><span class='object_link'><a href="Jylis.html#ujson-class_method" title="Jylis.ujson (method)">ujson</a></span></span><span class='period'>.</span><span class='id identifier rubyid_set'><span class='object_link'><a href="Jylis/DataType/UJSON.html#set-instance_method" title="Jylis::DataType::UJSON#set (method)">set</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>users</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>brett</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>admin</span><span class='
|
263
|
-
<span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_ujson'><span class='object_link'><a href="Jylis.html#ujson-class_method" title="Jylis.ujson (method)">ujson</a></span></span><span class='period'>.</span><span class='id identifier rubyid_set'><span class='object_link'><a href="Jylis/DataType/UJSON.html#set-instance_method" title="Jylis::DataType::UJSON#set (method)">set</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>users</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>carol</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>admin</span><span class='
|
261
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_ujson'><span class='object_link'><a href="Jylis.html#ujson-class_method" title="Jylis.ujson (method)">ujson</a></span></span><span class='period'>.</span><span class='id identifier rubyid_set'><span class='object_link'><a href="Jylis/DataType/UJSON.html#set-instance_method" title="Jylis::DataType::UJSON#set (method)">set</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>users</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>alice</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>admin</span><span class='label_end'>":</span> <span class='kw'>false</span><span class='rbrace'>}</span>
|
262
|
+
<span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_ujson'><span class='object_link'><a href="Jylis.html#ujson-class_method" title="Jylis.ujson (method)">ujson</a></span></span><span class='period'>.</span><span class='id identifier rubyid_set'><span class='object_link'><a href="Jylis/DataType/UJSON.html#set-instance_method" title="Jylis::DataType::UJSON#set (method)">set</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>users</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>brett</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>admin</span><span class='label_end'>":</span> <span class='kw'>false</span><span class='rbrace'>}</span>
|
263
|
+
<span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_ujson'><span class='object_link'><a href="Jylis.html#ujson-class_method" title="Jylis.ujson (method)">ujson</a></span></span><span class='period'>.</span><span class='id identifier rubyid_set'><span class='object_link'><a href="Jylis/DataType/UJSON.html#set-instance_method" title="Jylis::DataType::UJSON#set (method)">set</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>users</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>carol</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>admin</span><span class='label_end'>":</span> <span class='kw'>true</span><span class='rbrace'>}</span>
|
264
264
|
|
265
265
|
<span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_ujson'><span class='object_link'><a href="Jylis.html#ujson-class_method" title="Jylis.ujson (method)">ujson</a></span></span><span class='period'>.</span><span class='id identifier rubyid_get'><span class='object_link'><a href="Jylis/DataType/UJSON.html#get-instance_method" title="Jylis::DataType::UJSON#get (method)">get</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>users</span><span class='tstring_end'>"</span></span>
|
266
266
|
<span class='comment'># => {"brett"=>{"admin"=>false}, "carol"=>{"admin"=>true}, "alice"=>{"admin"=>false}}
|
@@ -287,10 +287,31 @@ data.</p>
|
|
287
287
|
<span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_query'><span class='object_link'><a href="Jylis.html#query-class_method" title="Jylis.query (method)">query</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>TLOG</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>GET</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>temperature</span><span class='tstring_end'>"</span></span>
|
288
288
|
<span class='comment'># => [["72.6", 5]]
|
289
289
|
</span></code></pre>
|
290
|
+
|
291
|
+
<h3 id="label-Timestamps">Timestamps</h3>
|
292
|
+
|
293
|
+
<p>In addition to supporting integer timestamps as defined by the Jylis spec,
|
294
|
+
this library also has helpers to convert the Jylis <code>Timestamped</code>
|
295
|
+
data types to/from ISO 8601. Functions that have a <code>timestamp</code>
|
296
|
+
parameter will automatically convert an ISO 8601 string to a Unix
|
297
|
+
timestamp.</p>
|
298
|
+
|
299
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_treg'><span class='object_link'><a href="Jylis.html#treg-class_method" title="Jylis.treg (method)">treg</a></span></span><span class='period'>.</span><span class='id identifier rubyid_set'><span class='object_link'><a href="Jylis/DataType/TREG.html#set-instance_method" title="Jylis::DataType::TREG#set (method)">set</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>volume</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='int'>64</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2018-06-06T01:42:57Z</span><span class='tstring_end'>"</span></span>
|
300
|
+
|
301
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Jylis.html" title="Jylis (class)">Jylis</a></span></span><span class='period'>.</span><span class='id identifier rubyid_treg'><span class='object_link'><a href="Jylis.html#treg-class_method" title="Jylis.treg (method)">treg</a></span></span><span class='period'>.</span><span class='id identifier rubyid_get'><span class='object_link'><a href="Jylis/DataType/TREG.html#get-instance_method" title="Jylis::DataType::TREG#get (method)">get</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>volume</span><span class='tstring_end'>"</span></span>
|
302
|
+
<span class='comment'># => #<Jylis::DataType::TREG::Result:0x00005609aa767f00 @timestamp=1528249377, @value="64">
|
303
|
+
</span>
|
304
|
+
<span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_timestamp'>timestamp</span>
|
305
|
+
<span class='comment'># => 1528249377
|
306
|
+
</span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_time'>time</span>
|
307
|
+
<span class='comment'># => 2018-06-05 18:42:57 -0700
|
308
|
+
</span><span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_timestamp_iso8601'>timestamp_iso8601</span>
|
309
|
+
<span class='comment'># => "2018-06-06T01:42:57Z"
|
310
|
+
</span></code></pre>
|
290
311
|
</div></div>
|
291
312
|
|
292
313
|
<div id="footer">
|
293
|
-
Generated on
|
314
|
+
Generated on Tue Jun 5 17:01:51 2018 by
|
294
315
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
295
316
|
0.9.14 (ruby-2.5.1).
|
296
317
|
</div>
|
data/doc/method_list.html
CHANGED
@@ -436,6 +436,22 @@
|
|
436
436
|
</li>
|
437
437
|
|
438
438
|
|
439
|
+
<li class="even ">
|
440
|
+
<div class="item">
|
441
|
+
<span class='object_link'><a href="Jylis/DataType/TLOG/Row.html#time-instance_method" title="Jylis::DataType::TLOG::Row#time (method)">#time</a></span>
|
442
|
+
<small>Jylis::DataType::TLOG::Row</small>
|
443
|
+
</div>
|
444
|
+
</li>
|
445
|
+
|
446
|
+
|
447
|
+
<li class="odd ">
|
448
|
+
<div class="item">
|
449
|
+
<span class='object_link'><a href="Jylis/DataType/TREG/Result.html#time-instance_method" title="Jylis::DataType::TREG::Result#time (method)">#time</a></span>
|
450
|
+
<small>Jylis::DataType::TREG::Result</small>
|
451
|
+
</div>
|
452
|
+
</li>
|
453
|
+
|
454
|
+
|
439
455
|
<li class="even ">
|
440
456
|
<div class="item">
|
441
457
|
<span class='object_link'><a href="Jylis/DataType/TLOG/Row.html#timestamp-instance_method" title="Jylis::DataType::TLOG::Row#timestamp (method)">#timestamp</a></span>
|
@@ -452,6 +468,22 @@
|
|
452
468
|
</li>
|
453
469
|
|
454
470
|
|
471
|
+
<li class="even ">
|
472
|
+
<div class="item">
|
473
|
+
<span class='object_link'><a href="Jylis/DataType/TLOG/Row.html#timestamp_iso8601-instance_method" title="Jylis::DataType::TLOG::Row#timestamp_iso8601 (method)">#timestamp_iso8601</a></span>
|
474
|
+
<small>Jylis::DataType::TLOG::Row</small>
|
475
|
+
</div>
|
476
|
+
</li>
|
477
|
+
|
478
|
+
|
479
|
+
<li class="odd ">
|
480
|
+
<div class="item">
|
481
|
+
<span class='object_link'><a href="Jylis/DataType/TREG/Result.html#timestamp_iso8601-instance_method" title="Jylis::DataType::TREG::Result#timestamp_iso8601 (method)">#timestamp_iso8601</a></span>
|
482
|
+
<small>Jylis::DataType::TREG::Result</small>
|
483
|
+
</div>
|
484
|
+
</li>
|
485
|
+
|
486
|
+
|
455
487
|
<li class="even ">
|
456
488
|
<div class="item">
|
457
489
|
<span class='object_link'><a href="Jylis.html#tlog-class_method" title="Jylis.tlog (method)">tlog</a></span>
|
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
103
|
+
Generated on Tue Jun 5 17:01:51 2018 by
|
104
104
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
105
|
0.9.14 (ruby-2.5.1).
|
106
106
|
</div>
|
@@ -76,6 +76,16 @@ class Jylis
|
|
76
76
|
def to_a
|
77
77
|
[value, timestamp]
|
78
78
|
end
|
79
|
+
|
80
|
+
# @return [Time] the timestamp as a {Time} object
|
81
|
+
def time
|
82
|
+
Time.at(timestamp)
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [String] the timestamp as an ISO8601 formatted string
|
86
|
+
def timestamp_iso8601
|
87
|
+
time.utc.iso8601
|
88
|
+
end
|
79
89
|
end
|
80
90
|
|
81
91
|
# Get the latest `value` and `timestamp` for the register at `key`.
|
@@ -101,8 +111,11 @@ class Jylis
|
|
101
111
|
# end
|
102
112
|
|
103
113
|
# Insert a `value`/`timestamp` entry into the log at `key`.
|
114
|
+
#
|
115
|
+
# @param timestamp [Integer, String] a unix or iso8601 formatted timestamp
|
104
116
|
def ins(key, value, timestamp)
|
105
|
-
|
117
|
+
timestamp = Time.parse(timestamp).utc.to_i if timestamp.is_a?(String)
|
118
|
+
result = connection.query("TLOG", "INS", key, value, timestamp)
|
106
119
|
|
107
120
|
unless result == "OK"
|
108
121
|
raise "Failed: TLOG INS #{key} #{value} #{timestamp}"
|
@@ -121,8 +134,11 @@ class Jylis
|
|
121
134
|
|
122
135
|
# Raise the cutoff timestamp of the log, causing any entries to be
|
123
136
|
# discarded whose timestamp is earlier than the newly given `timestamp`.
|
137
|
+
#
|
138
|
+
# @param timestamp [Integer, String] a unix or iso8601 formatted timestamp
|
124
139
|
def trimat(key, timestamp)
|
125
|
-
|
140
|
+
timestamp = Time.parse(timestamp).utc.to_i if timestamp.is_a?(String)
|
141
|
+
result = connection.query("TLOG", "TRIMAT", key, timestamp)
|
126
142
|
|
127
143
|
unless result == "OK"
|
128
144
|
raise "Failed: TLOG TRIMAT #{key} #{timestamp}"
|
@@ -33,6 +33,16 @@ class Jylis
|
|
33
33
|
def to_a
|
34
34
|
[value, timestamp]
|
35
35
|
end
|
36
|
+
|
37
|
+
# @return [Time] the timestamp as a {Time} object
|
38
|
+
def time
|
39
|
+
Time.at(timestamp)
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [String] the timestamp as an ISO8601 formatted string
|
43
|
+
def timestamp_iso8601
|
44
|
+
time.utc.iso8601
|
45
|
+
end
|
36
46
|
end
|
37
47
|
|
38
48
|
# Get the latest `value` and `timestamp` for the register at `key`.
|
@@ -45,8 +55,11 @@ class Jylis
|
|
45
55
|
end
|
46
56
|
|
47
57
|
# Set a `value` and `timestamp` for the register at `key`.
|
58
|
+
#
|
59
|
+
# @param timestamp [Integer, String] a unix or iso8601 formatted timestamp
|
48
60
|
def set(key, value, timestamp)
|
49
|
-
|
61
|
+
timestamp = Time.parse(timestamp).utc.to_i if timestamp.is_a?(String)
|
62
|
+
result = connection.query("TREG", "SET", key, value, timestamp)
|
50
63
|
|
51
64
|
unless result == "OK"
|
52
65
|
raise "Failed: TREG SET #{key} #{value} #{timestamp}"
|
data/lib/jylis-rb/jylis.rb
CHANGED
data/lib/jylis-rb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jylis-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex McLain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hiredis
|
@@ -152,6 +152,8 @@ files:
|
|
152
152
|
- doc/Jylis/DataType/TREG.html
|
153
153
|
- doc/Jylis/DataType/TREG/Result.html
|
154
154
|
- doc/Jylis/DataType/UJSON.html
|
155
|
+
- doc/Jylis/Helpers.html
|
156
|
+
- doc/Jylis/Helpers/Timestamp.html
|
155
157
|
- doc/_index.html
|
156
158
|
- doc/class_list.html
|
157
159
|
- doc/css/common.css
|