webtail 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ require "slop"
4
4
  argv = ARGV.dup
5
5
  slop = Slop.new(:strict => true, :help => true)
6
6
  slop.banner "$ tail -f ... | webtail [options]"
7
- slop.on :p, :port, "port number for http server (default is 9999)"
7
+ slop.on :p, :port=, "port number for http server (default is 9999)"
8
8
  begin
9
9
  slop.parse!(argv)
10
10
  rescue => e
@@ -18,7 +18,9 @@ module Webtail
18
18
 
19
19
  class Server < ::Sinatra::Base
20
20
  path = File.expand_path("~/.webtailrc")
21
- set :webtailrc, File.exist?(path) && File.read(path)
21
+ set :webtailrc do
22
+ File.exist?(path) && File.read(path)
23
+ end
22
24
  set :root, File.expand_path("../../../", __FILE__)
23
25
 
24
26
  get "/" do
@@ -2,9 +2,16 @@ module Webtail
2
2
  module Stdin
3
3
  extend self
4
4
 
5
+ ENTITY_MAP = {
6
+ "&lt;" => "<",
7
+ "&gt;" => ">",
8
+ }
9
+
5
10
  def run
6
11
  STDIN.each do |line|
7
- Webtail.channel << strip_ansi_sequence(line)
12
+ line = unescape_entity(line)
13
+ line = strip_ansi_sequence(line)
14
+ Webtail.channel << line
8
15
  end
9
16
  end
10
17
 
@@ -13,5 +20,9 @@ module Webtail
13
20
  def strip_ansi_sequence(str)
14
21
  str.gsub(/\e\[.*?m/, "")
15
22
  end
23
+
24
+ def unescape_entity(str)
25
+ str.gsub(/#{Regexp.union(ENTITY_MAP.keys)}/o) {|key| ENTITY_MAP[key] }
26
+ end
16
27
  end
17
28
  end
@@ -1,3 +1,3 @@
1
1
  module Webtail
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -3,14 +3,15 @@ var Webtail = {
3
3
  var self = this;
4
4
  jQuery(function($) {
5
5
  var socket = new (WebSocket || MozWebSocket)('ws://localhost:' + port);
6
+ var context = {};
6
7
  socket.onmessage = function(message) {
7
- $.each(self.onmessages, function() { this(message) });
8
+ $.each(self.onmessages, function() { this(message, context) });
8
9
  };
9
10
  });
10
11
  },
11
12
 
12
13
  onmessages: [
13
- function(message) {
14
+ function(message, context) {
14
15
  // To ignore serial empty lines
15
16
  if (message.data == '\n' && $('pre:last').text() == '\n') return;
16
17
 
@@ -10,7 +10,7 @@
10
10
  <script type="text/javascript" src="/js/webtail.js"></script>
11
11
  <script type="text/javascript">
12
12
  <% if @webtailrc %>
13
- Webtail.onmessages.push(function() {
13
+ Webtail.onmessages.push(function(message, context) {
14
14
  <%= @webtailrc %>
15
15
  });
16
16
  <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webtail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-04 00:00:00.000000000 Z
12
+ date: 2012-09-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &70139463093720 !ruby/object:Gem::Requirement
16
+ requirement: &70318316704200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70139463093720
24
+ version_requirements: *70318316704200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: em-websocket
27
- requirement: &70139463093220 !ruby/object:Gem::Requirement
27
+ requirement: &70318316701640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70139463093220
35
+ version_requirements: *70318316701640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sinatra
38
- requirement: &70139463092740 !ruby/object:Gem::Requirement
38
+ requirement: &70318316700780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70139463092740
46
+ version_requirements: *70318316700780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: slop
49
- requirement: &70139463092300 !ruby/object:Gem::Requirement
49
+ requirement: &70318316700060 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70139463092300
57
+ version_requirements: *70318316700060
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: launchy
60
- requirement: &70139463091780 !ruby/object:Gem::Requirement
60
+ requirement: &70318316698040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 2.0.6
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70139463091780
68
+ version_requirements: *70318316698040
69
69
  description: Stdin to your browser by WebSocket
70
70
  email:
71
71
  - r7kamura@gmail.com