trecs 0.1.13 → 0.1.14
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/bin/trecs +55 -11
- data/bin/trecs_record +2 -2
- data/lib/trecs/readers/json_reader.rb +1 -1
- data/lib/trecs/recording_strategies/config_strategy.rb +8 -4
- data/lib/trecs/recording_strategies/hash_strategy.rb +5 -3
- data/lib/trecs/recording_strategies/tmux_session_strategy.rb +0 -1
- data/lib/trecs/sources/in_memory_source.rb +80 -0
- data/lib/trecs/sources/tgz_source.rb +93 -13
- data/lib/trecs/version.rb +1 -1
- data/lib/trecs/writers/json_writer.rb +3 -3
- data/spec/trecs/readers/json_reader_spec.rb +1 -1
- data/spec/trecs/recording_strategies/config_strategy_spec.rb +1 -1
- data/spec/trecs/recording_strategies/hash_strategy_spec.rb +6 -3
- data/spec/trecs/sources/in_memory_source_spec.rb +90 -0
- data/spec/trecs/sources/tgz_source_spec.rb +119 -8
- data/spec/trecs/writers/json_writer_spec.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4483b0fafe0266d5424f01b291a8ef6dc044ddd
|
4
|
+
data.tar.gz: 465ed8d44cd35a7a6b46a81be537a381d21715e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb3c8768eba4935b9615b43a048c0e8c93cb369c5c4639f204a19b78aa0321a7a2d38494ffceaf7737b1125e4eeb808128a52fc3fd0ad8d17934c9428c1afff7
|
7
|
+
data.tar.gz: 45404627642b17cce299a350c513907dcec4dd81c32054e919d195e9666c46a38da7490bdf6887eb726bca3c57aa2bdf9f8e72a29ddcb29ebda175c9c6f1cb82
|
data/Gemfile.lock
CHANGED
data/bin/trecs
CHANGED
@@ -16,32 +16,60 @@ end
|
|
16
16
|
opts = Trollop::options do
|
17
17
|
version TRecs::VERSION
|
18
18
|
|
19
|
-
opt :step, "Time in ms between frames", short: 's',
|
20
|
-
opt :ticker, "Ticker",
|
19
|
+
opt :step, "Time in ms between frames", short: 's', default: 100
|
20
|
+
opt :ticker, "Ticker", type: String, default: "clock"
|
21
21
|
|
22
|
-
opt :from, "Play from",
|
23
|
-
opt :to, "Play to",
|
24
|
-
opt :speed, "Playing speed",
|
22
|
+
opt :from, "Play from", type: Integer, default: 0
|
23
|
+
opt :to, "Play to", type: Integer, default: 0
|
24
|
+
opt :speed, "Playing speed", type: Float, default: 1.0
|
25
25
|
|
26
|
-
opt :ticker_file, "File to watch",
|
26
|
+
opt :ticker_file, "File to watch", type: String, default: "/tmp/ticker"
|
27
|
+
|
28
|
+
opt :audio, "If there's an audio file, reproduce it", default: true
|
29
|
+
|
30
|
+
opt :duration, "Length of the recording", default: false
|
27
31
|
end
|
28
32
|
opts[:trecs_file] = ARGV[0]
|
29
33
|
|
30
34
|
trap "SIGINT" do
|
31
35
|
finish(opts)
|
36
|
+
if @sox_pid
|
37
|
+
Process.kill("SIGINT", @sox_pid)
|
38
|
+
Process.waitpid(@sox_pid)
|
39
|
+
end
|
32
40
|
exit rescue nil
|
33
41
|
end
|
34
42
|
|
43
|
+
|
44
|
+
########## AUDIO ##########
|
45
|
+
def start_sound_player(file_name='sound.ogg')
|
46
|
+
return unless File.exist?(file_name)
|
47
|
+
# at_exit { system('stty echo') }
|
48
|
+
STDOUT.puts "=> Starting sound player..."
|
49
|
+
@sox_pid = fork do
|
50
|
+
`play #{file_name} 2>&1`
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def stop_sound_player
|
55
|
+
return unless File.exist?(file_name)
|
56
|
+
STDOUT.puts "=> Stopping sound player..."
|
57
|
+
Process.waitpid(@sox_pid)
|
58
|
+
end
|
59
|
+
######## END AUDIO ########
|
60
|
+
|
61
|
+
|
62
|
+
|
35
63
|
source = TRecs::TgzSource.new(trecs_file: opts.fetch(:trecs_file))
|
36
|
-
reader = source.
|
64
|
+
reader = source.build_reader(opts)
|
37
65
|
|
38
66
|
ticker_file = "tickers/#{opts[:ticker]}_ticker"
|
39
67
|
require ticker_file
|
40
68
|
ticker_class_name = [
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
69
|
+
"TRecs::",
|
70
|
+
opts[:ticker].split(/[-_\s]/).map(&:capitalize),
|
71
|
+
"Ticker"
|
72
|
+
].join
|
45
73
|
ticker_class = ticker_class_name.split("::").reduce(Object) { |a, e| a.const_get e }
|
46
74
|
ticker = ticker_class.new(opts)
|
47
75
|
|
@@ -51,7 +79,23 @@ player_options = {
|
|
51
79
|
step: opts[:step],
|
52
80
|
}
|
53
81
|
|
82
|
+
|
83
|
+
|
54
84
|
player = TRecs::Player.new(player_options)
|
85
|
+
|
86
|
+
if opts[:duration]
|
87
|
+
last_timestamp = player.timestamps.last
|
88
|
+
hr = last_timestamp / (1000*60*60)
|
89
|
+
last_timestamp = last_timestamp % (1000*60*60)
|
90
|
+
min = last_timestamp / (1000*60)
|
91
|
+
last_timestamp = last_timestamp % (1000*60)
|
92
|
+
seg = last_timestamp / 1000
|
93
|
+
duration = "%d:%02d:%02d" % [hr, min, seg]
|
94
|
+
|
95
|
+
puts duration
|
96
|
+
exit 0
|
97
|
+
end
|
98
|
+
|
55
99
|
player.play
|
56
100
|
|
57
101
|
finish(opts)
|
data/bin/trecs_record
CHANGED
@@ -21,7 +21,7 @@ opts = Trollop::options do
|
|
21
21
|
|
22
22
|
opt :audio, "Record audio", type: String
|
23
23
|
end
|
24
|
-
opts[:
|
24
|
+
opts[:trecs_backend] = ARGV[0]
|
25
25
|
|
26
26
|
require "writers/json_writer"
|
27
27
|
writer_class = TRecs::JsonWriter
|
@@ -36,7 +36,7 @@ strategy_class_name = [
|
|
36
36
|
strategy_class = strategy_class_name.split("::").reduce(Object) { |a, e| a.const_get e }
|
37
37
|
|
38
38
|
########## AUDIO ##########
|
39
|
-
def start_sound_recording(file_name='sound.ogg')
|
39
|
+
def start_sound_recording(file_name='/tmp/sound.ogg')
|
40
40
|
puts "Sound file stored in #{file_name}"
|
41
41
|
@sox_pid = fork do
|
42
42
|
Signal.trap("SIGINT") {
|
@@ -13,12 +13,16 @@ module TRecs
|
|
13
13
|
@strategies = options.fetch(:strategies) { [] }
|
14
14
|
end
|
15
15
|
|
16
|
-
def <<(
|
17
|
-
|
18
|
-
@strategies << strategy
|
19
|
-
end
|
16
|
+
def <<(strategy)
|
17
|
+
@strategies << strategy
|
20
18
|
end
|
21
19
|
|
20
|
+
def append(*strategies)
|
21
|
+
strategies.each do |strategy|
|
22
|
+
self << strategy
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
22
26
|
def perform
|
23
27
|
strategies.each do |strategy|
|
24
28
|
strategy.recorder = recorder
|
@@ -10,9 +10,11 @@ module TRecs
|
|
10
10
|
|
11
11
|
def perform
|
12
12
|
@frames.each do |time, content|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
if time.is_a?(Numeric) || /\A\d+\Z/ === time
|
14
|
+
current_time(time.to_i)
|
15
|
+
current_content(content)
|
16
|
+
save_frame
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'json'
|
2
|
+
require "yaml"
|
3
|
+
require "stringio"
|
4
|
+
|
5
|
+
module TRecs
|
6
|
+
class Source
|
7
|
+
attr_reader :manifest
|
8
|
+
|
9
|
+
def initialize(options={})
|
10
|
+
@trecs_backend = options.fetch(:trecs_backend)
|
11
|
+
end
|
12
|
+
|
13
|
+
def []=(key, value)
|
14
|
+
manifest[key] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def [](key)
|
18
|
+
manifest[key]
|
19
|
+
end
|
20
|
+
|
21
|
+
def manifest
|
22
|
+
@manifest ||= {}
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
class InMemorySource < Source
|
28
|
+
def create_recording
|
29
|
+
clear
|
30
|
+
trecs_backend[:manifest] = manifest
|
31
|
+
end
|
32
|
+
|
33
|
+
def clear
|
34
|
+
@trecs_backend.clear
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_entry(path)
|
38
|
+
io = StringIO.new
|
39
|
+
yield io
|
40
|
+
io.rewind
|
41
|
+
content = io.read.to_s
|
42
|
+
|
43
|
+
path_array = path.split("/") << content
|
44
|
+
result = path_array.reverse.inject do |entry, path|
|
45
|
+
{ path => entry }
|
46
|
+
end
|
47
|
+
deep_merge(trecs_backend, result)
|
48
|
+
end
|
49
|
+
|
50
|
+
def read_entry(path)
|
51
|
+
path = path.split("/")
|
52
|
+
|
53
|
+
path.inject(trecs_backend) do |current_tree, current_entry|
|
54
|
+
break nil if current_tree.nil?
|
55
|
+
current_tree[current_entry]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
attr_reader :trecs_backend
|
61
|
+
|
62
|
+
def deep_merge(hash1, hash2, &block)
|
63
|
+
hash2.each_pair do |current_key, other_value|
|
64
|
+
this_value = hash1[current_key]
|
65
|
+
|
66
|
+
hash1[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
|
67
|
+
deep_merge(this_value, other_value, &block)
|
68
|
+
else
|
69
|
+
if block_given? && key?(current_key)
|
70
|
+
block.call(current_key, this_value, other_value)
|
71
|
+
else
|
72
|
+
other_value
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
hash1
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'json'
|
2
3
|
require "fileutils"
|
3
4
|
require "zlib"
|
@@ -6,19 +7,96 @@ require "tmpdir"
|
|
6
7
|
require "pathname"
|
7
8
|
require "yaml"
|
8
9
|
|
10
|
+
#module TRecs
|
11
|
+
# class TgzSource
|
12
|
+
# include Archive::Tar
|
13
|
+
#
|
14
|
+
# def initialize(options={})
|
15
|
+
# @trecs_backend = options.fetch(:trecs_backend)
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# def create_recording
|
19
|
+
# in_tmp_dir do
|
20
|
+
# @tgz = Zlib::GzipWriter.new(trecs_backend)
|
21
|
+
#
|
22
|
+
# yield self if block_given?
|
23
|
+
#
|
24
|
+
# create_entry('manifest.yaml') do |f|
|
25
|
+
# f.write manifest.to_yaml
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# Minitar.pack(@files_to_add.flatten, @tgz)
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# # TODO: Este es el punto de intersección entre read y create_recording
|
33
|
+
# def manifest
|
34
|
+
# @manifest ||= {}
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# def []=(key, value)
|
38
|
+
# manifest[key] = value
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# def [](key)
|
42
|
+
# manifest[key]
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# def read_file(file_name)
|
46
|
+
# File.read(file_name)
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# def create_entry(file_name)
|
50
|
+
# File.open(file_name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
|
51
|
+
# yield f
|
52
|
+
# end
|
53
|
+
# add_file(file_name)
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# def add_file(file_name)
|
57
|
+
# @files_to_add ||= []
|
58
|
+
# @files_to_add << file_name
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# def add_audio_file(file_name)
|
62
|
+
# Dir.mkdir("audio") unless File.exist? "audio"
|
63
|
+
#
|
64
|
+
# orig_file = file_name
|
65
|
+
# file_name = "./audio/" + Pathname(file_name).basename.to_s
|
66
|
+
# FileUtils.symlink(orig_file, file_name)
|
67
|
+
# add_file(file_name)
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# private
|
71
|
+
#
|
72
|
+
# attr_reader :trecs_backend
|
73
|
+
#
|
74
|
+
# #Investigar como hacer para descomprimir en memoria
|
75
|
+
# def in_tmp_dir
|
76
|
+
# Dir.mktmpdir("trecs_record") do |dir|
|
77
|
+
# Dir.chdir(dir) do
|
78
|
+
# yield
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
#end
|
84
|
+
#
|
85
|
+
|
9
86
|
module TRecs
|
10
87
|
class TgzSource
|
11
88
|
include Archive::Tar
|
12
89
|
|
13
|
-
attr_reader :
|
90
|
+
attr_reader :trecs_backend
|
91
|
+
attr_reader :audio_files
|
14
92
|
|
15
93
|
def initialize(options={})
|
16
|
-
@
|
94
|
+
@trecs_backend = options.fetch(:trecs_backend)
|
17
95
|
end
|
18
96
|
|
19
97
|
def create_recording
|
20
98
|
in_tmp_dir do
|
21
|
-
@tgz = Zlib::GzipWriter.new(File.open(
|
99
|
+
@tgz = Zlib::GzipWriter.new(File.open(trecs_backend, 'wb'))
|
22
100
|
|
23
101
|
yield self
|
24
102
|
|
@@ -30,7 +108,16 @@ module TRecs
|
|
30
108
|
end
|
31
109
|
end
|
32
110
|
|
33
|
-
def
|
111
|
+
def read
|
112
|
+
in_tmp_dir do
|
113
|
+
tgz = Zlib::GzipReader.new(File.open(trecs_backend, 'rb'))
|
114
|
+
Minitar.unpack(tgz, "./")
|
115
|
+
|
116
|
+
yield self
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def build_reader(options={})
|
34
121
|
reader = nil
|
35
122
|
options[:source] = self
|
36
123
|
read do |source|
|
@@ -50,15 +137,7 @@ module TRecs
|
|
50
137
|
reader
|
51
138
|
end
|
52
139
|
|
53
|
-
|
54
|
-
in_tmp_dir do
|
55
|
-
tgz = Zlib::GzipReader.new(File.open(trecs_file, 'rb'))
|
56
|
-
Minitar.unpack(tgz, "./")
|
57
|
-
|
58
|
-
yield self
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
140
|
+
# Investigar como hacer para descomprimir en memoria
|
62
141
|
def in_tmp_dir
|
63
142
|
Dir.mktmpdir("trecs_record") do |dir|
|
64
143
|
Dir.chdir(dir) do
|
@@ -98,6 +177,7 @@ module TRecs
|
|
98
177
|
|
99
178
|
private
|
100
179
|
|
180
|
+
# TODO: Este es el punto de intersección entre read y create_recording
|
101
181
|
def manifest
|
102
182
|
@manifest ||= {}
|
103
183
|
end
|
data/lib/trecs/version.rb
CHANGED
@@ -9,8 +9,8 @@ module TRecs
|
|
9
9
|
attr_reader :source
|
10
10
|
|
11
11
|
def initialize(options={})
|
12
|
-
|
13
|
-
@source = TgzSource.new(
|
12
|
+
trecs_backend = options.fetch(:trecs_backend)
|
13
|
+
@source = TgzSource.new(trecs_backend: trecs_backend)
|
14
14
|
|
15
15
|
@audio_files = options.fetch(:audio_files) { [] }
|
16
16
|
@audio_files = Array(@audio_files)
|
@@ -40,7 +40,7 @@ module TRecs
|
|
40
40
|
source.add_audio_file(file)
|
41
41
|
end
|
42
42
|
if audio_files.any?
|
43
|
-
source[:
|
43
|
+
source[:default_audio] = audio_files.first
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -23,9 +23,11 @@ module TRecs
|
|
23
23
|
Given(:recorder) { Spy.new("recorder") }
|
24
24
|
Given(:strategy) { HashStrategy.new(
|
25
25
|
{
|
26
|
-
0
|
27
|
-
10
|
28
|
-
15
|
26
|
+
0 => "A",
|
27
|
+
10.0 => "B",
|
28
|
+
"15" => "C",
|
29
|
+
"1a2b3C4" => "h",
|
30
|
+
20 => "D",
|
29
31
|
}
|
30
32
|
) }
|
31
33
|
|
@@ -35,6 +37,7 @@ module TRecs
|
|
35
37
|
Then { recorder.calls[1] == [:current_frame, [ {time: 0, content: "A"} ] ] }
|
36
38
|
Then { recorder.calls[2] == [:current_frame, [ {time: 10, content: "B"} ] ] }
|
37
39
|
Then { recorder.calls[3] == [:current_frame, [ {time: 15, content: "C"} ] ] }
|
40
|
+
Then { recorder.calls[4] == [:current_frame, [ {time: 20, content: "D"} ] ] }
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "sources/in_memory_source"
|
3
|
+
|
4
|
+
module TRecs
|
5
|
+
describe InMemorySource do
|
6
|
+
Given(:source) { InMemorySource.new(trecs_backend: trecs_backend) }
|
7
|
+
context "creating from scratch" do
|
8
|
+
Given(:trecs_backend) { Hash.new }
|
9
|
+
|
10
|
+
When { source.create_recording }
|
11
|
+
|
12
|
+
context "creation" do
|
13
|
+
Then { trecs_backend.keys.any? }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "creating a manifest" do
|
17
|
+
When { source[:format] = "FORMAT" }
|
18
|
+
|
19
|
+
Then { source[:format] == "FORMAT" }
|
20
|
+
Then { trecs_backend[:manifest][:format] == "FORMAT" }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "adding entries" do
|
24
|
+
context "root level" do
|
25
|
+
When {
|
26
|
+
source.add_entry("an_entry") do |e|
|
27
|
+
e.write "THE CONTENT"
|
28
|
+
end
|
29
|
+
}
|
30
|
+
|
31
|
+
Then { trecs_backend["an_entry"] == "THE CONTENT" }
|
32
|
+
end
|
33
|
+
|
34
|
+
context "one level deep" do
|
35
|
+
When {
|
36
|
+
source.add_entry("a_section/an_entry") do |e|
|
37
|
+
e.write "THE CONTENT"
|
38
|
+
end
|
39
|
+
}
|
40
|
+
|
41
|
+
Then { trecs_backend["a_section"]["an_entry"] == "THE CONTENT" }
|
42
|
+
end
|
43
|
+
|
44
|
+
context "two entries one level deep" do
|
45
|
+
When {
|
46
|
+
source.add_entry("a_section/an_entry") do |e|
|
47
|
+
e.write "THE CONTENT"
|
48
|
+
end
|
49
|
+
|
50
|
+
source.add_entry("a_section/another_entry") do |e|
|
51
|
+
e.write "THE OTHER CONTENT"
|
52
|
+
end
|
53
|
+
}
|
54
|
+
|
55
|
+
Then { trecs_backend["a_section"]["an_entry"] == "THE CONTENT" }
|
56
|
+
Then { trecs_backend["a_section"]["another_entry"] == "THE OTHER CONTENT" }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
context "reading a recording" do
|
63
|
+
Given(:trecs_backend) {
|
64
|
+
{ "a" => { "b" => { "c.txt" => "ABC" } } }
|
65
|
+
}
|
66
|
+
Then { source.read_entry("a/b/c.txt") == "ABC" }
|
67
|
+
|
68
|
+
Then { source.read_entry("a/b/c.t") == nil }
|
69
|
+
Then { source.read_entry("a/d/f/g/i.txt") == nil }
|
70
|
+
|
71
|
+
Then { source.read_entry("a/d/f/g/i.txt") == nil }
|
72
|
+
end
|
73
|
+
|
74
|
+
context "handling non-empty recordings" do
|
75
|
+
context "#clear" do
|
76
|
+
Given(:trecs_backend) {
|
77
|
+
{ "a" => { "b" => { "c.txt" => "ABC" } } }
|
78
|
+
}
|
79
|
+
|
80
|
+
When {
|
81
|
+
source.create_recording
|
82
|
+
source.clear
|
83
|
+
}
|
84
|
+
|
85
|
+
Then { trecs_backend == {} }
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -1,8 +1,119 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "sources/tgz_source"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
# require "spec_helper"
|
2
|
+
# require "sources/tgz_source"
|
3
|
+
# require "stringio"
|
4
|
+
# require 'archive/tar/minitar'
|
5
|
+
#
|
6
|
+
# require "spec_helper"
|
7
|
+
# require "sources/in_memory_source"
|
8
|
+
#
|
9
|
+
# module TRecs
|
10
|
+
# describe TgzSource do
|
11
|
+
# Given(:source) { TgzSource.new(trecs_backend: trecs_backend) }
|
12
|
+
# context "creating from scratch" do
|
13
|
+
# Given(:trecs_backend) { StringIO.new }
|
14
|
+
#
|
15
|
+
# When { source.create_recording }
|
16
|
+
#
|
17
|
+
# context "creation" do
|
18
|
+
# When { trecs_backend.rewind }
|
19
|
+
# Then { !trecs_backend.string.empty? }
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# context "creating a manifest" do
|
23
|
+
# When { source[:format] = "FORMAT" }
|
24
|
+
#
|
25
|
+
# Then { source[:format] == "FORMAT" }
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# context "adding entries" do
|
29
|
+
# context "root level" do
|
30
|
+
# When {
|
31
|
+
# source.add_entry("an_entry") do |e|
|
32
|
+
# e.write "THE CONTENT"
|
33
|
+
# end
|
34
|
+
# }
|
35
|
+
#
|
36
|
+
# Then { trecs_backend["an_entry"] == "THE CONTENT" }
|
37
|
+
# end
|
38
|
+
# #
|
39
|
+
# # context "one level deep" do
|
40
|
+
# # When {
|
41
|
+
# # source.add_entry("a_section/an_entry") do |e|
|
42
|
+
# # e.write "THE CONTENT"
|
43
|
+
# # end
|
44
|
+
# # }
|
45
|
+
# #
|
46
|
+
# # Then { trecs_backend["a_section"]["an_entry"] == "THE CONTENT" }
|
47
|
+
# # end
|
48
|
+
# #
|
49
|
+
# # context "two entries one level deep" do
|
50
|
+
# # When {
|
51
|
+
# # source.add_entry("a_section/an_entry") do |e|
|
52
|
+
# # e.write "THE CONTENT"
|
53
|
+
# # end
|
54
|
+
# #
|
55
|
+
# # source.add_entry("a_section/another_entry") do |e|
|
56
|
+
# # e.write "THE OTHER CONTENT"
|
57
|
+
# # end
|
58
|
+
# # }
|
59
|
+
# #
|
60
|
+
# # Then { trecs_backend["a_section"]["an_entry"] == "THE CONTENT" }
|
61
|
+
# # Then { trecs_backend["a_section"]["another_entry"] == "THE OTHER CONTENT" }
|
62
|
+
# # end
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
# #
|
66
|
+
# # context "reading a recording" do
|
67
|
+
# # Given(:trecs_backend) { StringIO.new }
|
68
|
+
# #
|
69
|
+
# # When {
|
70
|
+
# # source.add_entry("a/b/c.txt") do |e|
|
71
|
+
# # e.write "ABC"
|
72
|
+
# # end
|
73
|
+
# # }
|
74
|
+
# #
|
75
|
+
# # Then { source.read_entry("a/b/c.txt") == "ABC" }
|
76
|
+
# #
|
77
|
+
# # Then { source.read_entry("a/b/c.t") == nil }
|
78
|
+
# # Then { source.read_entry("a/d/f/g/i.txt") == nil }
|
79
|
+
# # end
|
80
|
+
# #
|
81
|
+
# # context "handling non-empty recordings" do
|
82
|
+
# # context "#clear" do
|
83
|
+
# # Given(:trecs_backend) {
|
84
|
+
# # { "a" => { "b" => { "c.txt" => "ABC" } } }
|
85
|
+
# # }
|
86
|
+
# #
|
87
|
+
# # When {
|
88
|
+
# # source.create_recording
|
89
|
+
# # source.clear
|
90
|
+
# # }
|
91
|
+
# #
|
92
|
+
# # Then { trecs_backend == {} }
|
93
|
+
# # end
|
94
|
+
# #
|
95
|
+
# # end
|
96
|
+
# end
|
97
|
+
# end
|
98
|
+
#
|
99
|
+
#
|
100
|
+
# # module TRecs
|
101
|
+
# # describe TgzSource do
|
102
|
+
# # Given(:trecs_backend) { StringIO.new }
|
103
|
+
# # Given(:source) { TgzSource.new(trecs_backend: trecs_backend) }
|
104
|
+
#
|
105
|
+
#
|
106
|
+
# # context "creation" do
|
107
|
+
# # When { source.create_recording }
|
108
|
+
# # Then { !trecs_backend.to_s.empty? }
|
109
|
+
# # end
|
110
|
+
#
|
111
|
+
# # context "manifest" do
|
112
|
+
# # When { source.create_recording }
|
113
|
+
# # When { source["format"] = "THE FORMAT" }
|
114
|
+
#
|
115
|
+
# # Then { trecs_backend.read == "" }
|
116
|
+
# # Then { source.manifest == { "format" => "THE FORMAT"} }
|
117
|
+
# # end
|
118
|
+
# # end
|
119
|
+
# # end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trecs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Federico Iachetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/trecs/recording_strategies/tmux_session_strategy.rb
|
135
135
|
- lib/trecs/recording_strategies/ttyrec_strategy.rb
|
136
136
|
- lib/trecs/screens/terminal_screen.rb
|
137
|
+
- lib/trecs/sources/in_memory_source.rb
|
137
138
|
- lib/trecs/sources/tgz_source.rb
|
138
139
|
- lib/trecs/tickers/clock_ticker.rb
|
139
140
|
- lib/trecs/tickers/terminal_input_ticker.rb
|
@@ -162,6 +163,7 @@ files:
|
|
162
163
|
- spec/trecs/recording_strategies/incremental_strategy_spec.rb
|
163
164
|
- spec/trecs/recording_strategies/raw_file_strategy_spec.rb
|
164
165
|
- spec/trecs/recording_strategies/shell_command_strategy_spec.rb
|
166
|
+
- spec/trecs/sources/in_memory_source_spec.rb
|
165
167
|
- spec/trecs/sources/tgz_source_spec.rb
|
166
168
|
- spec/trecs/tickers/clock_ticker_spec.rb
|
167
169
|
- spec/trecs/writers/in_memory_writer_spec.rb
|
@@ -208,6 +210,7 @@ test_files:
|
|
208
210
|
- spec/trecs/recording_strategies/incremental_strategy_spec.rb
|
209
211
|
- spec/trecs/recording_strategies/raw_file_strategy_spec.rb
|
210
212
|
- spec/trecs/recording_strategies/shell_command_strategy_spec.rb
|
213
|
+
- spec/trecs/sources/in_memory_source_spec.rb
|
211
214
|
- spec/trecs/sources/tgz_source_spec.rb
|
212
215
|
- spec/trecs/tickers/clock_ticker_spec.rb
|
213
216
|
- spec/trecs/writers/in_memory_writer_spec.rb
|