trecs 0.3.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/trecs/frame.rb +13 -6
- data/lib/trecs/player.rb +1 -1
- data/lib/trecs/readers/json_reader.rb +5 -5
- data/lib/trecs/version.rb +1 -1
- data/spec/trecs/frame_spec.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1567faa458d8727e15199ceadb97b6c08c73a05b
|
4
|
+
data.tar.gz: 336b1cd252fb2b75efd20cd65ca4f11553581ead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2303fc365f90d50cfdea548877847381338cd280dd4a5549e09731d0ec4ae27e4ea9fbf6b01aad0f74eae2f5417a8115e4dafdf18034edd5ae72ce4a3407d1cf
|
7
|
+
data.tar.gz: afe215e565ddff5f58430548c973716b32482763652b88318bfc299f871e2ec5e67a814d2c65716ac00bbc0396dc37ac166dad61f2428f4272f42199e53a8b23
|
data/Gemfile.lock
CHANGED
data/lib/trecs/frame.rb
CHANGED
@@ -2,8 +2,11 @@ module TRecs
|
|
2
2
|
class Frame
|
3
3
|
include Enumerable
|
4
4
|
attr_accessor :content
|
5
|
-
|
6
|
-
|
5
|
+
attr_accessor :format
|
6
|
+
def initialize(opts={})
|
7
|
+
opts = opts.is_a?(Hash) ? opts : {content: opts}
|
8
|
+
@content = opts.fetch(:content) { "" }
|
9
|
+
@format = opts.fetch(:format) { "raw" }
|
7
10
|
end
|
8
11
|
|
9
12
|
def width
|
@@ -24,13 +27,17 @@ module TRecs
|
|
24
27
|
content
|
25
28
|
end
|
26
29
|
alias :to_str :to_s
|
30
|
+
|
31
|
+
def ==(other)
|
32
|
+
to_s == other.to_s
|
33
|
+
end
|
27
34
|
end
|
28
35
|
|
29
|
-
def Frame(
|
30
|
-
case
|
31
|
-
when Frame then
|
36
|
+
def Frame(opts)
|
37
|
+
case opts
|
38
|
+
when Frame then opts
|
32
39
|
else
|
33
|
-
Frame.new(
|
40
|
+
Frame.new(opts)
|
34
41
|
end
|
35
42
|
end
|
36
43
|
module_function :Frame
|
data/lib/trecs/player.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "sources/tgz_source"
|
2
|
+
require "frame"
|
2
3
|
|
3
4
|
module TRecs
|
4
5
|
class JsonReader
|
@@ -20,9 +21,9 @@ module TRecs
|
|
20
21
|
frames = {}
|
21
22
|
source.read do
|
22
23
|
json_string = source.read_entry("frames.json") || "{}"
|
23
|
-
parsed_json = JSON.parse(json_string)
|
24
|
-
parsed_json.each do |time,
|
25
|
-
frames[Integer(time)] =
|
24
|
+
parsed_json = JSON.parse(json_string, symbolize_names: true)
|
25
|
+
parsed_json.each do |time, value|
|
26
|
+
frames[Integer(time.to_s)] = TRecs::Frame(value)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
frames
|
@@ -33,8 +34,7 @@ module TRecs
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def frame_at(time)
|
36
|
-
|
37
|
-
frame.is_a?(Hash) ? frame["content"] : frame
|
37
|
+
@frames[time]
|
38
38
|
end
|
39
39
|
|
40
40
|
def to_s
|
data/lib/trecs/version.rb
CHANGED
data/spec/trecs/frame_spec.rb
CHANGED
@@ -5,8 +5,9 @@ module TRecs
|
|
5
5
|
describe Frame do
|
6
6
|
context "content" do
|
7
7
|
context "initializer" do
|
8
|
-
Given(:frame) { Frame.new("THE CONTENT") }
|
8
|
+
Given(:frame) { Frame.new(content: "THE CONTENT") }
|
9
9
|
Then { frame.content == "THE CONTENT" }
|
10
|
+
Then { frame.format == "raw" }
|
10
11
|
end
|
11
12
|
context "set aftewards" do
|
12
13
|
Given(:frame) { Frame.new }
|
@@ -31,6 +32,11 @@ FRAME
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
context "equality" do
|
36
|
+
Then { Frame.new(content: "A") == Frame.new("A") }
|
37
|
+
Then { Frame.new(content: "B") == "B" }
|
38
|
+
end
|
39
|
+
|
34
40
|
context "height" do
|
35
41
|
context "one line" do
|
36
42
|
Given(:frame) { Frame.new("LINE 1") }
|