shellcast 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/bin/shellcast +25 -0
- data/lib/shellcast/player.rb +38 -0
- data/lib/shellcast/publisher.rb +4 -0
- data/lib/shellcast/recorder.rb +67 -0
- data/lib/shellcast.rb +20 -0
- data/spec/shellcast/player_spec.rb +0 -0
- data/spec/shellcast/publisher_spec.rb +0 -0
- data/spec/shellcast/recorder_spec.rb +10 -0
- data/spec/shellcast_spec.rb +11 -0
- data/spec/spec_helper.rb +12 -0
- metadata +169 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'xdg'
|
4
|
+
gem 'ohai'
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.1.0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.5.1"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
extlib (0.9.15)
|
6
|
+
git (1.2.5)
|
7
|
+
jeweler (1.5.1)
|
8
|
+
bundler (~> 1.0.0)
|
9
|
+
git (>= 1.2.5)
|
10
|
+
rake
|
11
|
+
json (1.4.6)
|
12
|
+
mixlib-cli (1.2.0)
|
13
|
+
mixlib-config (1.1.2)
|
14
|
+
mixlib-log (1.2.0)
|
15
|
+
ohai (0.5.8)
|
16
|
+
extlib
|
17
|
+
json (>= 1.4.4, <= 1.4.6)
|
18
|
+
mixlib-cli
|
19
|
+
mixlib-config
|
20
|
+
mixlib-log
|
21
|
+
systemu
|
22
|
+
rake (0.8.7)
|
23
|
+
rcov (0.9.9)
|
24
|
+
rspec (2.1.0)
|
25
|
+
rspec-core (~> 2.1.0)
|
26
|
+
rspec-expectations (~> 2.1.0)
|
27
|
+
rspec-mocks (~> 2.1.0)
|
28
|
+
rspec-core (2.1.0)
|
29
|
+
rspec-expectations (2.1.0)
|
30
|
+
diff-lcs (~> 1.1.2)
|
31
|
+
rspec-mocks (2.1.0)
|
32
|
+
systemu (1.2.0)
|
33
|
+
xdg (1.0.0)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (~> 1.0.0)
|
40
|
+
jeweler (~> 1.5.1)
|
41
|
+
ohai
|
42
|
+
rcov
|
43
|
+
rspec (~> 2.1.0)
|
44
|
+
xdg
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Antono Vasiljev
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= shellcast
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to shellcast
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Antono Vasiljev. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "shellcast"
|
16
|
+
gem.homepage = "http://github.com/antono/shellcast"
|
17
|
+
gem.license = "GPL"
|
18
|
+
gem.summary = %Q{Record and distribute shellcasts}
|
19
|
+
gem.description = %Q{Screencast utility for unix shell junkies :)}
|
20
|
+
gem.email = "antono.vasiljev@gmail.com"
|
21
|
+
gem.authors = ["Antono Vasiljev"]
|
22
|
+
end
|
23
|
+
Jeweler::RubygemsDotOrgTasks.new
|
24
|
+
|
25
|
+
require 'rspec/core'
|
26
|
+
require 'rspec/core/rake_task'
|
27
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
28
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
29
|
+
end
|
30
|
+
|
31
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
32
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
33
|
+
spec.rcov = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "shellcast #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/shellcast
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'shellcast'
|
7
|
+
|
8
|
+
case ARGV[0]
|
9
|
+
when 'record'
|
10
|
+
ShellCast::Recorder.record!
|
11
|
+
when 'list'
|
12
|
+
ShellCast::Player.list
|
13
|
+
when 'play'
|
14
|
+
if ARGV[1]
|
15
|
+
ShellCast::Player.play(ARGV[1])
|
16
|
+
else
|
17
|
+
puts "Missing id for shellcast"
|
18
|
+
ShellCast::Player.list
|
19
|
+
puts "Select one..."
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
else
|
23
|
+
puts "Usage: #{__FILE__} command [shellcast_id]"
|
24
|
+
puts "Commands: record, list, play, publish, get"
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ShellCast
|
2
|
+
class Player
|
3
|
+
def self.play(id)
|
4
|
+
new(id).play
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.list
|
8
|
+
Dir[File.join(ShellCast::DATA_DIR, "**", 'meta')].each do |path|
|
9
|
+
metadata = YAML.load_file(path)
|
10
|
+
puts "#{metadata["id"]}: #{metadata["title"]}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(id)
|
15
|
+
@shellcast_id = id
|
16
|
+
end
|
17
|
+
|
18
|
+
def play
|
19
|
+
puts ""
|
20
|
+
puts "Playback started"
|
21
|
+
puts "-" * 80
|
22
|
+
system(scriptreplay_cmd)
|
23
|
+
puts
|
24
|
+
puts "-" * 80
|
25
|
+
puts "Playback finished"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def shellcast_file(name)
|
31
|
+
File.join(ShellCast.shellcast_dir(@shellcast_id), name)
|
32
|
+
end
|
33
|
+
|
34
|
+
def scriptreplay_cmd
|
35
|
+
"scriptreplay #{shellcast_file('timing')} #{shellcast_file('data')}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module ShellCast
|
2
|
+
class Recorder
|
3
|
+
|
4
|
+
def self.record!
|
5
|
+
new.record!
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@meta = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def record!
|
13
|
+
FileUtils.mkdir_p(shellcast_dir) unless File.exists?(shellcast_dir)
|
14
|
+
request_metadata
|
15
|
+
puts "Your session started"
|
16
|
+
puts "Type Ctrl+D or exit to finish recording"
|
17
|
+
puts "-" * 80
|
18
|
+
init_terminal
|
19
|
+
system(script_cmd)
|
20
|
+
restore_terminal
|
21
|
+
puts "-" * 80
|
22
|
+
puts "Session finihed!"
|
23
|
+
puts "Shellcast ID:\t #{shellcast_id}"
|
24
|
+
puts "Shellcast path:\t #{shellcast_dir}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def request_metadata
|
28
|
+
puts "Provide name for Your shellcast: "
|
29
|
+
@meta["title"] = STDIN.gets.strip
|
30
|
+
@meta["id"] = shellcast_id
|
31
|
+
puts shellcast_file('meta')
|
32
|
+
File.open(shellcast_file('meta'), 'w+') do |meta|
|
33
|
+
meta.puts @meta.to_yaml
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def init_terminal
|
40
|
+
stty_data = `stty -a`
|
41
|
+
@user_columns = stty_data.match(/columns (\d+)/)[1]
|
42
|
+
@user_rows = stty_data.match(/rows (\d+)/)[1]
|
43
|
+
puts "Saved terminal size #{@user_columns}X#{@user_rows}"
|
44
|
+
system("stty columns 80 rows 24")
|
45
|
+
end
|
46
|
+
|
47
|
+
def restore_terminal
|
48
|
+
system("stty columns #{@user_columns} rows #{@user_rows}")
|
49
|
+
end
|
50
|
+
|
51
|
+
def shellcast_dir
|
52
|
+
@shellcast_dir ||= ShellCast.shellcast_dir(shellcast_id)
|
53
|
+
end
|
54
|
+
|
55
|
+
def shellcast_id
|
56
|
+
@shellcast_id ||= Time.now.to_i.to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
def shellcast_file(name)
|
60
|
+
File.join(ShellCast.shellcast_dir(shellcast_id), name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def script_cmd
|
64
|
+
"script -c 'bash' #{shellcast_file('data')} -t 2> #{shellcast_file('timing')}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/shellcast.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'xdg'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module ShellCast
|
7
|
+
|
8
|
+
APP_NAME = 'shellcast'
|
9
|
+
DATA_DIR = File.join(XDG::Data.home, APP_NAME)
|
10
|
+
|
11
|
+
def shellcast_dir(shellcast_id)
|
12
|
+
File.join(ShellCast::DATA_DIR, shellcast_id)
|
13
|
+
end
|
14
|
+
module_function :shellcast_dir
|
15
|
+
|
16
|
+
autoload :Recorder, 'shellcast/recorder.rb'
|
17
|
+
autoload :Player, 'shellcast/player.rb'
|
18
|
+
autoload :Publisher, 'shellcast/publisher.rb'
|
19
|
+
|
20
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ShellCast do
|
4
|
+
it "should have ::APP_NAME defined" do
|
5
|
+
ShellCast::APP_NAME.should == 'shellcast'
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should provide XDG and APP_NAME based ::DATA_DIR" do
|
9
|
+
ShellCast::DATA_DIR.should == File.join(XDG::Data.home, ShellCast::APP_NAME)
|
10
|
+
end
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'shellcast'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shellcast
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Antono Vasiljev
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-06 00:00:00 +02:00
|
18
|
+
default_executable: shellcast
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: xdg
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ohai
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 2
|
56
|
+
- 1
|
57
|
+
- 0
|
58
|
+
version: 2.1.0
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id003
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: bundler
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 1
|
71
|
+
- 0
|
72
|
+
- 0
|
73
|
+
version: 1.0.0
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: jeweler
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ~>
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 1
|
86
|
+
- 5
|
87
|
+
- 1
|
88
|
+
version: 1.5.1
|
89
|
+
type: :development
|
90
|
+
version_requirements: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: rcov
|
93
|
+
prerelease: false
|
94
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id006
|
104
|
+
description: Screencast utility for unix shell junkies :)
|
105
|
+
email: antono.vasiljev@gmail.com
|
106
|
+
executables:
|
107
|
+
- shellcast
|
108
|
+
extensions: []
|
109
|
+
|
110
|
+
extra_rdoc_files:
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.rdoc
|
113
|
+
files:
|
114
|
+
- .document
|
115
|
+
- .rspec
|
116
|
+
- Gemfile
|
117
|
+
- Gemfile.lock
|
118
|
+
- LICENSE.txt
|
119
|
+
- README.rdoc
|
120
|
+
- Rakefile
|
121
|
+
- VERSION
|
122
|
+
- bin/shellcast
|
123
|
+
- lib/shellcast.rb
|
124
|
+
- lib/shellcast/player.rb
|
125
|
+
- lib/shellcast/publisher.rb
|
126
|
+
- lib/shellcast/recorder.rb
|
127
|
+
- spec/shellcast/player_spec.rb
|
128
|
+
- spec/shellcast/publisher_spec.rb
|
129
|
+
- spec/shellcast/recorder_spec.rb
|
130
|
+
- spec/shellcast_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
has_rdoc: true
|
133
|
+
homepage: http://github.com/antono/shellcast
|
134
|
+
licenses:
|
135
|
+
- GPL
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
version: "0"
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
requirements: []
|
158
|
+
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.3.7
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Record and distribute shellcasts
|
164
|
+
test_files:
|
165
|
+
- spec/shellcast/player_spec.rb
|
166
|
+
- spec/shellcast/publisher_spec.rb
|
167
|
+
- spec/shellcast/recorder_spec.rb
|
168
|
+
- spec/shellcast_spec.rb
|
169
|
+
- spec/spec_helper.rb
|