trecs 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 063ffb002a27203278a25d1514da9f5175309148
4
- data.tar.gz: b2d61f5b666dcd311c8257da9f6bc8e653edf23c
3
+ metadata.gz: 1567faa458d8727e15199ceadb97b6c08c73a05b
4
+ data.tar.gz: 336b1cd252fb2b75efd20cd65ca4f11553581ead
5
5
  SHA512:
6
- metadata.gz: f236b56eeeda0aa44602e8714cf4ed1e06aa4119b179f2c847cc0259d4e7e616f1e43807d819f632fb8262c16f2ead7546bb60e0717381fa4d40e9d49da44d36
7
- data.tar.gz: 9f32b4ad8fe607200d5a7ccb72adbf91f43d97ff87348db46712d047db40e280e4447942d3a272106344e0d24413767ffd976032a654f51fa5444b89d02da034
6
+ metadata.gz: 2303fc365f90d50cfdea548877847381338cd280dd4a5549e09731d0ec4ae27e4ea9fbf6b01aad0f74eae2f5417a8115e4dafdf18034edd5ae72ce4a3407d1cf
7
+ data.tar.gz: afe215e565ddff5f58430548c973716b32482763652b88318bfc299f871e2ec5e67a814d2c65716ac00bbc0396dc37ac166dad61f2428f4272f42199e53a8b23
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trecs (0.3.0)
4
+ trecs (0.3.1)
5
5
  minitar (~> 0.5.4)
6
6
  trollop (~> 2.0)
7
7
 
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
- def initialize(content="")
6
- @content = content
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(value)
30
- case value
31
- when Frame then value
36
+ def Frame(opts)
37
+ case opts
38
+ when Frame then opts
32
39
  else
33
- Frame.new(value.to_str)
40
+ Frame.new(opts)
34
41
  end
35
42
  end
36
43
  module_function :Frame
data/lib/trecs/player.rb CHANGED
@@ -33,7 +33,7 @@ module TRecs
33
33
  content = reader.frame_at(time_to_play(time))
34
34
  if content != prev_content
35
35
  screen.clear
36
- screen.puts(content)
36
+ screen.puts(content.to_s)
37
37
  self.prev_content = content
38
38
  end
39
39
  content
@@ -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, content|
25
- frames[Integer(time)] = content
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
- frame = @frames[time]
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
@@ -1,3 +1,3 @@
1
1
  module TRecs
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -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") }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trecs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Iachetti