shelr 0.11.8 → 0.11.9
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/.rbenv-version +1 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +11 -4
- data/bin/shelr +13 -4
- data/features/recording.feature +1 -1
- data/lib/shelr/publisher.rb +34 -6
- data/lib/shelr/version.rb +1 -1
- data/shelr.1 +5 -1
- data/shelr.1.ronn +3 -0
- data/spec/fixtures/record1.json +1 -0
- data/spec/shelr/publisher_spec.rb +33 -2
- data/spec/shelr/recorder_spec.rb +3 -3
- data/spec/spec_helper.rb +7 -3
- metadata +7 -11
data/.rbenv-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p125
|
data/Gemfile
CHANGED
@@ -3,9 +3,11 @@ source "http://rubygems.org"
|
|
3
3
|
gem 'json'
|
4
4
|
|
5
5
|
group :development, :test do
|
6
|
+
gem "pry"
|
7
|
+
gem "pry-nav"
|
8
|
+
gem "rspec"
|
6
9
|
gem "rspec"
|
7
10
|
gem "aruba", :git => 'git://github.com/cucumber/aruba.git'
|
8
|
-
gem "mocha"
|
9
11
|
gem "bundler"
|
10
12
|
gem "jeweler"
|
11
13
|
gem "simplecov"
|
data/Gemfile.lock
CHANGED
@@ -14,6 +14,7 @@ GEM
|
|
14
14
|
builder (3.0.0)
|
15
15
|
childprocess (0.3.1)
|
16
16
|
ffi (~> 1.0.6)
|
17
|
+
coderay (1.0.5)
|
17
18
|
cucumber (1.1.9)
|
18
19
|
builder (>= 2.1.2)
|
19
20
|
diff-lcs (>= 1.1.2)
|
@@ -31,10 +32,14 @@ GEM
|
|
31
32
|
rake
|
32
33
|
rdoc
|
33
34
|
json (1.6.5)
|
34
|
-
|
35
|
-
mocha (0.10.5)
|
36
|
-
metaclass (~> 0.0.1)
|
35
|
+
method_source (0.7.1)
|
37
36
|
multi_json (1.1.0)
|
37
|
+
pry (0.9.8.2)
|
38
|
+
coderay (~> 1.0.5)
|
39
|
+
method_source (~> 0.7)
|
40
|
+
slop (>= 2.4.4, < 3)
|
41
|
+
pry-nav (0.1.0)
|
42
|
+
pry (~> 0.9.8.1)
|
38
43
|
rake (0.9.2.2)
|
39
44
|
rdoc (3.12)
|
40
45
|
json (~> 1.4)
|
@@ -50,6 +55,7 @@ GEM
|
|
50
55
|
multi_json (~> 1.0)
|
51
56
|
simplecov-html (~> 0.5.3)
|
52
57
|
simplecov-html (0.5.3)
|
58
|
+
slop (2.4.4)
|
53
59
|
term-ansicolor (1.0.7)
|
54
60
|
|
55
61
|
PLATFORMS
|
@@ -60,6 +66,7 @@ DEPENDENCIES
|
|
60
66
|
bundler
|
61
67
|
jeweler
|
62
68
|
json
|
63
|
-
|
69
|
+
pry
|
70
|
+
pry-nav
|
64
71
|
rspec
|
65
72
|
simplecov
|
data/bin/shelr
CHANGED
@@ -19,6 +19,11 @@ HELP = <<-HELP
|
|
19
19
|
push last - publish last record
|
20
20
|
push RECORD_ID - publish
|
21
21
|
|
22
|
+
Getting record as json:
|
23
|
+
|
24
|
+
dump last - dump last record as json to current dir
|
25
|
+
dump RECORD_ID - dump any record as json to current dir
|
26
|
+
|
22
27
|
Replaying:
|
23
28
|
|
24
29
|
list - print list of records
|
@@ -53,7 +58,14 @@ when 'play'
|
|
53
58
|
puts "Missing id for shellcast"
|
54
59
|
Shelr::Player.list
|
55
60
|
puts "Select one..."
|
56
|
-
|
61
|
+
end
|
62
|
+
when 'dump'
|
63
|
+
if ARGV[1]
|
64
|
+
Shelr::Publisher.new.dump(ARGV[1])
|
65
|
+
else
|
66
|
+
puts "What do you want to dump?"
|
67
|
+
Shelr::Player.list
|
68
|
+
puts "Select one..."
|
57
69
|
end
|
58
70
|
when 'push'
|
59
71
|
if ARGV[1]
|
@@ -62,21 +74,18 @@ when 'push'
|
|
62
74
|
puts "What do you want to publish?"
|
63
75
|
Shelr::Player.list
|
64
76
|
puts "Select one..."
|
65
|
-
exit
|
66
77
|
end
|
67
78
|
when 'setup'
|
68
79
|
if ARGV[1]
|
69
80
|
Shelr.api_key = ARGV[1]
|
70
81
|
else
|
71
82
|
puts "\n\tUsage: #{BASENAME} setup API_KEY\n\n"
|
72
|
-
exit
|
73
83
|
end
|
74
84
|
when 'backend'
|
75
85
|
if ARGV[1]
|
76
86
|
Shelr.backend = ARGV[1]
|
77
87
|
else
|
78
88
|
puts "\n\tUsage: #{BASENAME} backend [ttyrec|script]\n\n"
|
79
|
-
exit
|
80
89
|
end
|
81
90
|
when 'version'
|
82
91
|
puts Shelr::VERSION
|
data/features/recording.feature
CHANGED
data/lib/shelr/publisher.rb
CHANGED
@@ -5,10 +5,34 @@ module Shelr
|
|
5
5
|
class Publisher
|
6
6
|
|
7
7
|
def publish(id)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
with_exception_handler do
|
9
|
+
uri = URI.parse(Shelr::API_URL + '/records')
|
10
|
+
params = { 'record' => prepare(id) }
|
11
|
+
params.merge!({'api_key' => Shelr.api_key}) if api_key
|
12
|
+
handle_response Net::HTTP.post_form(uri, params)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def dump(id)
|
17
|
+
with_exception_handler do
|
18
|
+
File.open(dump_filename, 'w+') do |f|
|
19
|
+
f.puts(prepare(id))
|
20
|
+
end
|
21
|
+
puts "=> record dumped to #{dump_filename}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def with_exception_handler(&block)
|
28
|
+
yield
|
29
|
+
rescue => e
|
30
|
+
puts "=> Something went wrong..."
|
31
|
+
puts e.message
|
32
|
+
puts e.backtrace.join("\n")
|
33
|
+
end
|
34
|
+
|
35
|
+
def handle_response(res)
|
12
36
|
res = JSON.parse(res.body)
|
13
37
|
if res['ok']
|
14
38
|
puts res['message']
|
@@ -18,6 +42,10 @@ module Shelr
|
|
18
42
|
end
|
19
43
|
end
|
20
44
|
|
45
|
+
def dump_filename
|
46
|
+
File.join(Dir.getwd, 'shelr-record.json')
|
47
|
+
end
|
48
|
+
|
21
49
|
def api_key
|
22
50
|
unless Shelr.api_key
|
23
51
|
print 'Paste your API KEY [or Enter to publish as Anonymous]: '
|
@@ -29,8 +57,8 @@ module Shelr
|
|
29
57
|
|
30
58
|
def prepare(id)
|
31
59
|
puts
|
32
|
-
puts 'Your record will be published under terms'
|
33
|
-
puts '
|
60
|
+
puts 'Your record will be published under terms of'
|
61
|
+
puts 'Creative Commons Attribution-ShareAlike 3.0 Unported'
|
34
62
|
puts 'See http://creativecommons.org/licenses/by-sa/3.0/ for details.'
|
35
63
|
puts
|
36
64
|
|
data/lib/shelr/version.rb
CHANGED
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" "
|
4
|
+
.TH "SHELR" "1" "March 2012" "" ""
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBshelr\fR \- screencasting for shell ninjas
|
@@ -33,6 +33,10 @@ plays local or remote shellcast\.
|
|
33
33
|
\fBpush\fR
|
34
34
|
publish your shellcast
|
35
35
|
.
|
36
|
+
.TP
|
37
|
+
\fBdump\fR
|
38
|
+
dump shellcast as json to current directory\.
|
39
|
+
.
|
36
40
|
.SH "EXAMPLES"
|
37
41
|
Record your shellcast:
|
38
42
|
.
|
data/shelr.1.ronn
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"timing":"0.117451 100\n2.245175 1\n0.645616 1\n0.131508 2\n0.265617 41\n0.006015 198\n0.002213 174\n0.000021 100\n0.045656 1\n1.635819 1\n0.158412 1\n0.438685 1\n0.408513 4\n1.611577 41\n0.005889 100\n0.053797 6\n","typescript":"Script started on Sun 25 Mar 2012 02:09:04 PM FET\n\u001b]0;antono@libero ~/Code/shelr.tv \u0007\u001b[0;36m(\u001b[0;32mnext \u001b[0;31m✗\u001b[0;36m)\u001b[39m \u001b[0;36mshelr.tv\u001b[39m ls\r\n\u001b]0;ls {~/Code/shelr.tv} (antono@libero)\u0007\u001b[0m\u001b[01;34mapp\u001b[0m config.ru \u001b[01;34mdoc\u001b[0m Gemfile.lock Guardfile \u001b[01;34mlog\u001b[0m Rakefile \u001b[01;32mrun.sh\u001b[0m \u001b[01;34msolr\u001b[0m tags \u001b[01;34mtmp\u001b[0m \u001b[01;34mvendor\u001b[0m\r\n\u001b[01;34mconfig\u001b[0m \u001b[01;34mdb\u001b[0m Gemfile gems.tags \u001b[01;34mlib\u001b[0m \u001b[01;34mpublic\u001b[0m README.md \u001b[01;34mscript\u001b[0m \u001b[01;34mspec\u001b[0m TAGS TODO.org\r\n\u001b]0;antono@libero ~/Code/shelr.tv \u0007\u001b[0;36m(\u001b[0;32mnext \u001b[0;31m✗\u001b[0;36m)\u001b[39m \u001b[0;36mshelr.tv\u001b[39m yo !^C\r\n\u001b]0;ls {~/Code/shelr.tv} (antono@libero)\u0007\u001b]0;antono@libero ~/Code/shelr.tv \u0007\u001b[0;36m(\u001b[0;32mnext \u001b[0;31m✗\u001b[0;36m)\u001b[39m \u001b[0;36mshelr.tv\u001b[39m exit\r\n\nScript done on Sun 25 Mar 2012 02:09:12 PM FET\n","title":"hello fixture","created_at":"1332673740","columns":"141","rows":"40","description":"hello fixture","tags":"fixture, linux"}
|
@@ -1,9 +1,40 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shelr::Publisher do
|
4
|
+
before :each do
|
5
|
+
File.stub(:open)
|
6
|
+
Net::HTTP.stub(:post_form)
|
7
|
+
end
|
8
|
+
|
4
9
|
describe "#publish(id)" do
|
5
|
-
it "should
|
6
|
-
|
10
|
+
it "should prepare record as json" do
|
11
|
+
STDIN.stub(:gets).and_return('something')
|
12
|
+
subject.stub(:handle_response)
|
13
|
+
subject.stub(:prepare).and_return(fixture('record1.json'))
|
14
|
+
subject.should_receive(:prepare).with('hello')
|
15
|
+
|
16
|
+
subject.publish('hello')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#dump_filename" do
|
21
|
+
it "should return `pwd` + /shelr-record.json" do
|
22
|
+
subject.send(:dump_filename).should == File.join(Dir.getwd, 'shelr-record.json')
|
7
23
|
end
|
8
24
|
end
|
25
|
+
|
26
|
+
describe "#dump(id)" do
|
27
|
+
before :each do
|
28
|
+
@file = mock('dump file')
|
29
|
+
File.stub(:open).and_yield @file
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should save prepared dump to #dump_filename" do
|
33
|
+
File.should_receive(:open).with(subject.send(:dump_filename), 'w+')
|
34
|
+
subject.should_receive(:prepare).with('hello').and_return('dump')
|
35
|
+
@file.should_receive(:puts).with('dump')
|
36
|
+
subject.dump('hello')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
9
40
|
end
|
data/spec/shelr/recorder_spec.rb
CHANGED
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Shelr::Recorder do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
STDIN.
|
6
|
+
STDIN.stub(:gets).and_return('my shellcast')
|
7
7
|
Shelr.backend = 'script'
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#record!" do
|
11
11
|
before(:each) do
|
12
|
-
subject.
|
12
|
+
subject.stub(:system).with(anything).and_return(true)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should start script session" do
|
16
|
-
subject.
|
16
|
+
subject.should_receive("system").with(Regexp.compile("script"))
|
17
17
|
subject.record!
|
18
18
|
end
|
19
19
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -23,12 +23,16 @@ require 'rspec'
|
|
23
23
|
require 'shelr'
|
24
24
|
require "rubygems"
|
25
25
|
require "bundler/setup"
|
26
|
+
require 'pry'
|
27
|
+
require 'pry-nav'
|
26
28
|
|
27
29
|
# Requires supporting files with custom matchers and macros, etc,
|
28
30
|
# in ./support/ and its subdirectories.
|
29
31
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
def fixture(name)
|
34
|
+
file = File.join(File.expand_path("../fixtures/#{name}", __FILE__))
|
35
|
+
require 'pp'
|
36
|
+
pp file
|
37
|
+
JSON.parse(File.read(file))
|
34
38
|
end
|
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.11.
|
4
|
+
version: 0.11.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-03-
|
14
|
+
date: 2012-03-25 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|
18
|
-
requirement: &
|
18
|
+
requirement: &16036960 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
version: 1.6.5
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *16036960
|
27
27
|
description: Screencast utility for unix shell junkies
|
28
28
|
email: self@antono.info
|
29
29
|
executables:
|
@@ -32,6 +32,7 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- .gitignore
|
35
|
+
- .rbenv-version
|
35
36
|
- .rspec
|
36
37
|
- .rvmrc
|
37
38
|
- Gemfile
|
@@ -53,6 +54,7 @@ files:
|
|
53
54
|
- shelr.1
|
54
55
|
- shelr.1.ronn
|
55
56
|
- shelr.gemspec
|
57
|
+
- spec/fixtures/record1.json
|
56
58
|
- spec/shelr/player_spec.rb
|
57
59
|
- spec/shelr/publisher_spec.rb
|
58
60
|
- spec/shelr/recorder_spec.rb
|
@@ -71,21 +73,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
73
|
- - ! '>='
|
72
74
|
- !ruby/object:Gem::Version
|
73
75
|
version: '0'
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
hash: 218875704179376272
|
77
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
77
|
none: false
|
79
78
|
requirements:
|
80
79
|
- - ! '>='
|
81
80
|
- !ruby/object:Gem::Version
|
82
81
|
version: '0'
|
83
|
-
segments:
|
84
|
-
- 0
|
85
|
-
hash: 218875704179376272
|
86
82
|
requirements: []
|
87
83
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.11
|
89
85
|
signing_key:
|
90
86
|
specification_version: 3
|
91
87
|
summary: Screencasts for Shell Ninjas
|