Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Private records!

 - delegate url generation to server
 - push last --private switch
 - indented docs
  • Loading branch information...
commit 42778f5f76780436a0a90e62c49c6af893f0008b 1 parent 7d12318
@antono antono authored
View
41 bin/shelr
@@ -10,34 +10,37 @@ HELP = <<-HELP
Usage: #{BASENAME} command [arg]
- Recording:
+ COMMANDS:
- record - record new shellcast
+ Recording:
- Publishing:
+ record - record new shellcast
- push last - publish last record
- push RECORD_ID - publish
+ Publishing:
- Getting record as json:
+ push last - publish last record
+ push last --private - publish private record
+ push RECORD_ID - publish record with given id
- dump last - dump last record as json to current dir
- dump RECORD_ID - dump any record as json to current dir
+ Getting record as json:
- Replaying:
+ dump last - dump last record as json to current dir
+ dump RECORD_ID - dump any record as json to current dir
- list - print list of records
- play last - play last local record
- play RECORD_ID - play local record
- play RECORD_URL - play remote record
- play dump.json - play local file dumped with `shelr dump`
+ Replaying:
- Setup:
+ list - print list of records
+ play last - play last local record
+ play RECORD_ID - play local record
+ play RECORD_URL - play remote record
+ play dump.json - play local file dumped with `shelr dump`
- setup API_KEY - set your API key
- backend [ttyrec|script] - setup recorder backend
+ Setup:
- Visit: http://shelr.tv/ for more info.
+ setup API_KEY - set your API key
+ backend [ttyrec|script] - setup recorder backend
+
+ Visit: http://shelr.tv/ for more info.
HELP
@@ -75,7 +78,7 @@ when 'dump'
end
when 'push'
if ARGV[1]
- Shelr::Publisher.new.publish(ARGV[1])
+ Shelr::Publisher.new.publish(ARGV[1], ARGV[2] == '--private')
else
puts "What do you want to publish?"
Shelr::Player.list
View
3  lib/shelr/player.rb
@@ -64,6 +64,9 @@ def play
STDOUT.puts "-=" * (Shelr.terminal.size[:width] / 2)
end
+ def scriptreplay(typescript, timing)
+ end
+
private
def record_file(name)
View
20 lib/shelr/publisher.rb
@@ -4,7 +4,8 @@
module Shelr
class Publisher
- def publish(id)
+ def publish(id, priv = false)
+ @private = priv
ensure_unlocked(id)
with_exception_handler do
uri = URI.parse(Shelr::API_URL + '/records')
@@ -30,7 +31,7 @@ def ensure_unlocked(id)
if File.exist?(lock_path)
puts "=> Cannot publish the record (make sure it finished with exit or Ctrl+D)"
puts "=> Record locked on #{File.read(lock_path)}"
- puts "=> Esure no other shelr process running"
+ puts "=> Make sure no other shelr process running (ps axu | grep shelr)"
puts "=> Or remove lock file manually: #{lock_path}"
exit 0
end
@@ -45,12 +46,14 @@ def with_exception_handler(&block)
end
def handle_response(res)
- res = JSON.parse(res.body)
- if res['ok']
- STDOUT.puts res['message']
- STDOUT.puts Shelr::API_URL + '/records/' + res['id']
- else
- STDOUT.puts res['message']
+ with_exception_handler do
+ res = JSON.parse(res.body)
+ if res['ok']
+ STDOUT.puts "=> " + res['message'].to_s
+ STDOUT.puts "=> " + res['url'].to_s
+ else
+ STDOUT.puts res['message']
+ end
end
end
@@ -85,6 +88,7 @@ def prepare(id)
out['description'] = STDIN.gets.strip
STDOUT.print 'Tags (ex: howto, linux): '
out['tags'] = STDIN.gets.strip
+ out['private'] = @private
return out.to_json
end
end
View
12 spec/shelr/recorder_spec.rb
@@ -5,6 +5,7 @@
before do
STDIN.stub(:gets).and_return('my shellcast')
Shelr.backend = 'script'
+ # disable term size guard
STDOUT.stub(:puts)
STDOUT.stub(:print)
end
@@ -13,6 +14,7 @@
before do
subject.stub(:system).with(anything).and_return(true)
subject.stub(:record_id => "1")
+ subject.stub(:ensure_terminal_has_good_size)
subject.stub(:with_lock_file).and_yield
end
@@ -49,9 +51,9 @@
end
it "adds XDG_CURRENT_DESKTOP to @meta as xdg_current_desktop" do
- subject.stub(:record_id => 'ololo')
+ ENV['XDG_CURRENT_DESKTOP'] = 'united-kde-gnome-shell'
subject.request_metadata
- subject.meta["recorded_at"].should == 'ololo'
+ subject.meta["xdg_current_desktop"].should == 'united-kde-gnome-shell'
end
it "reads title from stdin" do
@@ -69,4 +71,10 @@
subject.user_columns.should == 10
end
end
+
+ describe "#scriptreplay(typescript, timing)" do
+ it "reads typescript" do
+ File.stub(:read)
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.