webtail 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -8,10 +8,68 @@ $ gem install webtail
8
8
  ```
9
9
 
10
10
  ## Usage
11
+ Pass Stdout to webtail via pipeline
11
12
 
12
13
  ```
13
- $ gem install webtail
14
14
  $ tail -f ... | webtail
15
15
  ```
16
16
 
17
- ![](http://dl.dropbox.com/u/5978869/image/20120804_141841.png)
17
+ ## ~/.webtailrc
18
+ You can define your custom callback into ~/.webtailrc.
19
+ The code in ~/.webtailrc is executed when a new line is inserted.
20
+
21
+ ## Examples
22
+
23
+ ### Rails log viewer
24
+
25
+ ```
26
+ $ cat ~/.webtailrc
27
+ var line = $('pre:last');
28
+ var text = line.text();
29
+
30
+ if (text == '\n') {
31
+ line.css({
32
+ margin: '3em 0',
33
+ height: 1,
34
+ background: 'lime'
35
+ });
36
+ }
37
+
38
+ if (text.match(/CACHE|Load/)) {
39
+ line.css({
40
+ color: '#E1017B'
41
+ });
42
+ }
43
+
44
+ $ tail -f log/development.log | webtail
45
+ ```
46
+
47
+ ![](http://dl.dropbox.com/u/5978869/image/20120804_205402.png)
48
+
49
+ ### Twitter client
50
+
51
+ ```
52
+ $ gem install userstream
53
+ $ cat twitter.rb
54
+ # encoding: utf-8
55
+ require "user_stream"
56
+
57
+ UserStream.configure do |config|
58
+ config.consumer_key = "..."
59
+ config.consumer_secret = "..."
60
+ config.oauth_token = "..."
61
+ config.oauth_token_secret = "..."
62
+ end
63
+
64
+ UserStream.client.user do |status|
65
+ STDOUT.puts "#{status.user.name}: #{status.text}"
66
+ STDOUT.flush
67
+ end
68
+
69
+ $ cat ~/.webtailrc
70
+ last.text(text.replace(/[ァ-ンー]{2,}/gi, 'ゆのっち'));
71
+
72
+ $ ruby twitter.rb | webtail
73
+ ```
74
+
75
+ ![](http://dl.dropbox.com/u/5978869/image/20120805_012055.png)
@@ -1,3 +1,3 @@
1
1
  module Webtail
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,30 +1,24 @@
1
1
  var Webtail = {
2
2
  run: function(port) {
3
3
  var self = this;
4
-
5
4
  jQuery(function($) {
6
- var socket = new (WebSocket || MozWebSocket)('ws://localhost:' + port),
7
- body = $('body');
8
-
9
- self.onmessages.push(function(message) {
10
- // To ignore serial empty lines
11
- if (message.data == '\n' && $('pre:last').text() == '\n') return;
12
-
13
- // Insert a new line
14
- $('<pre>').text(message.data).appendTo('body');
15
-
16
- // Scroll to bottom of the page
17
- $('html, body').scrollTop($(document).height());
18
-
19
- // Trigger onmessage event
20
- body.trigger('onmessage');
21
- });
22
-
5
+ var socket = new (WebSocket || MozWebSocket)('ws://localhost:' + port);
23
6
  socket.onmessage = function(message) {
24
7
  $.each(self.onmessages, function() { this(message) });
25
8
  };
26
9
  });
27
10
  },
28
11
 
29
- onmessages: []
12
+ onmessages: [
13
+ function(message) {
14
+ // To ignore serial empty lines
15
+ if (message.data == '\n' && $('pre:last').text() == '\n') return;
16
+
17
+ // Insert a new line
18
+ $('<pre>').text(message.data).appendTo('body');
19
+
20
+ // Scroll to bottom of the page
21
+ $('html, body').scrollTop($(document).height());
22
+ }
23
+ ]
30
24
  };
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &70359241311920 !ruby/object:Gem::Requirement
16
+ requirement: &70139463093720 !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: *70359241311920
24
+ version_requirements: *70139463093720
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: em-websocket
27
- requirement: &70359241311460 !ruby/object:Gem::Requirement
27
+ requirement: &70139463093220 !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: *70359241311460
35
+ version_requirements: *70139463093220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sinatra
38
- requirement: &70359241310800 !ruby/object:Gem::Requirement
38
+ requirement: &70139463092740 !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: *70359241310800
46
+ version_requirements: *70139463092740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: slop
49
- requirement: &70359241309900 !ruby/object:Gem::Requirement
49
+ requirement: &70139463092300 !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: *70359241309900
57
+ version_requirements: *70139463092300
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: launchy
60
- requirement: &70359241309220 !ruby/object:Gem::Requirement
60
+ requirement: &70139463091780 !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: *70359241309220
68
+ version_requirements: *70139463091780
69
69
  description: Stdin to your browser by WebSocket
70
70
  email:
71
71
  - r7kamura@gmail.com