shelr 0.11.2 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3
data/Gemfile CHANGED
@@ -1,9 +1,10 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- group :development do
3
+ group :development, :test do
4
4
  gem "rspec"
5
+ gem "aruba", :git => 'git://github.com/cucumber/aruba.git'
5
6
  gem "mocha"
6
7
  gem "bundler"
7
8
  gem "jeweler"
8
- gem "rcov"
9
+ gem "simplecov"
9
10
  end
data/Gemfile.lock CHANGED
@@ -1,31 +1,64 @@
1
+ GIT
2
+ remote: git://github.com/cucumber/aruba.git
3
+ revision: fabc92edc45bf42b5747a0937dd31511d4ab774a
4
+ specs:
5
+ aruba (0.4.11)
6
+ childprocess (>= 0.2.3)
7
+ cucumber (>= 1.1.1)
8
+ ffi (>= 1.0.11)
9
+ rspec (>= 2.7.0)
10
+
1
11
  GEM
2
12
  remote: http://rubygems.org/
3
13
  specs:
4
- diff-lcs (1.1.2)
14
+ builder (3.0.0)
15
+ childprocess (0.3.1)
16
+ ffi (~> 1.0.6)
17
+ cucumber (1.1.9)
18
+ builder (>= 2.1.2)
19
+ diff-lcs (>= 1.1.2)
20
+ gherkin (~> 2.9.0)
21
+ json (>= 1.4.6)
22
+ term-ansicolor (>= 1.0.6)
23
+ diff-lcs (1.1.3)
24
+ ffi (1.0.11)
25
+ gherkin (2.9.0)
26
+ json (>= 1.4.6)
5
27
  git (1.2.5)
6
- jeweler (1.6.4)
28
+ jeweler (1.8.3)
7
29
  bundler (~> 1.0)
8
30
  git (>= 1.2.5)
9
31
  rake
10
- mocha (0.9.9)
11
- rake
12
- rake (0.9.2)
13
- rcov (0.9.9)
14
- rspec (2.1.0)
15
- rspec-core (~> 2.1.0)
16
- rspec-expectations (~> 2.1.0)
17
- rspec-mocks (~> 2.1.0)
18
- rspec-core (2.1.0)
19
- rspec-expectations (2.1.0)
32
+ rdoc
33
+ json (1.6.5)
34
+ metaclass (0.0.1)
35
+ mocha (0.10.5)
36
+ metaclass (~> 0.0.1)
37
+ multi_json (1.1.0)
38
+ rake (0.9.2.2)
39
+ rdoc (3.12)
40
+ json (~> 1.4)
41
+ rspec (2.8.0)
42
+ rspec-core (~> 2.8.0)
43
+ rspec-expectations (~> 2.8.0)
44
+ rspec-mocks (~> 2.8.0)
45
+ rspec-core (2.8.0)
46
+ rspec-expectations (2.8.0)
20
47
  diff-lcs (~> 1.1.2)
21
- rspec-mocks (2.1.0)
48
+ rspec-mocks (2.8.0)
49
+ simplecov (0.6.1)
50
+ multi_json (~> 1.0)
51
+ simplecov-html (~> 0.5.3)
52
+ simplecov-html (0.5.3)
53
+ term-ansicolor (1.0.7)
22
54
 
23
55
  PLATFORMS
24
56
  ruby
25
57
 
26
58
  DEPENDENCIES
59
+ aruba!
27
60
  bundler
28
61
  jeweler
29
62
  mocha
30
- rcov
31
63
  rspec
64
+ simplecov
data/README.md CHANGED
@@ -22,7 +22,7 @@ PKGBUILD: https://aur.archlinux.org/packages.php?ID=56945
22
22
 
23
23
  ## Watching other's records
24
24
 
25
- shelr play http://shelr.tv/records/4d1c5458905ba77eb7000002
25
+ shelr play http://shelr.tv/records/4f4ca2a43cd1090001000002.json
26
26
 
27
27
  You can watch them online at [http://shelr.tv/][TV]
28
28
 
@@ -42,12 +42,22 @@ You can watch them online at [http://shelr.tv/][TV]
42
42
 
43
43
  ## Dependencies
44
44
 
45
+ ### Linux/BSD/Hurd/etc...
46
+
45
47
  You need `script` and `scriptreplay` tools from BSD Utils.
46
48
  Tey are already installed if You use Debian/Ubuntu/BSD variants.
47
- Not sure about other OSes.
49
+
50
+ ### OSX
51
+
52
+ If You use OS X - install `ttyrec` via homebrew and setup it as recording backend.
53
+
54
+ brew install ttyrec
55
+ shelr backend ttyrec
48
56
 
49
57
  ## Copyright
50
58
 
51
59
  Copyright (c) 2010, 2011, 2012 Antono Vasiljev. See LICENSE.txt for details.
52
60
 
61
+ [![endorse](http://api.coderwall.com/antono/endorsecount.png)](http://coderwall.com/antono)
62
+
53
63
  [TV]: http://shelr.tv/ "Shellcasts from shell ninjas"
data/Rakefile CHANGED
@@ -15,8 +15,8 @@ Jeweler::Tasks.new do |gem|
15
15
  gem.name = "shelr"
16
16
  gem.homepage = "http://shelr.tv/"
17
17
  gem.license = "GPLv3"
18
- gem.summary = %Q{Screencasts for Shell Ninjas}
19
- gem.description = %Q{Screencast utility for unix shell junkies :)}
18
+ gem.summary = "Screencasts for Shell Ninjas"
19
+ gem.description = "Screencast utility for unix shell junkies"
20
20
  gem.email = "self@antono.info"
21
21
  gem.authors = ["Antono Vasiljev", "Pete Clark"]
22
22
  end
data/TODO.org CHANGED
@@ -1,13 +1,13 @@
1
1
  * DONE Remove dependencies for easier packaging
2
- * TODO Port to termrec or ttyrec
2
+ * DONE Port to termrec or ttyrec
3
3
  git clone http://angband.pl/git/termrec
4
4
  http://angband.pl/termrec.html
5
- * TODO Port Figlet from artii gem to ruby 1.9.2
6
- and use it instead hardcoded headers and footers
7
- * TODO Think about terminal setup before shellcasting
5
+ * DONE Think about terminal setup before shellcasting
8
6
  * TODO Take in account suggestions from playterm
9
7
  be sure to set your terminal width/height to 80x24 or 120x35
10
8
  to get rid of your prompt type 'export PS1="playterm $ "'
11
9
  if you want to turn off wordwrap in your terminal type: echo -e "\e[?7l\c"
12
10
  sometimes it helps to type 'export TERM=vt100' again before you start the real deal
13
11
  use CTRL-C to prevent commentary text (for instructing the user) being processed
12
+ * TODO Port Figlet from artii gem to ruby 1.9.2
13
+ and use it instead hardcoded headers and footers
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.2
1
+ 0.11.3
data/bin/shelr CHANGED
@@ -39,7 +39,7 @@ case ARGV[0]
39
39
  when '-h', '--help'
40
40
  puts HELP
41
41
  when 'record'
42
- Shelr::Recorder.record!
42
+ Shelr::Recorder.record!
43
43
  when 'list'
44
44
  Shelr::Player.list
45
45
  when 'play'
@@ -0,0 +1,20 @@
1
+ Feature: Recording shell
2
+
3
+ In order to impress the world
4
+ As a `shelr` user
5
+ I would like to record my terminal
6
+
7
+ Background:
8
+ Given shelr backend is script
9
+
10
+ Scenario: Basic recording
11
+ When I run `shelr record` interactively
12
+ And I type "test screencast"
13
+ And I type "ls"
14
+ # FIXME: wtf with nested processes?
15
+ And I type "exit"
16
+ Then the stdout should contain "Provide HUMAN NAME for Your record: "
17
+ And the stdout should contain "Press Ctrl+D or 'exit' to finish recording"
18
+ And the stdout should contain "Replay : shelr play last"
19
+ And the stdout should contain "Publish : shelr push last"
20
+ And the stdout should contain "Your session started"
@@ -0,0 +1,38 @@
1
+ When /^I do shelr (.*)$/ do |shelr_step|
2
+ begin
3
+ step(shelr_step)
4
+ rescue => e
5
+ @shelr_exception = e
6
+ end
7
+ end
8
+
9
+ # Useful for debugging timing problems
10
+ When /^sleep (\d+)$/ do |time|
11
+ sleep time.to_i
12
+ end
13
+
14
+ Given /^shelr backend is (\w+)$/ do |backend|
15
+ step "I run `shelr backend #{backend}`"
16
+ end
17
+
18
+ When /^I set env variable "(\w+)" to "([^"]*)"$/ do |var, value|
19
+ ENV[var] = value
20
+ end
21
+
22
+ Then /^aruba should fail with "([^"]*)"$/ do |error_message|
23
+ @shelr_exception.message.should include(unescape(error_message))
24
+ end
25
+
26
+ Then /^the following step should fail with Spec::Expectations::ExpectationNotMetError:$/ do |multiline_step|
27
+ proc { steps multiline_step }.should raise_error(RSpec::Expectations::ExpectationNotMetError)
28
+ end
29
+
30
+ Then /^the output should be (\d+) bytes long$/ do |length|
31
+ all_output.chomp.length.should == length.to_i
32
+ end
33
+
34
+ When /^show me the output$/ do
35
+
36
+ require 'pp'
37
+ pp all_output
38
+ end
@@ -0,0 +1,12 @@
1
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
2
+
3
+ require "rubygems"
4
+ require "bundler/setup"
5
+ require 'aruba/cucumber'
6
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec/spec_helper.rb')
7
+
8
+ # Aruba.configure do |config|
9
+ # config.before_cmd do |cmd|
10
+ # puts "About to run `#{cmd}`"
11
+ # end
12
+ # end
@@ -33,7 +33,7 @@ module Shelr
33
33
  request_metadata
34
34
  puts HEADER
35
35
  puts "Your session started"
36
- puts "Type Ctrl+D or exit to finish recording"
36
+ puts "Press Ctrl+D or 'exit' to finish recording"
37
37
  system(recorder_cmd)
38
38
  restore_terminal
39
39
  save_as_typescript if Shelr.backend == 'ttyrec'
data/lib/shelr.rb CHANGED
@@ -3,12 +3,14 @@ require 'json'
3
3
 
4
4
  module Shelr
5
5
 
6
- APP_NAME = 'shelr'
7
- DATA_DIR = File.join(ENV['HOME'], '.local', 'share', APP_NAME)
8
- CONFIG_DIR = File.join(ENV['HOME'], '.config', APP_NAME)
9
- API_KEY = File.join(CONFIG_DIR, 'api_key')
10
- API_URL = ENV['SHELR_LOCAL'] ? 'http://localhost:3000' : 'http://shelr.tv'
11
- BACKEND_CFG = File.join(CONFIG_DIR, 'backend')
6
+ APP_NAME = 'shelr'
7
+ API_URL = ENV['SHELR_LOCAL'] ? 'http://localhost:3000' : 'http://shelr.tv'
8
+ XDG_DATA_DIR = ENV['XDG_DATA_HOME'] || File.join(ENV['HOME'], '.local', 'share')
9
+ XDG_CONFIG_DIR = ENV['XDG_CONFIG_HOME'] || File.join(ENV['HOME'], '.config')
10
+ DATA_DIR = File.join(XDG_DATA_DIR, APP_NAME)
11
+ CONFIG_DIR = File.join(XDG_CONFIG_DIR, APP_NAME)
12
+ API_KEY_CFG = File.join(CONFIG_DIR, 'api_key')
13
+ BACKEND_CFG = File.join(CONFIG_DIR, 'backend')
12
14
 
13
15
  autoload :Recorder, 'shelr/recorder.rb'
14
16
  autoload :Player, 'shelr/player.rb'
@@ -17,13 +19,13 @@ module Shelr
17
19
 
18
20
  class << self
19
21
  def api_key
20
- return false unless File.exist?(API_KEY)
21
- @api_key ||= File.read(API_KEY).strip
22
+ return false unless File.exist?(API_KEY_CFG)
23
+ @api_key ||= File.read(API_KEY_CFG).strip
22
24
  end
23
25
 
24
26
  def api_key=(key)
25
27
  ensure_config_dir_exist
26
- File.open(API_KEY, 'w+') { |f| f.puts(key.strip) }
28
+ File.open(API_KEY_CFG, 'w+') { |f| f.puts(key.strip) }
27
29
  end
28
30
 
29
31
  def backend
@@ -31,17 +33,21 @@ module Shelr
31
33
  end
32
34
 
33
35
  def backend=(bin)
36
+ unless ['script', 'ttyrec'].include?(bin)
37
+ puts "Backend should be either `script` or `ttyrec`"
38
+ exit 1
39
+ end
34
40
  ensure_config_dir_exist
35
41
  File.open(BACKEND_CFG, 'w+') { |f| f.puts(bin.strip) }
36
42
  end
37
43
 
38
44
  def data_dir(record_id)
39
45
  id = record_id.strip == 'last' ? last_id : record_id.to_s
40
- File.join(Shelr::DATA_DIR, id)
46
+ File.join(DATA_DIR, id)
41
47
  end
42
48
 
43
49
  def last_id
44
- File.basename(Dir[File.join(Shelr::DATA_DIR, '*')].sort.last)
50
+ File.basename(Dir[File.join(DATA_DIR, '*')].sort.last)
45
51
  end
46
52
 
47
53
  private
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Shelr::Publisher do
4
4
  describe "#publish(id)" do
5
- it "should publish shellcast with oauth" do
5
+ it "should publish shellcast with API_KEY" do
6
6
  pending
7
7
  end
8
8
  end
@@ -4,38 +4,17 @@ describe Shelr::Recorder do
4
4
 
5
5
  before(:each) do
6
6
  STDIN.stubs(:gets).returns('my shellcast')
7
+ Shelr.backend = 'script'
7
8
  end
8
9
 
9
10
  describe "#record!" do
10
-
11
11
  before(:each) do
12
12
  subject.stubs(:system).with(anything).returns(true)
13
13
  end
14
14
 
15
- it "should set tty to 80x24" do
16
- subject.expects("system").with(regexp_matches(/stty columns 80 rows 24/))
17
- subject.record!
18
- end
19
-
20
- it "should restore tty to user defined values" do
21
- subject.expects(:restore_terminal)
22
- subject.record!
23
- end
24
-
25
15
  it "should start script session" do
26
- subject.expects("system").with(regexp_matches Regexp.compile("script -c 'bash'"))
16
+ subject.expects("system").with(regexp_matches Regexp.compile("script"))
27
17
  subject.record!
28
18
  end
29
19
  end
30
-
31
- describe "#restore_terminal" do
32
- it "should call tty with saved dimensions" do
33
- subject.expects(:system).with(
34
- all_of(regexp_matches(/stty/),
35
- regexp_matches(/columns/),
36
- regexp_matches(/rows/))
37
- )
38
- subject.send :restore_terminal
39
- end
40
- end
41
20
  end
data/spec/shelr_spec.rb CHANGED
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe Shelr do
4
4
  it "should have ::APP_NAME defined" do
5
- Shelr::APP_NAME.should == 'shelr'
5
+ Shelr::APP_NAME.should_not be_nil
6
6
  end
7
7
 
8
8
  it "should provide XDG and APP_NAME based ::DATA_DIR" do
9
- Shelr::DATA_DIR.should == File.join(XDG['DATA_HOME'].to_s, Shelr::APP_NAME)
9
+ Shelr::DATA_DIR.should == File.join(ENV['XDG_DATA_HOME'], Shelr::APP_NAME)
10
10
  end
11
11
 
12
12
  it "should provide XDG config path" do
13
- Shelr::CONFIG_DIR.should == File.join(XDG['CONFIG_HOME'].to_s, Shelr::APP_NAME)
13
+ Shelr::CONFIG_DIR.should == File.join(ENV['XDG_CONFIG_HOME'], Shelr::APP_NAME)
14
14
  end
15
15
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,24 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'fileutils'
5
+ require 'pathname'
6
+ require 'tmpdir'
7
+
8
+ # XDG directories
9
+ shelr_dir = File.join(Dir.tmpdir, 'shelr')
10
+ FileUtils.mkdir_p(shelr_dir)
11
+
12
+ TEMPDIR = Pathname.new Dir.mktmpdir('test', shelr_dir)
13
+ XDG_DATA_DIR = TEMPDIR.join('.local', 'share')
14
+ XDG_CONFIG_DIR = TEMPDIR.join('.config')
15
+
16
+ FileUtils.mkdir_p(XDG_DATA_DIR)
17
+ FileUtils.mkdir_p(XDG_CONFIG_DIR)
18
+
19
+ ENV['XDG_DATA_HOME'] = XDG_DATA_DIR.to_s
20
+ ENV['XDG_CONFIG_HOME'] = XDG_CONFIG_DIR.to_s
21
+
3
22
  require 'rspec'
4
23
  require 'shelr'
5
24
  require "rubygems"
@@ -9,6 +28,7 @@ require "bundler/setup"
9
28
  # in ./support/ and its subdirectories.
10
29
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
30
 
31
+
12
32
  RSpec.configure do |config|
13
33
  config.mock_with :mocha
14
34
  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.2
4
+ version: 0.11.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-27 00:00:00.000000000Z
13
+ date: 2012-03-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &30598720 !ruby/object:Gem::Requirement
17
+ requirement: &25799440 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,21 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *30598720
25
+ version_requirements: *25799440
26
+ - !ruby/object:Gem::Dependency
27
+ name: aruba
28
+ requirement: &25797600 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *25797600
26
37
  - !ruby/object:Gem::Dependency
27
38
  name: mocha
28
- requirement: &30598240 !ruby/object:Gem::Requirement
39
+ requirement: &25796280 !ruby/object:Gem::Requirement
29
40
  none: false
30
41
  requirements:
31
42
  - - ! '>='
@@ -33,10 +44,10 @@ dependencies:
33
44
  version: '0'
34
45
  type: :development
35
46
  prerelease: false
36
- version_requirements: *30598240
47
+ version_requirements: *25796280
37
48
  - !ruby/object:Gem::Dependency
38
49
  name: bundler
39
- requirement: &30597760 !ruby/object:Gem::Requirement
50
+ requirement: &25795080 !ruby/object:Gem::Requirement
40
51
  none: false
41
52
  requirements:
42
53
  - - ! '>='
@@ -44,10 +55,10 @@ dependencies:
44
55
  version: '0'
45
56
  type: :development
46
57
  prerelease: false
47
- version_requirements: *30597760
58
+ version_requirements: *25795080
48
59
  - !ruby/object:Gem::Dependency
49
60
  name: jeweler
50
- requirement: &30597280 !ruby/object:Gem::Requirement
61
+ requirement: &25793260 !ruby/object:Gem::Requirement
51
62
  none: false
52
63
  requirements:
53
64
  - - ! '>='
@@ -55,10 +66,10 @@ dependencies:
55
66
  version: '0'
56
67
  type: :development
57
68
  prerelease: false
58
- version_requirements: *30597280
69
+ version_requirements: *25793260
59
70
  - !ruby/object:Gem::Dependency
60
- name: rcov
61
- requirement: &30596780 !ruby/object:Gem::Requirement
71
+ name: simplecov
72
+ requirement: &25808000 !ruby/object:Gem::Requirement
62
73
  none: false
63
74
  requirements:
64
75
  - - ! '>='
@@ -66,8 +77,8 @@ dependencies:
66
77
  version: '0'
67
78
  type: :development
68
79
  prerelease: false
69
- version_requirements: *30596780
70
- description: Screencast utility for unix shell junkies :)
80
+ version_requirements: *25808000
81
+ description: Screencast utility for unix shell junkies
71
82
  email: self@antono.info
72
83
  executables:
73
84
  - shelr
@@ -78,6 +89,7 @@ extra_rdoc_files:
78
89
  files:
79
90
  - .document
80
91
  - .rspec
92
+ - .rvmrc
81
93
  - Gemfile
82
94
  - Gemfile.lock
83
95
  - LICENSE.txt
@@ -86,6 +98,9 @@ files:
86
98
  - TODO.org
87
99
  - VERSION
88
100
  - bin/shelr
101
+ - features/recording.feature
102
+ - features/step_definitions/shelr_steps.rb
103
+ - features/support/env.rb
89
104
  - lib/shelr.rb
90
105
  - lib/shelr/player.rb
91
106
  - lib/shelr/publisher.rb
@@ -113,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
128
  version: '0'
114
129
  segments:
115
130
  - 0
116
- hash: -3369964607201174593
131
+ hash: -1402734329441089779
117
132
  required_rubygems_version: !ruby/object:Gem::Requirement
118
133
  none: false
119
134
  requirements: