shelr 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.0
1
+ 0.11.0
data/bin/shelr CHANGED
@@ -9,17 +9,28 @@ BASENAME = File.basename(__FILE__)
9
9
  HELP = <<-HELP
10
10
 
11
11
  Usage: #{BASENAME} command [arg]
12
-
13
- Commands:
14
- setup API_KEY - setup
12
+
13
+ Recording:
14
+
15
15
  record - record new shellcast
16
+
17
+ Publishing:
18
+
16
19
  push last - publish last record
17
20
  push RECORD_ID - publish
21
+
22
+ Replaying:
23
+
18
24
  list - print list of records
19
25
  play last - play last local record
20
26
  play RECORD_ID - play local record
21
27
  play RECORD_URL - play remote record
22
28
 
29
+ Setup:
30
+
31
+ setup API_KEY - set your API key
32
+ backend [ttyrec|script] - setup recorder backend
33
+
23
34
  Visit: http://shelr.tv/ for more info.
24
35
 
25
36
  HELP
@@ -28,7 +39,7 @@ case ARGV[0]
28
39
  when '-h', '--help'
29
40
  puts HELP
30
41
  when 'record'
31
- Shelr::Recorder.record!
42
+ Shelr::Recorder.record!
32
43
  when 'list'
33
44
  Shelr::Player.list
34
45
  when 'play'
@@ -60,6 +71,13 @@ when 'setup'
60
71
  puts "\n\tUsage: #{BASENAME} setup API_KEY\n\n"
61
72
  exit
62
73
  end
74
+ when 'backend'
75
+ if ARGV[1]
76
+ Shelr.backend = ARGV[1]
77
+ else
78
+ puts "\n\tUsage: #{BASENAME} backend [ttyrec|script]\n\n"
79
+ exit
80
+ end
63
81
  else
64
82
  puts HELP
65
83
  end
@@ -3,21 +3,21 @@ module Shelr
3
3
  class Recorder
4
4
 
5
5
  HEADER = <<-EOH
6
- ____ _ _
7
- | _ \ ___ ___ ___ _ __ __| (_)_ __ __ _
6
+ ____ _ _
7
+ | _ \ ___ ___ ___ _ __ __| (_)_ __ __ _
8
8
  | |_) / _ \/ __/ _ \| '__/ _` | | '_ \ / _` |
9
9
  | _ < __/ (_| (_) | | | (_| | | | | | (_| |
10
10
  |_| \_\___|\___\___/|_| \__,_|_|_| |_|\__, |
11
- |___/
11
+ |___/
12
12
  EOH
13
13
 
14
14
  FOOTER = <<-EOF
15
- _____ _ _ _ _
15
+ _____ _ _ _ _
16
16
  | ___(_)_ __ (_)___| |__ ___ __| |
17
17
  | |_ | | '_ \| / __| '_ \ / _ \/ _` |
18
18
  | _| | | | | | \__ \ | | | __/ (_| |
19
19
  |_| |_|_| |_|_|___/_| |_|\___|\__,_|
20
-
20
+
21
21
  EOF
22
22
 
23
23
  def self.record!
@@ -34,8 +34,9 @@ module Shelr
34
34
  puts HEADER
35
35
  puts "Your session started"
36
36
  puts "Type Ctrl+D or exit to finish recording"
37
- system(script_cmd)
37
+ system(recorder_cmd)
38
38
  restore_terminal
39
+ save_as_typescript if Shelr.backend == 'ttyrec'
39
40
  puts FOOTER
40
41
  puts
41
42
  puts "Replay : #{Shelr::APP_NAME} play last"
@@ -57,6 +58,20 @@ module Shelr
57
58
 
58
59
  private
59
60
 
61
+ def save_as_typescript
62
+ puts '=> Converting ttyrec -> typescript'
63
+
64
+ ttyrecord = File.open(record_file('ttyrecord'), 'r')
65
+ converter = Shelr::TTYRec.new(ttyrecord)
66
+ typescript = converter.parse.to_typescript
67
+
68
+ [:typescript, :timing].each do |part|
69
+ File.open(record_file(part.to_s), 'w') do |f|
70
+ f.write(typescript[part])
71
+ end
72
+ end
73
+ end
74
+
60
75
  def check_record_dir
61
76
  FileUtils.mkdir_p(record_dir) unless File.exists?(record_dir)
62
77
  end
@@ -85,9 +100,13 @@ module Shelr
85
100
  File.join(Shelr.data_dir(record_id), name)
86
101
  end
87
102
 
88
- def script_cmd
89
- "script -c 'bash' #{record_file('typescript')} -t 2> #{record_file('timing')}"
103
+ def recorder_cmd
104
+ case Shelr.backend
105
+ when 'script'
106
+ "script #{record_file('typescript')} -t 2> #{record_file('timing')}"
107
+ when 'ttyrec'
108
+ "ttyrec #{record_file('ttyrecord')}"
109
+ end
90
110
  end
91
-
92
111
  end
93
112
  end
@@ -0,0 +1,47 @@
1
+ module Shelr
2
+ class TTYRec
3
+
4
+ def initialize(ttyrec)
5
+ @io = ttyrec
6
+ @timeline = []
7
+ end
8
+
9
+ def parse
10
+ while !@io.eof?
11
+ frame = {}
12
+
13
+ sec, usec, len = @io.read(12).unpack('VVV')
14
+ data = @io.read(len)
15
+
16
+ prev_timestamp ||= [ sec, usec ].join('.').to_f
17
+ curr_timestamp = [ sec, usec ].join('.').to_f
18
+
19
+ offset = curr_timestamp - prev_timestamp
20
+
21
+ frame = {
22
+ :offset => "%5.6f" % offset,
23
+ :data => data,
24
+ :length => len
25
+ }
26
+
27
+ @timeline << frame
28
+
29
+ prev_timestamp = curr_timestamp
30
+ prev_data = data
31
+ end
32
+
33
+ self
34
+ end
35
+
36
+ def to_typescript
37
+ script = { :typescript => "Script started...\n", :timing => "" }
38
+
39
+ @timeline.each do |frame|
40
+ script[:timing] += [frame[:offset], ' ', frame[:length], "\n"].join
41
+ script[:typescript] += frame[:data]
42
+ end
43
+
44
+ script
45
+ end
46
+ end
47
+ end
data/lib/shelr.rb CHANGED
@@ -1,18 +1,19 @@
1
1
  require 'fileutils'
2
- require 'yaml'
3
2
  require 'json'
4
3
 
5
4
  module Shelr
6
5
 
7
- APP_NAME = 'shelr'
8
- DATA_DIR = File.join(ENV['HOME'], '.local', 'share', APP_NAME)
9
- CONFIG_DIR = File.join(ENV['HOME'], '.config', APP_NAME)
10
- API_KEY = File.join(CONFIG_DIR, 'api_key')
11
- API_URL = ENV['SHELR_LOCAL'] ? 'http://localhost:3000' : 'http://shelr.tv'
6
+ APP_NAME = 'shelr'
7
+ DATA_DIR = File.join(ENV['HOME'], '.local', 'share', APP_NAME)
8
+ CONFIG_DIR = File.join(ENV['HOME'], '.config', APP_NAME)
9
+ API_KEY = File.join(CONFIG_DIR, 'api_key')
10
+ API_URL = ENV['SHELR_LOCAL'] ? 'http://localhost:3000' : 'http://shelr.tv'
11
+ BACKEND_CFG = File.join(CONFIG_DIR, 'backend')
12
12
 
13
13
  autoload :Recorder, 'shelr/recorder.rb'
14
14
  autoload :Player, 'shelr/player.rb'
15
15
  autoload :Publisher, 'shelr/publisher.rb'
16
+ autoload :TTYRec, 'shelr/ttyrec.rb'
16
17
 
17
18
  class << self
18
19
  def api_key
@@ -21,10 +22,19 @@ module Shelr
21
22
  end
22
23
 
23
24
  def api_key=(key)
24
- FileUtils.mkdir_p(CONFIG_DIR) unless File.exist?(CONFIG_DIR)
25
+ ensure_config_dir_exist
25
26
  File.open(API_KEY, 'w+') { |f| f.puts(key.strip) }
26
27
  end
27
28
 
29
+ def backend
30
+ @backend ||= File.read(BACKEND_CFG).strip || 'script'
31
+ end
32
+
33
+ def backend=(bin)
34
+ ensure_config_dir_exist
35
+ File.open(BACKEND_CFG, 'w+') { |f| f.puts(bin.strip) }
36
+ end
37
+
28
38
  def data_dir(record_id)
29
39
  id = record_id.strip == 'last' ? last_id : record_id.to_s
30
40
  File.join(Shelr::DATA_DIR, id)
@@ -33,6 +43,12 @@ module Shelr
33
43
  def last_id
34
44
  File.basename(Dir[File.join(Shelr::DATA_DIR, '*')].sort.last)
35
45
  end
46
+
47
+ private
48
+
49
+ def ensure_config_dir_exist
50
+ FileUtils.mkdir_p(CONFIG_DIR) unless File.exist?(CONFIG_DIR)
51
+ end
36
52
  end
37
53
 
38
54
  end
data/shelr.1 CHANGED
@@ -6,12 +6,15 @@
6
6
  .SH "NAME"
7
7
  \fBshelr\fR \- screencasting for shell ninjas
8
8
  .
9
+ .SH "DESCRIPTION"
10
+ \fBShelr\fR records terminal output and can replay it\.
11
+ .
12
+ .P
13
+ Also you can shere Your records at http://shelr\.tv/ or other services\.
14
+ .
9
15
  .SH "SYNOPSIS"
10
16
  \fBshelr\fR command [id]
11
17
  .
12
- .SH "DESCRIPTION"
13
- \fBShelr\fR records terminal output and can replay it
14
- .
15
18
  .SH "COMMANDS"
16
19
  .
17
20
  .TP
@@ -99,13 +102,21 @@ $ shelr push last # will push most recent local record
99
102
  .
100
103
  .IP "" 0
101
104
  .
102
- .SH "BUGS"
103
- \fBshelr\fR is written in Ruby and depends on \fBscript\fR and \fBscriptreplay\fR, commands libraries that are non\-trivial to install on some systems\.
104
- .
105
105
  .P
106
- \fBscript\fR on BSD and Darwin does not support timings\.
106
+ Setup recording backend:
107
107
  .
108
- .P
108
+ .IP "" 4
109
+ .
110
+ .nf
111
+
112
+ $ shelr backend script
113
+ $ shelr backend ttyrec
114
+ .
115
+ .fi
116
+ .
117
+ .IP "" 0
118
+ .
119
+ .SH "BUGS"
109
120
  \fBWindows\fR heh\.
110
121
  .
111
122
  .SH "COPYRIGHT"
data/shelr.1.ronn CHANGED
@@ -1,13 +1,16 @@
1
1
  shelr(1) -- screencasting for shell ninjas
2
2
  ===============================================
3
3
 
4
- ## SYNOPSIS
4
+ ## DESCRIPTION
5
5
 
6
- `shelr` command [id]
6
+ **Shelr** records terminal output and can replay it.
7
7
 
8
- ## DESCRIPTION
8
+ Also you can shere Your records at http://shelr.tv/
9
+ or other services.
10
+
11
+ ## SYNOPSIS
9
12
 
10
- **Shelr** records terminal output and can replay it
13
+ `shelr` command [id]
11
14
 
12
15
  ## COMMANDS
13
16
 
@@ -16,7 +19,7 @@ shelr(1) -- screencasting for shell ninjas
16
19
  store it to $HOME/.local/share/shelr/
17
20
 
18
21
  * `list`:
19
- lists all your shellcasts.
22
+ lists all your shellcasts.
20
23
 
21
24
  * `play`:
22
25
  plays local or remote shellcast.
@@ -50,13 +53,12 @@ Publish your shellcast:
50
53
  $ shelr push 1293702847
51
54
  $ shelr push last # will push most recent local record
52
55
 
56
+ Setup recording backend:
53
57
 
54
- ## BUGS
58
+ $ shelr backend script
59
+ $ shelr backend ttyrec
55
60
 
56
- **shelr** is written in Ruby and depends on `script` and `scriptreplay`,
57
- commands libraries that are non-trivial to install on some systems.
58
-
59
- **script** on BSD and Darwin does not support timings.
61
+ ## BUGS
60
62
 
61
63
  **Windows** heh.
62
64
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-26 00:00:00.000000000Z
13
+ date: 2012-02-27 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &10652700 !ruby/object:Gem::Requirement
17
+ requirement: &25328280 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *10652700
25
+ version_requirements: *25328280
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: mocha
28
- requirement: &10650840 !ruby/object:Gem::Requirement
28
+ requirement: &25327740 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *10650840
36
+ version_requirements: *25327740
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &10649440 !ruby/object:Gem::Requirement
39
+ requirement: &25276640 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *10649440
47
+ version_requirements: *25276640
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: jeweler
50
- requirement: &10646940 !ruby/object:Gem::Requirement
50
+ requirement: &25276140 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *10646940
58
+ version_requirements: *25276140
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rcov
61
- requirement: &10632680 !ruby/object:Gem::Requirement
61
+ requirement: &25275660 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *10632680
69
+ version_requirements: *25275660
70
70
  description: Screencast utility for unix shell junkies :)
71
71
  email: self@antono.info
72
72
  executables:
@@ -90,6 +90,7 @@ files:
90
90
  - lib/shelr/player.rb
91
91
  - lib/shelr/publisher.rb
92
92
  - lib/shelr/recorder.rb
93
+ - lib/shelr/ttyrec.rb
93
94
  - shelr.1
94
95
  - shelr.1.ronn
95
96
  - spec/shelr/player_spec.rb
@@ -112,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
113
  version: '0'
113
114
  segments:
114
115
  - 0
115
- hash: -4236082943444524578
116
+ hash: 3627863128559079363
116
117
  required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  none: false
118
119
  requirements: