trecs 0.0.1.alpha
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 +7 -0
- data/.bundle/config +1 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.spec +0 -0
- data/.travis.yml +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +38 -0
- data/LICENCE.txt +22 -0
- data/README.org +44 -0
- data/Rakefile +7 -0
- data/bin/trecs +33 -0
- data/bin/trecs_message +20 -0
- data/bin/trecs_terminal +25 -0
- data/doc/steps.org +18 -0
- data/lib/player.rb +75 -0
- data/lib/players/zip_file_player.rb +56 -0
- data/lib/recorder.rb +68 -0
- data/lib/recorders/message_recorder.rb +18 -0
- data/lib/recorders/ttyrec_recorder.rb +13 -0
- data/lib/recorders/zip_file_recorder.rb +41 -0
- data/lib/recording_strategies/incremental_recording_strategy.rb +25 -0
- data/lib/recording_strategies/ttyrec_recording_strategy.rb +30 -0
- data/lib/recording_strategy.rb +10 -0
- data/lib/screens/terminal_screen.rb +22 -0
- data/lib/timestamps.rb +22 -0
- data/lib/trecs/version.rb +3 -0
- data/sandbox/create_recording.rb +28 -0
- data/sandbox/lipsum_end +1 -0
- data/sandbox/lipsum_start +1 -0
- data/sandbox/record +50 -0
- data/sandbox/record_diff +26 -0
- data/sandbox/record_script_file +45 -0
- data/spec/player_spec.rb +196 -0
- data/spec/recorder_spec.rb +248 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/timestamps_spec.rb +44 -0
- data/spec/trecs_message_spec.rb +125 -0
- data/spec/trecs_spec.rb +110 -0
- data/spec/zip_file_recorder_spec.rb +58 -0
- data/trecs.gemspec +31 -0
- metadata +179 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fileutils"
|
3
|
+
require 'zip'
|
4
|
+
|
5
|
+
describe "T-Recs" do
|
6
|
+
include FileUtils
|
7
|
+
|
8
|
+
define :have_frames do |expected|
|
9
|
+
match do |actual|
|
10
|
+
actual = actual.split("\e[H\e[2J\n").select { |f|
|
11
|
+
(/\S/ === f)
|
12
|
+
}.map(&:chomp)
|
13
|
+
expected = Array(expected)
|
14
|
+
actual == expected
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:trecs_root) { File.expand_path("../..", __FILE__) }
|
19
|
+
let(:bin) { "#{trecs_root}/bin" }
|
20
|
+
let(:exe) { "#{bin}/trecs_message" }
|
21
|
+
let(:play_exe) { "#{bin}/trecs" }
|
22
|
+
|
23
|
+
let(:project_dir) { create_dir("#{trecs_root}/tmp") }
|
24
|
+
|
25
|
+
def trecs(*args, &block)
|
26
|
+
command = [exe]
|
27
|
+
.concat(args.map(&:to_s))
|
28
|
+
.concat(["2>&1"])
|
29
|
+
.join(" ")
|
30
|
+
IO.popen(command) do |output|
|
31
|
+
yield output.read if block_given?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def play(*args, &block)
|
36
|
+
command = [play_exe]
|
37
|
+
.concat(args.map(&:to_s))
|
38
|
+
.concat(["testing", "2>&1"])
|
39
|
+
.join(" ")
|
40
|
+
IO.popen(command) do |output|
|
41
|
+
yield output.read if block_given?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "trecs_message command" do
|
46
|
+
after do
|
47
|
+
rm file_name if file_name
|
48
|
+
end
|
49
|
+
|
50
|
+
specify "is in place and executes" do
|
51
|
+
expect { trecs }.not_to raise_exception
|
52
|
+
trecs do |output|
|
53
|
+
output.should_not match /error/i
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it "expects a file name" do
|
58
|
+
trecs do |output|
|
59
|
+
output.should have_frames "Please give a file name"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "generates a .trecs compressed file" do
|
64
|
+
file_name "i_should_exist"
|
65
|
+
trecs("-f", file_name, "--message", "a")
|
66
|
+
|
67
|
+
File.exists?(file_name).should be_true
|
68
|
+
expect { Zip::File.open(file_name) }.not_to raise_error(Zip::ZipError)
|
69
|
+
end
|
70
|
+
|
71
|
+
context "recording" do
|
72
|
+
it "records a one letter message screencast" do
|
73
|
+
file_name "a"
|
74
|
+
|
75
|
+
trecs("-f", file_name, "--message", "a")
|
76
|
+
|
77
|
+
play("-f", file_name) do |output|
|
78
|
+
output.should have_frames "a"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it "records a two letters message screencast" do
|
83
|
+
file_name "ab"
|
84
|
+
|
85
|
+
trecs("-f", file_name, "--message", "ab")
|
86
|
+
|
87
|
+
play("-f", file_name) do |output|
|
88
|
+
output.should have_frames ["a", "ab"]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it "records a three letters message screencast" do
|
93
|
+
file_name "abc"
|
94
|
+
|
95
|
+
trecs("-f", file_name, "--message", "abc")
|
96
|
+
|
97
|
+
play("-f", file_name) do |output|
|
98
|
+
output.should have_frames ["a", "ab", "abc"]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "timestamps" do
|
104
|
+
it "uses 100 ms by default" do
|
105
|
+
file_name "abcd"
|
106
|
+
|
107
|
+
trecs("-f", file_name, "-m", "abcd")
|
108
|
+
|
109
|
+
play("-f", file_name, "--timestamps") do |output|
|
110
|
+
output.should have_frames "[0, 100, 200, 300]"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it "accepts a step parameter" do
|
115
|
+
file_name "abc"
|
116
|
+
|
117
|
+
trecs("-f", file_name, "-m", "abcd", "-s", "250")
|
118
|
+
|
119
|
+
play("-f", file_name, "--timestamps") do |output|
|
120
|
+
output.should have_frames "[0, 250, 500, 750]"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/spec/trecs_spec.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fileutils"
|
3
|
+
require 'zip'
|
4
|
+
require 'rspec/expectations'
|
5
|
+
|
6
|
+
describe "T-Recs" do
|
7
|
+
define :have_frames do |expected|
|
8
|
+
match do |actual|
|
9
|
+
actual = actual.split("\e[H\e[2J\n").select { |f|
|
10
|
+
(/\S/ === f)
|
11
|
+
}.map(&:chomp)
|
12
|
+
expected = Array(expected)
|
13
|
+
actual == expected
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
rm file_name if file_name
|
19
|
+
end
|
20
|
+
|
21
|
+
include FileUtils
|
22
|
+
|
23
|
+
let(:trecs_root) { File.expand_path("../..", __FILE__) }
|
24
|
+
let(:bin) { "#{trecs_root}/bin" }
|
25
|
+
let(:exe) { "#{bin}/trecs" }
|
26
|
+
|
27
|
+
let(:project_dir) { create_dir("#{trecs_root}/tmp") }
|
28
|
+
|
29
|
+
def trecs(*args, &block)
|
30
|
+
command = [exe]
|
31
|
+
.concat(args.map(&:to_s))
|
32
|
+
.concat(["--testing"])
|
33
|
+
.join(" ")
|
34
|
+
IO.popen(command) do |output|
|
35
|
+
yield output.read if block_given?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_recording(file_name: "")
|
40
|
+
unless File.exist?(file_name)
|
41
|
+
recording_dir = "#{File.dirname(file_name)}/frames"
|
42
|
+
rm_rf recording_dir
|
43
|
+
mkdir_p recording_dir
|
44
|
+
rm file_name if File.exists? file_name
|
45
|
+
|
46
|
+
yield recording_dir
|
47
|
+
|
48
|
+
files_to_record = Dir.glob("#{recording_dir}/*")
|
49
|
+
|
50
|
+
Zip::File.open(file_name, Zip::File::CREATE) do |trecs_file|
|
51
|
+
files_to_record.each do |file_to_rec|
|
52
|
+
dest_file_name = File.basename(file_to_rec)
|
53
|
+
trecs_file.add(dest_file_name, file_to_rec)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
rm_rf Dir.glob("#{recording_dir}")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_frame(file_name: "", content: "", time: 0)
|
61
|
+
File.open("#{project_dir}/frames/#{time.to_i}", File::WRONLY|File::CREAT) do |f|
|
62
|
+
f << content
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "trecs command" do
|
67
|
+
it "is in place and executes" do
|
68
|
+
expect { trecs }.not_to raise_exception
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns an error whe project doesn't exist" do
|
72
|
+
non_existent = "path/to/a/non/existing/file.trecs"
|
73
|
+
|
74
|
+
trecs("-f", non_existent) do |output|
|
75
|
+
output.should have_frames "File #{non_existent} does not exist."
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "Player" do
|
80
|
+
|
81
|
+
context "playing a recording" do
|
82
|
+
|
83
|
+
it "plays a recording" do
|
84
|
+
file_name "multiple_frames"
|
85
|
+
|
86
|
+
create_recording(file_name: file_name) do
|
87
|
+
create_frame(time: 0, content: "FIRST FRAME")
|
88
|
+
create_frame(time: 100, content: "FRAME AT 100")
|
89
|
+
create_frame(time: 200, content: "FRAME AT 200")
|
90
|
+
create_frame(time: 301, content: "FRAME AT 301")
|
91
|
+
create_frame(time: 499, content: "FRAME AT 499")
|
92
|
+
create_frame(time: 599, content: "FRAME AT 599")
|
93
|
+
end
|
94
|
+
|
95
|
+
trecs("-f", file_name) do |output|
|
96
|
+
output.should have_frames [
|
97
|
+
"FIRST FRAME",
|
98
|
+
"FRAME AT 100",
|
99
|
+
"FRAME AT 200",
|
100
|
+
"FRAME AT 200",
|
101
|
+
"FRAME AT 301",
|
102
|
+
"FRAME AT 499",
|
103
|
+
"FRAME AT 599",
|
104
|
+
]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "zip"
|
3
|
+
|
4
|
+
require "recorders/zip_file_recorder"
|
5
|
+
require "players/zip_file_player"
|
6
|
+
|
7
|
+
module TRecs
|
8
|
+
describe ZipFileRecorder do
|
9
|
+
class DummyRecordingStrategy
|
10
|
+
attr_reader :recorder
|
11
|
+
|
12
|
+
def initialize(recorder:)
|
13
|
+
@recorder = recorder
|
14
|
+
end
|
15
|
+
def perform
|
16
|
+
recorder.current_frame(time: 0, content: "zero")
|
17
|
+
recorder.current_frame(time: 1, content: "one")
|
18
|
+
recorder.current_frame(time: 2, content: "two")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class DummyZipFileRecorder < ZipFileRecorder
|
23
|
+
def initialize(**options)
|
24
|
+
@recording_strategy = DummyRecordingStrategy.new(recorder: self)
|
25
|
+
super(**options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "expects a file name" do
|
30
|
+
expect { ZipFileRecorder.new }.to raise_error
|
31
|
+
end
|
32
|
+
|
33
|
+
it "generates a .trecs compressed file" do
|
34
|
+
file_name = "tmp/i_should_exist.trecs"
|
35
|
+
recorder = DummyZipFileRecorder.new(file_name: file_name)
|
36
|
+
|
37
|
+
recorder.record
|
38
|
+
|
39
|
+
File.exists?(file_name).should be_true
|
40
|
+
expect { Zip::File.open(file_name) }.not_to raise_error(Zip::ZipError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has the correct frames" do
|
44
|
+
file_name = "tmp/zero_one_two.trecs"
|
45
|
+
recorder = DummyZipFileRecorder.new(file_name: file_name)
|
46
|
+
|
47
|
+
recorder.record
|
48
|
+
|
49
|
+
player = ZipFilePlayer.new(file_name: file_name)
|
50
|
+
|
51
|
+
player.timestamps.should == [0, 1, 2]
|
52
|
+
player.get_frame(0).should == "zero"
|
53
|
+
player.get_frame(1).should == "one"
|
54
|
+
player.get_frame(2).should == "two"
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
data/trecs.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
bin = File.expand_path('../bin', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
$LOAD_PATH.unshift(bin) unless $LOAD_PATH.include?(bin)
|
5
|
+
require 'trecs/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "trecs"
|
9
|
+
spec.version = TRecs::VERSION
|
10
|
+
spec.authors = ["Federico Iachetti"]
|
11
|
+
spec.email = ["iachetti.federico@gmail.com"]
|
12
|
+
spec.summary = %q{TRecs: Text Recordings.}
|
13
|
+
spec.description = %q{Record text screencasts.}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib", "bin"]
|
21
|
+
|
22
|
+
# Dependencies
|
23
|
+
spec.add_dependency "rubyzip", "~> 1.0.0"
|
24
|
+
spec.add_dependency "trollop", "~> 2.0"
|
25
|
+
|
26
|
+
# Development dependencies
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "rspec", "~> 2.12"
|
30
|
+
spec.add_development_dependency "rspec-given", "~> 3.5.4"
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trecs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Federico Iachetti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubyzip
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: trollop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-given
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.5.4
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.5.4
|
97
|
+
description: Record text screencasts.
|
98
|
+
email:
|
99
|
+
- iachetti.federico@gmail.com
|
100
|
+
executables:
|
101
|
+
- trecs
|
102
|
+
- trecs_message
|
103
|
+
- trecs_terminal
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- ".bundle/config"
|
108
|
+
- ".gitignore"
|
109
|
+
- ".rspec"
|
110
|
+
- ".spec"
|
111
|
+
- ".travis.yml"
|
112
|
+
- Gemfile
|
113
|
+
- Gemfile.lock
|
114
|
+
- LICENCE.txt
|
115
|
+
- README.org
|
116
|
+
- Rakefile
|
117
|
+
- bin/trecs
|
118
|
+
- bin/trecs_message
|
119
|
+
- bin/trecs_terminal
|
120
|
+
- doc/steps.org
|
121
|
+
- lib/player.rb
|
122
|
+
- lib/players/zip_file_player.rb
|
123
|
+
- lib/recorder.rb
|
124
|
+
- lib/recorders/message_recorder.rb
|
125
|
+
- lib/recorders/ttyrec_recorder.rb
|
126
|
+
- lib/recorders/zip_file_recorder.rb
|
127
|
+
- lib/recording_strategies/incremental_recording_strategy.rb
|
128
|
+
- lib/recording_strategies/ttyrec_recording_strategy.rb
|
129
|
+
- lib/recording_strategy.rb
|
130
|
+
- lib/screens/terminal_screen.rb
|
131
|
+
- lib/timestamps.rb
|
132
|
+
- lib/trecs/version.rb
|
133
|
+
- sandbox/create_recording.rb
|
134
|
+
- sandbox/lipsum_end
|
135
|
+
- sandbox/lipsum_start
|
136
|
+
- sandbox/record
|
137
|
+
- sandbox/record_diff
|
138
|
+
- sandbox/record_script_file
|
139
|
+
- spec/player_spec.rb
|
140
|
+
- spec/recorder_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
- spec/timestamps_spec.rb
|
143
|
+
- spec/trecs_message_spec.rb
|
144
|
+
- spec/trecs_spec.rb
|
145
|
+
- spec/zip_file_recorder_spec.rb
|
146
|
+
- trecs.gemspec
|
147
|
+
homepage: ''
|
148
|
+
licenses:
|
149
|
+
- MIT
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
- bin
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 1.3.1
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.2.2
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: 'TRecs: Text Recordings.'
|
172
|
+
test_files:
|
173
|
+
- spec/player_spec.rb
|
174
|
+
- spec/recorder_spec.rb
|
175
|
+
- spec/spec_helper.rb
|
176
|
+
- spec/timestamps_spec.rb
|
177
|
+
- spec/trecs_message_spec.rb
|
178
|
+
- spec/trecs_spec.rb
|
179
|
+
- spec/zip_file_recorder_spec.rb
|