shelr 0.12.3 → 0.12.4

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.
data/bin/shelr CHANGED
@@ -30,6 +30,7 @@ HELP = <<-HELP
30
30
  play last - play last local record
31
31
  play RECORD_ID - play local record
32
32
  play RECORD_URL - play remote record
33
+ play dump.json - play local file dumped with `shelr dump`
33
34
 
34
35
  Setup:
35
36
 
@@ -49,10 +50,10 @@ when 'list'
49
50
  Shelr::Player.list
50
51
  when 'play'
51
52
  if ARGV[1]
52
- if ARGV[1] =~ /^http:.*/
53
+ if ARGV[1] =~ /^http:.*/ # remote file
53
54
  Shelr::Player.play_remote(ARGV[1])
54
- else
55
- Shelr::Player.play(ARGV[1])
55
+ elsif ARGV[1] =~ /.*\.json$/ # local file
56
+ Shelr::Player.play_dump(ARGV[1])
56
57
  end
57
58
  else
58
59
  puts "Missing id for shellcast"
data/lib/shelr/player.rb CHANGED
@@ -14,26 +14,13 @@ module Shelr
14
14
  def self.play_remote(url)
15
15
  puts ".==> Fetching #{url}"
16
16
  resp = Net::HTTP.get(URI.parse(url))
17
- parts = JSON.parse(resp)
18
-
19
- print "Title:\t"
20
- puts parts['title']
21
- print "Description:\t"
22
- puts parts['description']
17
+ play_parts_hash(JSON.parse(resp))
18
+ end
23
19
 
24
- Dir.mktmpdir do |dir|
25
- %w(typescript timing).each do |type|
26
- File.open(File.join(dir, type), 'w') { |f| f.puts(parts[type]) }
27
- end
28
- puts "+==> Playing... "
29
- system "scriptreplay #{File.join(dir, 'timing')} #{File.join(dir, 'typescript')}"
30
- puts "+\n+"
31
- print "| Title:\t"
32
- puts parts['title']
33
- print "| Description:\t"
34
- puts parts['description']
35
- puts "`==> The end... "
36
- end
20
+ def self.play_dump(file)
21
+ json = File.read(File.open(file))
22
+ parts = JSON.parse(json)
23
+ play_parts_hash(parts)
37
24
  end
38
25
 
39
26
  def self.list
@@ -43,6 +30,24 @@ module Shelr
43
30
  end
44
31
  end
45
32
 
33
+ # TODO: refactore me!
34
+ def self.play_parts_hash(parts)
35
+ Dir.mktmpdir do |dir|
36
+ %w(typescript timing).each do |type|
37
+ File.open(File.join(dir, type), 'w') { |f| f.puts(parts[type]) }
38
+ end
39
+ Shelr.terminal.puts_line
40
+ puts "=> Title: #{parts['title']}"
41
+ puts "=> Description: #{parts['description']}t"
42
+ Shelr.terminal.puts_line
43
+ system "scriptreplay #{File.join(dir, 'timing')} #{File.join(dir, 'typescript')}"
44
+ Shelr.terminal.puts_line
45
+ puts "=> Title: #{parts['title']}"
46
+ puts "=> Description: #{parts['description']}t"
47
+ Shelr.terminal.puts_line
48
+ end
49
+ end
50
+
46
51
  def initialize(id)
47
52
  @record_id = id
48
53
  end
@@ -17,13 +17,13 @@ module Shelr
17
17
  with_lock_file do
18
18
  init_terminal
19
19
  request_metadata
20
- STDOUT.puts "-=" * (Shelr.terminal.size[:width] / 2)
20
+ Shelr.terminal.puts_line
21
21
  STDOUT.puts "=> Your session started"
22
22
  STDOUT.puts "=> Please, do not resize your terminal while recording"
23
23
  STDOUT.puts "=> Press Ctrl+D or 'exit' to finish recording"
24
24
  system(recorder_cmd)
25
25
  save_as_typescript if Shelr.backend == 'ttyrec'
26
- STDOUT.puts "-=" * (Shelr.terminal.size[:width] / 2)
26
+ Shelr.terminal.puts_line
27
27
  STDOUT.puts "=> Session finished"
28
28
  STDOUT.puts
29
29
  STDOUT.puts "Replay : #{Shelr::APP_NAME} play last"
@@ -5,5 +5,9 @@ module Shelr
5
5
  height, width = `stty size`.split(' ')
6
6
  { :height => height.to_i, :width => width.to_i }
7
7
  end
8
+
9
+ def puts_line
10
+ STDOUT.puts "-=" * (size[:width] / 2)
11
+ end
8
12
  end
9
13
  end
data/lib/shelr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Shelr
2
- VERSION = '0.12.3'
2
+ VERSION = '0.12.4'
3
3
  end
data/shelr.1 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "SHELR" "1" "March 2012" "" ""
4
+ .TH "SHELR" "1" "April 2012" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBshelr\fR \- screencasting for shell ninjas
@@ -72,8 +72,9 @@ Play local shellcast:
72
72
  .
73
73
  .nf
74
74
 
75
- $ shelr play 1293702847
76
- $ shelr play last # will play most recent local record
75
+ $ shelr play 1293702847 # play your own local record
76
+ $ shelr play record\.json # created with shelr dump
77
+ $ shelr play last # will play most recent local record
77
78
  .
78
79
  .fi
79
80
  .
data/shelr.1.ronn CHANGED
@@ -44,8 +44,9 @@ List recorded shellcasts:
44
44
 
45
45
  Play local shellcast:
46
46
 
47
- $ shelr play 1293702847
48
- $ shelr play last # will play most recent local record
47
+ $ shelr play 1293702847 # play your own local record
48
+ $ shelr play record.json # created with shelr dump
49
+ $ shelr play last # will play most recent local record
49
50
 
50
51
  Play remote shellcast:
51
52
 
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.12.3
4
+ version: 0.12.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -86,7 +86,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
86
  version: '0'
87
87
  segments:
88
88
  - 0
89
- hash: 1640227039729566954
89
+ hash: 2904017191069490073
90
90
  required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  none: false
92
92
  requirements:
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  version: '0'
96
96
  segments:
97
97
  - 0
98
- hash: 1640227039729566954
98
+ hash: 2904017191069490073
99
99
  requirements: []
100
100
  rubyforge_project:
101
101
  rubygems_version: 1.8.21