showterm 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,16 +6,22 @@ It's showtime for your terminal!
6
6
  Showterm lets your record a terminal session exactly as you experience it, right down to
7
7
  the syntax highlighting.
8
8
 
9
- Installation instructions (`gem install showterm`) and usage instructions (`showterm <program`) are available in the [showterm](https://showterm.herokuapp.com/b6803679cb1c9fbcf667cb7cfe8f605e3ce1fe03). :)
9
+ Installation instructions (`gem install showterm`) and usage instructions (`showterm program`) are available in the [showterm](https://showterm.herokuapp.com/b6803679cb1c9fbcf667cb7cfe8f605e3ce1fe03). :)
10
10
 
11
11
  (yes, this is me using showterm inside showterm; it's like inception, but with more
12
12
  syntax highlighting)
13
13
 
14
+ Configuration
15
+ =============
16
+
17
+ If you'd like to run your own showterm server, you can
18
+ `export SHOWTERM_SERVER=http://showterm.myorg.local/` to configure your showterm
19
+ client to talk to it.
20
+
14
21
  TODO
15
22
  ====
16
23
 
17
24
  * Allow embedders to chose colourschemes (at least light vs. dark background).
18
- * Fix problems with vim which sometimes goes out-of-bounds for term.js
19
25
 
20
26
  Meta-fu
21
27
  =======
data/bin/showterm CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'readline'
4
3
  require File.join(File.dirname(File.dirname(__FILE__)), 'lib/showterm')
5
4
 
6
5
  class Showterm::Main
@@ -45,6 +44,9 @@ class Showterm::Main
45
44
  You can pass `-e` as the first arg and it will allow you to edit the timings
46
45
  file before uploading. This can be nice if you want to take long pauses (such
47
46
  as searching an answer out) in between commands.
47
+
48
+ If you would like to attempt an upload again
49
+ showterm --retry <script> <times>
48
50
  EOF
49
51
  end
50
52
 
data/lib/showterm.rb CHANGED
@@ -29,22 +29,32 @@ module Showterm
29
29
  guess == 0 ? 80 : guess
30
30
  end
31
31
 
32
+
33
+ # Get the current height of the terminal
34
+ #
35
+ # @return [Integer] number of lines
36
+ def terminal_height
37
+ guess = `tput lines`.to_i
38
+ guess == 0 ? 25 : guess
39
+ end
40
+
32
41
  # Upload the termshow to showterm.io
33
42
  #
34
43
  # @param [String] scriptfile The ANSI dump of the terminal
35
44
  # @param [String] timingfile The timings
36
45
  # @param [Integer] cols The width of the terminal
37
- def upload!(scriptfile, timingfile, cols=terminal_width)
46
+ def upload!(scriptfile, timingfile, cols=terminal_width, lines=terminal_height)
38
47
  retried ||= false
39
48
  request = Net::HTTP::Post.new("/scripts")
40
49
  request.set_form_data(:scriptfile => scriptfile,
41
50
  :timingfile => timingfile,
42
- :cols => cols)
51
+ :cols => cols,
52
+ :lines => lines)
43
53
 
44
54
  response = http(request)
45
55
  raise response.body unless Net::HTTPSuccess === response
46
56
  response.body
47
- rescue => e
57
+ rescue
48
58
  raise if retried
49
59
  retried = true
50
60
  retry
@@ -152,15 +162,21 @@ module Showterm
152
162
  end
153
163
 
154
164
  def http(request)
155
- connection = Net::HTTP.new("showterm.herokuapp.com", 443)
156
- connection.use_ssl = true
157
- connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
165
+ connection = Net::HTTP.new(url.host, url.port)
166
+ if url.scheme =~ /https/i
167
+ connection.use_ssl = true
168
+ connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
169
+ end
158
170
  connection.open_timeout = 10
159
171
  connection.read_timeout = 10
160
172
  connection.start do |http|
161
173
  http.request request
162
174
  end
163
175
  rescue Timeout::Error
164
- raise "Could not connect to https://showterm.herokuapp.com/"
176
+ raise "Could not connect to #{@url.to_s}"
177
+ end
178
+
179
+ def url
180
+ @url ||= URI(ENV["SHOWTERM_SERVER"] || "https://showterm.herokuapp.com")
165
181
  end
166
182
  end
data/showterm.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "showterm"
3
- s.version = "0.3.0"
3
+ s.version = "0.4.0"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.author = "Conrad Irwin"
6
6
  s.email = "conrad.irwin@gmail.com"
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: showterm
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.0
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Conrad Irwin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-26 00:00:00.000000000 Z
12
+ date: 2013-01-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Integrates with showterm.io for awesome sharability.
15
15
  email: conrad.irwin@gmail.com