shellplay 0.0.2
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/.gitignore +25 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +14 -0
- data/bin/scenario.json +26 -0
- data/bin/shellplay +92 -0
- data/bin/shellrecord +56 -0
- data/lib/shellplay/config.rb +23 -0
- data/lib/shellplay/screen.rb +33 -0
- data/lib/shellplay/session.rb +79 -0
- data/lib/shellplay/version.rb +3 -0
- data/lib/shreplay.rb +5 -0
- data/shellplay.gemspec +28 -0
- data/spec/files/session.json +21 -0
- data/spec/lib/shellplay/screen_spec.rb +35 -0
- data/spec/lib/shellplay/session_spec.rb +34 -0
- data/spec/spec_helper.rb +22 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0dd9968b1001b7c9aaa8d706da0b9a32c78017d9
|
4
|
+
data.tar.gz: 3d8673ed9eb51653bf21760d3ab3d71404a27cc1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f20cf6a046e7f0e1b02a17355eb1f5e0ff513d482c816cd2afb67a000a88e6a1203f6d42d3b179e80e167bcbaefdcec01af5434b6731e4fccbe1370f1b853af3
|
7
|
+
data.tar.gz: 796df7f9e7e338401b366524a297357e4ef2715b100d0aeefa81b197a4a808798d11c2c26ab0b676f57b46fb1bd1ef9bb3db5aaf5912c16de9205299cce847df
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
/vendor
|
24
|
+
*.sublime-project
|
25
|
+
*.sublime-workspace
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.2
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Shellplay Changelog
|
2
|
+
=========================
|
3
|
+
|
4
|
+
v0.0.2 - 2014-08-10
|
5
|
+
---------------
|
6
|
+
|
7
|
+
- made recorder and player more or less working
|
8
|
+
- changed project name twice. First shellprez, then shreplay, finally shellplay rocks better
|
9
|
+
|
10
|
+
v0.0.1 - 2014-08-08
|
11
|
+
------------------
|
12
|
+
|
13
|
+
- just initial code
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 mose
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
Shellplay
|
2
|
+
==================
|
3
|
+
|
4
|
+
This is a CLI tool for recording and presenting step by step operations from the console. It is targeted at presentations that would simulate live coding, without the random murphy factor of it.
|
5
|
+
|
6
|
+
It can record a session and playback from it, so if internet fails in your conference room you are safe.
|
7
|
+
|
8
|
+
**Note: this is a work inprogress, nothing there to be seen yet, except for reading code.**
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
gem install shellplay
|
13
|
+
|
14
|
+
The first time you run it, some configuration variables will be asked, and stored in `$HOME/.shellplay/config.yml`. All the recorded sessions will be stored in that same directory.
|
15
|
+
|
16
|
+
## Recording a session
|
17
|
+
|
18
|
+
For recording a session
|
19
|
+
|
20
|
+
shellrecord
|
21
|
+
|
22
|
+
Then type the commands you want to record, amd type q at the end it will prompt you for a file name and a title.
|
23
|
+
|
24
|
+
The session file is stored in json format and can be used to be played
|
25
|
+
|
26
|
+
## Playing a session
|
27
|
+
|
28
|
+
For playing
|
29
|
+
|
30
|
+
shellplay <session_file_name>
|
31
|
+
|
32
|
+
or just
|
33
|
+
|
34
|
+
shellplay
|
35
|
+
|
36
|
+
If you don't specify the name of the session, all locally available sessions will be displayed and you will be asked to chose one.
|
37
|
+
|
38
|
+
Then type enter to go next, or `?` to display list of available commands.
|
39
|
+
|
40
|
+
## Todo
|
41
|
+
|
42
|
+
- when prototype is ready, switch to v0.1.0
|
43
|
+
- test coverage
|
44
|
+
- save and load sessions from gist
|
45
|
+
- add gist token to config or something
|
46
|
+
- ponder about using the curses lib
|
47
|
+
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create a feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create a new Pull Request
|
56
|
+
|
57
|
+
## Copyright
|
58
|
+
|
59
|
+
(c) Copyright 2014 mose. Distributed under MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
desc 'launch rspec tests'
|
7
|
+
task :spec do
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
9
|
+
t.rspec_opts = ['-c', '-f progress', '-r ./spec/spec_helper.rb']
|
10
|
+
t.pattern = 'spec/lib/**/*_spec.rb'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
task default: :spec
|
data/bin/scenario.json
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"title": "test prez",
|
3
|
+
"prompt": "\e[30;40mrecord >\e[0m ",
|
4
|
+
"content": [
|
5
|
+
{
|
6
|
+
"prompt": true,
|
7
|
+
"command": "ls",
|
8
|
+
"output": "bin CHANGELOG.md Gemfile Gemfile.lock lib LICENSE.txt Rakefile README.md shellprez.gemspec spec vendor"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"prompt": true,
|
12
|
+
"command": "ll",
|
13
|
+
"output": "total 72\n-rw-r--r--+ 1 mose staff 3.5K Aug 8 14:15 CHANGELOG.md\n-rw-r--r--+ 1 mose staff 103B Sep 18 2013 Gemfile\n-rw-r--r--+ 1 mose staff 1.0K Dec 25 2013 Gemfile.lock\n-rw-r--r--+ 1 mose staff 1.1K Sep 23 2013 LICENSE.txt\n-rw-r--r--+ 1 mose staff 11K Aug 8 14:16 README.md\n-rw-r--r--+ 1 mose staff 497B Sep 23 2013 Rakefile\ndrwxr-xr-x+ 3 mose staff 102B Sep 18 2013 bin\ndrwxr-xr-x+ 4 mose staff 136B Oct 25 2013 coverage\ndrwxr-xr-x+ 4 mose staff 136B Oct 30 2013 lib\ndrwxr-xr-x+ 12 mose staff 408B Dec 25 2013 pkg\ndrwxr-xr-x+ 5 mose staff 170B Oct 23 2013 spec\ndrwxr-xr-x+ 3 mose staff 102B Sep 18 2013 templates\ndrwxr-xr-x+ 4 mose staff 136B Jan 21 2014 vendor\n-rw-r--r--+ 1 mose staff 1.1K Nov 9 2013 zabbix-ruby-client.gemspec\ndrwxr-xr-x+ 18 mose staff 612B Aug 8 15:42 zabbix-templates"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"prompt": true,
|
17
|
+
"command": "tree spec/lib/",
|
18
|
+
"output": "spec/lib/\n├── cli_spec.rb\n├── data_spec.rb\n├── files\n│ └── logs\n├── logger_spec.rb\n├── plugin_base_spec.rb\n├── plugins\n│ ├── apache_spec.rb\n│ ├── apt_spec.rb\n│ ├── cpu_spec.rb\n│ ├── disk_spec.rb\n│ ├── load_spec.rb\n│ ├── memory_spec.rb\n│ └── network_spec.rb\n├── plugins_spec.rb\n├── runner_spec.rb\n└── store_spec.rb\n\n3 directories, 14 files"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"prompt": true,
|
22
|
+
"command": "head README.md",
|
23
|
+
"output": "Zabbix Ruby Client"
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
data/bin/shellplay
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'paint'
|
4
|
+
require 'json'
|
5
|
+
require 'open3'
|
6
|
+
|
7
|
+
|
8
|
+
lib = File.expand_path('../../lib', __FILE__)
|
9
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
10
|
+
|
11
|
+
require 'shellplay/session'
|
12
|
+
|
13
|
+
@session = Shellplay::Session.new
|
14
|
+
@session.import(ARGV[0])
|
15
|
+
|
16
|
+
continue = true
|
17
|
+
@sleeptime = 1.0/48.0
|
18
|
+
@lastelapsed = 0
|
19
|
+
|
20
|
+
counter = 1
|
21
|
+
def usage
|
22
|
+
puts "\nCommands: "
|
23
|
+
puts " h,? show help"
|
24
|
+
puts " s list screens"
|
25
|
+
puts " s# jump to screen #"
|
26
|
+
puts " <enter> jump to next screen"
|
27
|
+
puts " p jump to previous screen"
|
28
|
+
puts " <command> execute a subcommand in a bash -l -c"
|
29
|
+
puts " x,q quit"
|
30
|
+
puts
|
31
|
+
end
|
32
|
+
|
33
|
+
def display(screen)
|
34
|
+
print @session.config.prompt
|
35
|
+
sleep @sleeptime
|
36
|
+
print screen.stdin
|
37
|
+
STDIN.gets
|
38
|
+
puts screen.stdout
|
39
|
+
puts Paint[screen.stderr, :red]
|
40
|
+
@lastelapsed = screen.timespent
|
41
|
+
end
|
42
|
+
|
43
|
+
def shownext
|
44
|
+
if @session.current_screen and @session.current_screen.stdin
|
45
|
+
display @session.current_screen
|
46
|
+
@session.next
|
47
|
+
else
|
48
|
+
puts "You are at the end of the session."
|
49
|
+
@lastelapsed = 0
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def show(index)
|
54
|
+
if @session.show(index).stdin
|
55
|
+
display @session.show(index)
|
56
|
+
@session.next
|
57
|
+
else
|
58
|
+
puts "You are at the end of the session."
|
59
|
+
@lastelapsed = 0
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
while continue do
|
64
|
+
printf "\e[36m>\e[0m "
|
65
|
+
printf "\e[35melapsed: #{@lastelapsed}s\e[0m " unless @lastelapsed == 0
|
66
|
+
command = STDIN.gets.strip
|
67
|
+
case command
|
68
|
+
when /^(?:q|x)$/
|
69
|
+
puts "\nPlay ended.\n"
|
70
|
+
continue = false
|
71
|
+
when /^(?:\?|h)$/
|
72
|
+
usage
|
73
|
+
when /^s$/
|
74
|
+
@session.sequence.map { |c| c.stdin }.each_with_index do |l, i|
|
75
|
+
printf(" s%-3s %s\n", i, l)
|
76
|
+
end
|
77
|
+
when /s([0-9]+)/
|
78
|
+
show($1)
|
79
|
+
when ''
|
80
|
+
shownext
|
81
|
+
else
|
82
|
+
Open3.popen3("bash","-l","-c",command.strip) do |i, o, e, t|
|
83
|
+
o.read.split("\n").each do |line|
|
84
|
+
puts line
|
85
|
+
sleep sleeptime
|
86
|
+
end
|
87
|
+
e.read.split("\n").each do |line|
|
88
|
+
puts Paint[line, :red]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/bin/shellrecord
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'paint'
|
4
|
+
require 'open3'
|
5
|
+
|
6
|
+
lib = File.expand_path('../../lib', __FILE__)
|
7
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
8
|
+
|
9
|
+
require 'shellplay/session'
|
10
|
+
|
11
|
+
continue = true
|
12
|
+
sleeptime = 1.0/60.0
|
13
|
+
sleeptime = 0
|
14
|
+
|
15
|
+
session = Shellplay::Session.new
|
16
|
+
prompt = "\e[36mrecord >\e[0m"
|
17
|
+
|
18
|
+
while continue do
|
19
|
+
printf("\e[36mrecord >\e[33m %d > \e[0m", session.pointer)
|
20
|
+
command = STDIN.gets.strip
|
21
|
+
if command == "q"
|
22
|
+
session.save
|
23
|
+
puts "\nRecord ended.\n"
|
24
|
+
continue = false
|
25
|
+
else
|
26
|
+
if command[0] == '#'
|
27
|
+
command = command[1..-1].strip
|
28
|
+
displaycommand = false
|
29
|
+
else
|
30
|
+
displaycommand = true
|
31
|
+
end
|
32
|
+
start_time = Time.now
|
33
|
+
Open3.popen3("bash","-l","-c",command) do |i, o, e, t|
|
34
|
+
screen = Shellplay::Screen.new
|
35
|
+
out = o.read
|
36
|
+
err = e.read
|
37
|
+
end_time = Time.now
|
38
|
+
elapsed = end_time - start_time
|
39
|
+
session.add_screen({
|
40
|
+
'displaycommand' => displaycommand,
|
41
|
+
'stdin' => command,
|
42
|
+
'stdout' => out,
|
43
|
+
'stderr' => err,
|
44
|
+
'timespent' => elapsed
|
45
|
+
})
|
46
|
+
out.split("\n").each do |line|
|
47
|
+
puts line
|
48
|
+
sleep sleeptime
|
49
|
+
end
|
50
|
+
err.split("\n").each do |line|
|
51
|
+
puts Paint[line, :red]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
session.next
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'cliprompt'
|
2
|
+
require 'configstruct'
|
3
|
+
|
4
|
+
module Shellplay
|
5
|
+
class Config < ConfigStruct
|
6
|
+
|
7
|
+
include Cliprompt
|
8
|
+
|
9
|
+
def set_defaults
|
10
|
+
default :basedir, File.join(ENV['HOME'], '.shellplay')
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def setup
|
15
|
+
values = {}
|
16
|
+
output.puts Paint['Create a new shellplay configuration:', :blue]
|
17
|
+
values['editor'] = guess 'EDITOR', 'What is the path to launch your text editor?', 'vim'
|
18
|
+
values['prompt'] = ask 'What is the default prompt you want to use?'
|
19
|
+
write values
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Shellplay
|
2
|
+
class Screen
|
3
|
+
|
4
|
+
attr_reader :stdin, :stdout, :stderr, :display, :timespent
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@displaycommand = true
|
8
|
+
@stdin = nil
|
9
|
+
@stdout = nil
|
10
|
+
@stderr = nil
|
11
|
+
@timespent = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def import(hash)
|
15
|
+
@displaycommand = hash['displaycommand']
|
16
|
+
@stdin = hash['stdin']
|
17
|
+
@stdout = hash['stdout']
|
18
|
+
@stderr = hash['stderr']
|
19
|
+
@timespent = hash['timespent']
|
20
|
+
end
|
21
|
+
|
22
|
+
def export
|
23
|
+
{
|
24
|
+
displaycommand: @displaycommand,
|
25
|
+
stdin: @stdin,
|
26
|
+
stdout: @stdout,
|
27
|
+
stderr: @stderr,
|
28
|
+
timespent: @timespent
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require "cliprompt"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
require "shellplay/config"
|
5
|
+
require "shellplay/screen"
|
6
|
+
|
7
|
+
module Shellplay
|
8
|
+
class Session
|
9
|
+
|
10
|
+
include Cliprompt
|
11
|
+
|
12
|
+
attr_reader :title, :config, :pointer, :sequence
|
13
|
+
|
14
|
+
def initialize(input = STDIN, output = STDOUT)
|
15
|
+
@sequence = []
|
16
|
+
@title = false
|
17
|
+
@config = Shellplay::Config.new(nil, input, output)
|
18
|
+
@pointer = 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def import(name)
|
22
|
+
name ||= ask "What session do you want to load?",
|
23
|
+
aslist: true,
|
24
|
+
choices: Dir.glob(File.join(@config.basedir, '*.json')).map { |f| File.basename(f, '.json') }
|
25
|
+
infile = File.join(@config.basedir, "#{name}.json")
|
26
|
+
data = JSON.parse(IO.read(infile))
|
27
|
+
@title = data['title']
|
28
|
+
data['sequence'].each do |screenhash|
|
29
|
+
add_screen(screenhash)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_screen(screenhash)
|
34
|
+
s = Shellplay::Screen.new
|
35
|
+
s.import(screenhash)
|
36
|
+
@sequence << s
|
37
|
+
end
|
38
|
+
|
39
|
+
def next
|
40
|
+
@pointer += 1
|
41
|
+
end
|
42
|
+
|
43
|
+
def show(index)
|
44
|
+
@pointer = index.to_i
|
45
|
+
current_screen
|
46
|
+
end
|
47
|
+
|
48
|
+
def current_screen
|
49
|
+
@sequence[@pointer]
|
50
|
+
end
|
51
|
+
|
52
|
+
def save
|
53
|
+
prepare
|
54
|
+
h = {}
|
55
|
+
h[:title] = @title
|
56
|
+
h[:sequence] = @sequence.map(&:export)
|
57
|
+
outfile = File.join(@config.basedir, "#{@name}.json")
|
58
|
+
File.open(outfile, 'w') do |f|
|
59
|
+
f.write JSON.dump(h)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def prepare
|
64
|
+
set_title
|
65
|
+
set_name
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def set_title
|
71
|
+
@title ||= ask("What is the title of this session?", "No Title")
|
72
|
+
end
|
73
|
+
|
74
|
+
def set_name
|
75
|
+
@name ||= ask("What is the name of the session file?", "untitled")
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
data/lib/shreplay.rb
ADDED
data/shellplay.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "shellplay"
|
7
|
+
spec.version = File.read(File.expand_path('../CHANGELOG.md', __FILE__))[/([0-9]+\.[0-9]+\.[0-9]+)/]
|
8
|
+
spec.authors = ["mose"]
|
9
|
+
spec.email = ["mose@mose.com"]
|
10
|
+
spec.summary = %q{CLI tool for shell-based presentations.}
|
11
|
+
spec.description = %q{CLI tool for shell-based presentation. Think powerpoint in the console for commandline demos.}
|
12
|
+
spec.homepage = "https://github.com/mose/shellplay"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency 'paint'
|
21
|
+
spec.add_dependency 'cliprompt'
|
22
|
+
spec.add_dependency 'configstruct'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
spec.add_development_dependency 'coveralls'
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"title": "test prez",
|
3
|
+
"sequence": [
|
4
|
+
{
|
5
|
+
"stdin": "ls",
|
6
|
+
"sdtout": "bin CHANGELOG.md Gemfile Gemfile.lock lib LICENSE.txt Rakefile README.md shellprez.gemspec spec vendor"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"stdin": "ll",
|
10
|
+
"sdtout": "total 72\n-rw-r--r--+ 1 mose staff 3.5K Aug 8 14:15 CHANGELOG.md\n-rw-r--r--+ 1 mose staff 103B Sep 18 2013 Gemfile\n-rw-r--r--+ 1 mose staff 1.0K Dec 25 2013 Gemfile.lock\n-rw-r--r--+ 1 mose staff 1.1K Sep 23 2013 LICENSE.txt\n-rw-r--r--+ 1 mose staff 11K Aug 8 14:16 README.md\n-rw-r--r--+ 1 mose staff 497B Sep 23 2013 Rakefile\ndrwxr-xr-x+ 3 mose staff 102B Sep 18 2013 bin\ndrwxr-xr-x+ 4 mose staff 136B Oct 25 2013 coverage\ndrwxr-xr-x+ 4 mose staff 136B Oct 30 2013 lib\ndrwxr-xr-x+ 12 mose staff 408B Dec 25 2013 pkg\ndrwxr-xr-x+ 5 mose staff 170B Oct 23 2013 spec\ndrwxr-xr-x+ 3 mose staff 102B Sep 18 2013 templates\ndrwxr-xr-x+ 4 mose staff 136B Jan 21 2014 vendor\n-rw-r--r--+ 1 mose staff 1.1K Nov 9 2013 zabbix-ruby-client.gemspec\ndrwxr-xr-x+ 18 mose staff 612B Aug 8 15:42 zabbix-templates"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"stdin": "tree spec/lib/",
|
14
|
+
"sdtout": "spec/lib/\n├── cli_spec.rb\n├── data_spec.rb\n├── files\n│ └── logs\n├── logger_spec.rb\n├── plugin_base_spec.rb\n├── plugins\n│ ├── apache_spec.rb\n│ ├── apt_spec.rb\n│ ├── cpu_spec.rb\n│ ├── disk_spec.rb\n│ ├── load_spec.rb\n│ ├── memory_spec.rb\n│ └── network_spec.rb\n├── plugins_spec.rb\n├── runner_spec.rb\n└── store_spec.rb\n\n3 directories, 14 files"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"stdin": "head README.md",
|
18
|
+
"sdtout": "Zabbix Ruby Client"
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require "shellplay/screen"
|
4
|
+
|
5
|
+
describe Shellplay::Screen, "A typical screen element" do
|
6
|
+
|
7
|
+
let(:goodhash) {
|
8
|
+
{
|
9
|
+
"timespent" => 0.123,
|
10
|
+
"stdin" => "ls -1",
|
11
|
+
"stdout" => "bin\nCHANGELOG.md\nGemfile\n"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
subject { Shellplay::Screen.new }
|
16
|
+
|
17
|
+
describe ".import" do
|
18
|
+
|
19
|
+
context "when we import a valid hash, " do
|
20
|
+
before { subject.import(goodhash) }
|
21
|
+
it "fills up instance variables from a hash" do
|
22
|
+
expect(subject.stdin).to eq goodhash['stdin']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when we import an empty hash, " do
|
27
|
+
before { subject.import({}) }
|
28
|
+
it "inits the variables with false values" do
|
29
|
+
expect(subject.stdin).to be_falsey
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require "shellplay/session"
|
4
|
+
|
5
|
+
describe Shellplay::Session, "A shellplay session" do
|
6
|
+
|
7
|
+
let(:sessionfile) { File.expand_path('../../../files/session.json', __FILE__)}
|
8
|
+
let(:input) { StringIO.new }
|
9
|
+
let(:output) { StringIO.new }
|
10
|
+
subject { Shellplay::Session.new(input, output) }
|
11
|
+
|
12
|
+
describe '.new' do
|
13
|
+
context 'when there is no prior configuration file, ' do
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".import" do
|
18
|
+
|
19
|
+
context "when we import a valid file, " do
|
20
|
+
before { subject.import(sessionfile) }
|
21
|
+
it "fills up instance variables from the file" do
|
22
|
+
expect(subject.title).to eq "test prez"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when we import an invalid file, " do
|
27
|
+
it "should break and throw exception" do
|
28
|
+
expect { subject.import('/file/notfound') }.to raise_error
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler'
|
4
|
+
|
5
|
+
if ENV['COV']
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.profiles.define :app do
|
8
|
+
add_filter '/vendor/'
|
9
|
+
add_filter '/spec/'
|
10
|
+
end
|
11
|
+
SimpleCov.start :app
|
12
|
+
else
|
13
|
+
require 'coveralls'
|
14
|
+
Coveralls.wear!
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.mock_with :rspec
|
19
|
+
config.expect_with :rspec do |c|
|
20
|
+
c.syntax = :expect
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shellplay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mose
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: paint
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cliprompt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: configstruct
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: CLI tool for shell-based presentation. Think powerpoint in the console
|
112
|
+
for commandline demos.
|
113
|
+
email:
|
114
|
+
- mose@mose.com
|
115
|
+
executables:
|
116
|
+
- scenario.json
|
117
|
+
- shellplay
|
118
|
+
- shellrecord
|
119
|
+
extensions: []
|
120
|
+
extra_rdoc_files: []
|
121
|
+
files:
|
122
|
+
- ".gitignore"
|
123
|
+
- ".ruby-version"
|
124
|
+
- CHANGELOG.md
|
125
|
+
- Gemfile
|
126
|
+
- LICENSE.txt
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- bin/scenario.json
|
130
|
+
- bin/shellplay
|
131
|
+
- bin/shellrecord
|
132
|
+
- lib/shellplay/config.rb
|
133
|
+
- lib/shellplay/screen.rb
|
134
|
+
- lib/shellplay/session.rb
|
135
|
+
- lib/shellplay/version.rb
|
136
|
+
- lib/shreplay.rb
|
137
|
+
- shellplay.gemspec
|
138
|
+
- spec/files/session.json
|
139
|
+
- spec/lib/shellplay/screen_spec.rb
|
140
|
+
- spec/lib/shellplay/session_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
homepage: https://github.com/mose/shellplay
|
143
|
+
licenses:
|
144
|
+
- MIT
|
145
|
+
metadata: {}
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
requirements: []
|
161
|
+
rubyforge_project:
|
162
|
+
rubygems_version: 2.2.2
|
163
|
+
signing_key:
|
164
|
+
specification_version: 4
|
165
|
+
summary: CLI tool for shell-based presentations.
|
166
|
+
test_files:
|
167
|
+
- spec/files/session.json
|
168
|
+
- spec/lib/shellplay/screen_spec.rb
|
169
|
+
- spec/lib/shellplay/session_spec.rb
|
170
|
+
- spec/spec_helper.rb
|