trecs 0.4.0 → 0.4.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: 8d398a30c4662e41a3cbe7461c72fde6ed150f13
4
- data.tar.gz: bd44123337dca8b66a60ed882bac9485cfaa6f05
3
+ metadata.gz: 3ff49f07ddfe14f4149cc6633011195b0bcbfe93
4
+ data.tar.gz: a619e937967b0a856b470ed366f1704e073b43da
5
5
  SHA512:
6
- metadata.gz: de4d6ac1348a7b4cf1b4a45af508e832f0edfd6f1215728043ab7f1a1434e042b58746d758deebc9cd28c346977e925fc8164ca8d4d0ce0da0a13a13c2eddfe8
7
- data.tar.gz: a9f432b18467a15848db360f31d4dd76ab07ccf0d35853814215ebbc537ebb0dcbdeb43b5fbc92a162f3905a372b61786275c10964b27d16123cff5713e09ca0
6
+ metadata.gz: 02bd8f5842139767983a1f2b9a9d7dc791f42345167e884dbc0a0620dd76b447d3f2caa95d0ffc6a07def1097e69a75c33e3e285fd4ac3c0431e4edbd5117f6b
7
+ data.tar.gz: 35330ad17b08a0322368ef750dba3fa2fa5c890262e0e81f4c256574fe398f2ddd15a226b64f5520fbfe68fb2adb608ba64dc310304d91e7817da15c890cb5c6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trecs (0.4.0)
4
+ trecs (0.4.1)
5
5
  minitar (~> 0.5.4)
6
6
  trollop (~> 2.0)
7
7
 
@@ -7,11 +7,10 @@ module TRecs
7
7
  file = "/tmp/emacs-session-recording.html"
8
8
  @file = File.open(file)
9
9
 
10
- @clock = options.fetch(:clock) { Time }
11
- @testing = options.fetch(:testing) { false }
10
+ @clock = options.fetch(:clock) { Time }
12
11
 
13
- @height = 20
14
- @width = 80
12
+ @height = options.fetch(:height) { 0 }
13
+ @width = options.fetch(:width) { 0 }
15
14
  end
16
15
 
17
16
  def perform
@@ -48,9 +47,9 @@ module TRecs
48
47
  .split("\n").join("<do not compute>")[/\s+<pre>(.+)<\/pre>/, 1]
49
48
  .split("<do not compute>").join("\n")
50
49
  .gsub(/\/\*.+\*\//, "")
51
- #.gsub!(/^\s/, "").gsub!(/^(<[^\/]\w+ (\w+=['"][^>]+['"])*>)+ /) {|m| m[-1]=""; m } # clean extra space at the begining of each line
50
+ # .gsub!(/^\s/, "").gsub!(/^(<[^\/]\w+ (\w+=['"][^>]+['"])*>)+ /) {|m| m[-1]=""; m } # clean extra space at the begining of each line
52
51
 
53
- new_content = "<style>#{style}</style><pre style='border: 2px solid #898989;width: #{@width*1.3}ex;height: #{@height*1.31}ex' class='emacs-code'>#{code}</pre>"
52
+ new_content = "<style>#{style}</style><pre style='border: 2px solid #898989;width: #{@width/1.5}em;height: #{@height/1.55}em' class='emacs-code'>#{code}</pre>"
54
53
 
55
54
  super(new_content)
56
55
  end
@@ -28,13 +28,12 @@ module TRecs
28
28
  c[j] = hider
29
29
  end
30
30
  c = c[1..-2]
31
- @frames[current_time] = "" unless @frames[current_time]
32
- @frames[current_time] = @frames[current_time] << c.strip + "\n"
31
+ @frames[current_time] ||= ""
32
+ @frames[current_time] << c.strip + "\n"
33
33
  end
34
34
  end
35
35
 
36
36
  cleanup_frames
37
- #super
38
37
  end
39
38
 
40
39
  private
@@ -6,25 +6,26 @@ module TRecs
6
6
 
7
7
  def initialize(options={})
8
8
  super(options)
9
- @frames = []
10
- @step = @step / 1000.0
9
+ # @frames = []
10
+ @step = options.fetch(:step) { 100 }
11
11
  @color = options.fetch(:color) { true }
12
12
  set_color_or_bw
13
13
  end
14
14
 
15
15
  def perform
16
16
  start_recording
17
+ t = -step
17
18
  while(recording)
18
- get_frames do |frame|
19
- recorder.current_frame(content: frame)
20
- end
21
- sleep(step)
19
+ t += step
20
+ current_time(t)
21
+ current_content(get_current_frame)
22
+ save_frame
23
+ sleep(step/1000.0)
22
24
  end
23
25
  end
24
26
 
25
- def command
26
- @command ||=
27
- set_command
27
+ def capture_command
28
+ @capture_command ||= set_capture_command
28
29
  end
29
30
 
30
31
  def stop
@@ -40,17 +41,15 @@ module TRecs
40
41
  @color = @color ? "-e" : "-C"
41
42
  end
42
43
 
43
- def set_command
44
- command = %W[tmux capture-pane]
45
- command << @color if @color
46
- command
44
+ def set_capture_command
45
+ capture_command = %W[tmux capture-pane]
46
+ capture_command << @color if @color
47
+ capture_command
47
48
  end
48
49
 
49
- def get_frames
50
- system *command
51
- IO.popen(%W[tmux show-buffer]) do |out|
52
- yield out.read
53
- end
50
+ def get_current_frame
51
+ system *capture_command
52
+ IO.popen(%W[tmux show-buffer]).read
54
53
  end
55
54
  end
56
55
  end
data/lib/trecs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TRecs
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -42,11 +42,9 @@ module TRecs
42
42
 
43
43
  When { strategy.recorder = recorder }
44
44
  When { recorder.record }
45
- When { strategy.perform }
46
45
 
47
46
  When { recorder.stub(:step) { 100 } }
48
47
  When { strategy.recorder = recorder }
49
- When { strategy.perform }
50
48
 
51
49
  Then { writer.frames[0] == "" }
52
50
  Then { writer.frames[100] == " a" }
@@ -36,7 +36,6 @@ module TRecs
36
36
 
37
37
  When { strategy.recorder = recorder }
38
38
  When { recorder.record }
39
- When { strategy.perform }
40
39
 
41
40
  Then { writer.frames[0] == "A" }
42
41
  Then { writer.frames[10] == "B" }
@@ -25,7 +25,6 @@ module TRecs
25
25
 
26
26
  When { strategy.recorder = recorder }
27
27
  When { recorder.record }
28
- When { strategy.perform }
29
28
 
30
29
  Then { writer.frames[0] == "" }
31
30
  Then { writer.frames[100] == "H" }
@@ -7,67 +7,66 @@ require "writers/in_memory_writer"
7
7
 
8
8
  module TRecs
9
9
  describe SwipeStrategy do
10
- skip("Modify Swipe")
11
- #context "initialization" do
12
- # When(:strategy) { SwipeStrategy.new }
13
- # Then { expect(strategy).to have_raised(/key not found.*message/) }
14
- #end
15
- #
16
- #context "performing" do
17
- # Given(:writer) { InMemoryWriter.new }
18
- # Given(:recorder) { Recorder.new(strategy: strategy, writer: writer) }
19
- #
20
- # When { strategy.recorder = recorder }
21
- # When { recorder.record }
22
- # When { strategy.perform }
23
- #
24
- # context "one char" do
25
- # Given(:strategy) { SwipeStrategy.new(message: "a") }
26
- # Then { writer.frames[0] == "*" }
27
- # Then { writer.frames[100] == "|" }
28
- # Then { writer.frames[200] == "a|" }
29
- # Then { writer.frames[300] == "a" }
30
- # end
31
- #
32
- # context "two chars" do
33
- # Given(:strategy) { SwipeStrategy.new(message: "ab", step: 10) }
34
- # Then { writer.frames[0] == "**" }
35
- # Then { writer.frames[10] == "|*" }
36
- # Then { writer.frames[20] == "a|" }
37
- # Then { writer.frames[30] == "ab|" }
38
- # Then { writer.frames[40] == "ab" }
39
- # end
40
- #
41
- # context "multiple_lines" do
42
- # Given(:strategy) { SwipeStrategy.new(message: "FIRST\nSECOND") }
43
- # Then { writer.frames[0] == "******\n******" }
44
- # Then { writer.frames[100] == "|*****\n|*****" }
45
- # Then { writer.frames[200] == "F|****\nS|****" }
46
- # Then { writer.frames[300] == "FI|***\nSE|***" }
47
- # Then { writer.frames[400] == "FIR|**\nSEC|**" }
48
- # Then { writer.frames[500] == "FIRS|*\nSECO|*" }
49
- # Then { writer.frames[600] == "FIRST|\nSECON|" }
50
- # Then { writer.frames[700] == "FIRST |\nSECOND|" }
51
- # Then { writer.frames[800] == "FIRST\nSECOND" }
52
- # end
53
- #
54
- # context "swiper and hider" do
55
- # context "swiper" do
56
- # Given(:strategy) { SwipeStrategy.new(message: "a", swiper: ">") }
57
- # Then { writer.frames[0] == "*" }
58
- # Then { writer.frames[100] == ">" }
59
- # Then { writer.frames[200] == "a>" }
60
- # Then { writer.frames[300] == "a" }
61
- # end
62
- #
63
- # context "hider" do
64
- # Given(:strategy) { SwipeStrategy.new(message: "a", hider: "#") }
65
- # Then { writer.frames[0] == "#" }
66
- # Then { writer.frames[100] == "|" }
67
- # Then { writer.frames[200] == "a|" }
68
- # Then { writer.frames[300] == "a" }
69
- # end
70
- # end
71
- #end
10
+ #skip("Modify Swipe")
11
+ context "initialization" do
12
+ When(:strategy) { SwipeStrategy.new }
13
+ Then { expect(strategy).to have_raised(/key not found.*message/) }
14
+ end
15
+
16
+ context "performing" do
17
+ Given(:writer) { InMemoryWriter.new }
18
+ Given(:recorder) { Recorder.new(strategy: strategy, writer: writer) }
19
+
20
+ When { strategy.recorder = recorder }
21
+ When { recorder.record }
22
+
23
+ context "one char" do
24
+ Given(:strategy) { SwipeStrategy.new(message: "a") }
25
+ Then { writer.frames[0] == "*" }
26
+ Then { writer.frames[100] == "|" }
27
+ Then { writer.frames[200] == "a|" }
28
+ Then { writer.frames[300] == "a" }
29
+ end
30
+
31
+ context "two chars" do
32
+ Given(:strategy) { SwipeStrategy.new(message: "ab", step: 10) }
33
+ Then { writer.frames[0] == "**" }
34
+ Then { writer.frames[10] == "|*" }
35
+ Then { writer.frames[20] == "a|" }
36
+ Then { writer.frames[30] == "ab|" }
37
+ Then { writer.frames[40] == "ab" }
38
+ end
39
+
40
+ context "multiple_lines" do
41
+ Given(:strategy) { SwipeStrategy.new(message: "FIRST\nSECOND") }
42
+ Then { writer.frames[0] == "******\n******" }
43
+ Then { writer.frames[100] == "|*****\n|*****" }
44
+ Then { writer.frames[200] == "F|****\nS|****" }
45
+ Then { writer.frames[300] == "FI|***\nSE|***" }
46
+ Then { writer.frames[400] == "FIR|**\nSEC|**" }
47
+ Then { writer.frames[500] == "FIRS|*\nSECO|*" }
48
+ Then { writer.frames[600] == "FIRST|\nSECON|" }
49
+ Then { writer.frames[700] == "FIRST |\nSECOND|" }
50
+ Then { writer.frames[800] == "FIRST\nSECOND" }
51
+ end
52
+
53
+ context "swiper and hider" do
54
+ context "swiper" do
55
+ Given(:strategy) { SwipeStrategy.new(message: "a", swiper: ">") }
56
+ Then { writer.frames[0] == "*" }
57
+ Then { writer.frames[100] == ">" }
58
+ Then { writer.frames[200] == "a>" }
59
+ Then { writer.frames[300] == "a" }
60
+ end
61
+
62
+ context "hider" do
63
+ Given(:strategy) { SwipeStrategy.new(message: "a", hider: "#") }
64
+ Then { writer.frames[0] == "#" }
65
+ Then { writer.frames[100] == "|" }
66
+ Then { writer.frames[200] == "a|" }
67
+ Then { writer.frames[300] == "a" }
68
+ end
69
+ end
70
+ end
72
71
  end
73
72
  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.4.0
4
+ version: 0.4.1
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-10-20 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  version: '0'
199
199
  requirements: []
200
200
  rubyforge_project:
201
- rubygems_version: 2.2.2
201
+ rubygems_version: 2.4.2
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: 'TRecs: Text Recordings.'