shellplay 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/bin/shellplay +2 -2
- data/lib/shellplay/config.rb +10 -7
- data/lib/shellplay/session.rb +15 -9
- data/spec/files/{session.json → config/session.json} +2 -0
- data/spec/lib/shellplay/session_spec.rb +4 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 188691449457664d2cd0d87dd5dfac9ea87ba211
|
4
|
+
data.tar.gz: bfb44ea0af4cee6b0c03f2157a00e64a4a4a2b84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee3d60f66dc90cbbb3b92261f51d33e5cae7fc78b44d418eecba5d81c20b65783eeafe4ce7f9f5a914b1d001821ae318168daab44770c5e9ba5122a495b32c57
|
7
|
+
data.tar.gz: 378068c3c353337bb1b6f533b39849b969df862de90bc9693901370a8feecbaa28474d7548d525ffe359e546bce79a11c320f41bcbfec5b7dc3b3ce8d8b0e96c
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
Shellplay Changelog
|
2
2
|
=========================
|
3
3
|
|
4
|
+
v0.1.1 - 2014-08-17
|
5
|
+
--------------------
|
6
|
+
- remove the need for input of prompt and timeformat if they are included in the session
|
7
|
+
|
4
8
|
v0.1.0 - 2014-08-17
|
5
9
|
----------------------
|
6
10
|
- first version seems ok, it's running and has been used on the field
|
data/bin/shellplay
CHANGED
@@ -42,7 +42,7 @@ def display(screen)
|
|
42
42
|
if screen.customprompt
|
43
43
|
print screen.customprompt
|
44
44
|
else
|
45
|
-
print @session.
|
45
|
+
print @session.config.prompt
|
46
46
|
end
|
47
47
|
sleep @sleeptime
|
48
48
|
print screen.stdin
|
@@ -127,6 +127,6 @@ while continue do
|
|
127
127
|
end
|
128
128
|
if @playprompt
|
129
129
|
print "\n\e[33m>\e[0m "
|
130
|
-
printf("\e[33melapsed: \e[0m\e[1;93m#{@session.
|
130
|
+
printf("\e[33melapsed: \e[0m\e[1;93m#{@session.config.timeformat}s\e[0m ", @lastelapsed) unless @lastelapsed == 0
|
131
131
|
end
|
132
132
|
end
|
data/lib/shellplay/config.rb
CHANGED
@@ -8,21 +8,24 @@ module Shellplay
|
|
8
8
|
include Cliprompt
|
9
9
|
|
10
10
|
def initialize(options = nil, input = STDIN, output = STDOUT)
|
11
|
-
super(options
|
11
|
+
super(options, input = STDIN, output = STDOUT)
|
12
12
|
end
|
13
13
|
|
14
14
|
def set_defaults
|
15
15
|
default :basedir, File.join(ENV['HOME'], '.shellplay')
|
16
|
+
default :basefile, File.join(self.basedir, 'config.yml')
|
16
17
|
super
|
17
18
|
end
|
18
19
|
|
19
20
|
def setup
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
unless self.prompt && self.timeformat
|
22
|
+
values = {}
|
23
|
+
output.puts Paint['Create a new shellplay configuration:', :blue]
|
24
|
+
#values['editor'] = guess 'EDITOR', 'What is the path to launch your text editor?', 'vim'
|
25
|
+
values['prompt'] = ask 'What is the default prompt you want to use?', "\e[36m #{ENV['USER']} > \e[0m"
|
26
|
+
values['timeformat'] = ask 'What is the time format you want to display?', '%.1f'
|
27
|
+
write values
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
end
|
data/lib/shellplay/session.rb
CHANGED
@@ -12,24 +12,27 @@ module Shellplay
|
|
12
12
|
|
13
13
|
attr_reader :title, :config, :pointer, :sequence, :prompt, :timeformat
|
14
14
|
|
15
|
-
def initialize(input = STDIN, output = STDOUT)
|
15
|
+
def initialize(basedir = nil, basefile = nil, input = STDIN, output = STDOUT)
|
16
16
|
@sequence = []
|
17
17
|
@title = false
|
18
18
|
@prompt = false
|
19
19
|
@timeformat = false
|
20
|
-
@config = Shellplay::Config.new(nil, input, output)
|
21
20
|
@pointer = 0
|
21
|
+
@basedir = basedir || File.join(ENV['HOME'], '.shellplay')
|
22
|
+
@basefile = basefile || 'config.yml'
|
23
|
+
@input = input
|
24
|
+
@output = output
|
22
25
|
end
|
23
26
|
|
24
27
|
def import(name)
|
25
28
|
unless name
|
26
|
-
sessions = Dir.glob(File.join(@
|
29
|
+
sessions = Dir.glob(File.join(@basedir, '*.json'))
|
27
30
|
if sessions.count == 0
|
28
|
-
puts "There is no recorded session locally."
|
29
|
-
puts "Do you want to play a remote recording?"
|
31
|
+
@output.puts "There is no recorded session locally."
|
32
|
+
@output.puts "Do you want to play a remote recording?"
|
30
33
|
name = ask "url: "
|
31
34
|
else
|
32
|
-
puts "What session do you want to load?"
|
35
|
+
@output.puts "What session do you want to load?"
|
33
36
|
name = ask "(input a number or an url if you want to play a remote recording)",
|
34
37
|
aslist: true,
|
35
38
|
choices: sessions.map { |f| File.basename(f, '.json') }
|
@@ -38,12 +41,15 @@ module Shellplay
|
|
38
41
|
if /^https?:\/\//.match name
|
39
42
|
infile = open(name) { |f| f.read }
|
40
43
|
else
|
41
|
-
infile = IO.read(File.join(@
|
44
|
+
infile = IO.read(File.join(@basedir, "#{name}.json"))
|
42
45
|
end
|
43
46
|
data = JSON.parse(infile)
|
44
47
|
@title = data['title']
|
45
|
-
@
|
46
|
-
|
48
|
+
@config = Shellplay::Config.new({
|
49
|
+
basedir: @basedir,
|
50
|
+
basefile: File.join(@basedir, @basefile),
|
51
|
+
prompt: data['prompt'],
|
52
|
+
timeformat: data['timeformat'] }, input, output)
|
47
53
|
data['sequence'].each do |screenhash|
|
48
54
|
add_screen(screenhash)
|
49
55
|
end
|
@@ -4,10 +4,11 @@ require "shellplay/session"
|
|
4
4
|
|
5
5
|
describe Shellplay::Session, "A shellplay session" do
|
6
6
|
|
7
|
-
let(:
|
7
|
+
let(:basedir) { File.expand_path('../../../files/config', __FILE__) }
|
8
|
+
let(:basefile) { 'session.json' }
|
8
9
|
let(:input) { StringIO.new }
|
9
10
|
let(:output) { StringIO.new }
|
10
|
-
subject { Shellplay::Session.new(input, output) }
|
11
|
+
subject { Shellplay::Session.new(basedir, basefile, input, output) }
|
11
12
|
|
12
13
|
describe '.new' do
|
13
14
|
context 'when there is no prior configuration file, ' do
|
@@ -17,7 +18,7 @@ describe Shellplay::Session, "A shellplay session" do
|
|
17
18
|
describe ".import" do
|
18
19
|
|
19
20
|
context "when we import a valid file, " do
|
20
|
-
before
|
21
|
+
before { subject.import('session') }
|
21
22
|
it "fills up instance variables from the file" do
|
22
23
|
expect(subject.title).to eq "test prez"
|
23
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shellplay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mose
|
@@ -136,7 +136,7 @@ files:
|
|
136
136
|
- lib/shellplay/screen.rb
|
137
137
|
- lib/shellplay/session.rb
|
138
138
|
- shellplay.gemspec
|
139
|
-
- spec/files/session.json
|
139
|
+
- spec/files/config/session.json
|
140
140
|
- spec/lib/shellplay/screen_spec.rb
|
141
141
|
- spec/lib/shellplay/session_spec.rb
|
142
142
|
- spec/spec_helper.rb
|
@@ -166,7 +166,7 @@ signing_key:
|
|
166
166
|
specification_version: 4
|
167
167
|
summary: CLI tool for shell-based presentations.
|
168
168
|
test_files:
|
169
|
-
- spec/files/session.json
|
169
|
+
- spec/files/config/session.json
|
170
170
|
- spec/lib/shellplay/screen_spec.rb
|
171
171
|
- spec/lib/shellplay/session_spec.rb
|
172
172
|
- spec/spec_helper.rb
|