efflux 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bba5ac045934c1fe04d212826adf6c193c8cb484
4
+ data.tar.gz: c50f294351db47da9ed74d932720d4a5f84765c1
5
+ SHA512:
6
+ metadata.gz: 42a976bb7b552b87f8ea50970f2d3579bdb2380304c5968d5ecdce1f9c6d8f80b1955dbf82861782b8042ff35620ddb1033952e83b68c9a092f0d4a96324f5bc
7
+ data.tar.gz: 6c370cf7e5ae513b047068c47705ae9e78130ac1af797aaf8f063f3481e558f9c5be5bcb6da9f55d201ba550c874cd896b12a876439aa6443d20770470101835
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Efflux'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
@@ -0,0 +1,38 @@
1
+ require 'open3'
2
+ module Efflux
3
+ module Stream
4
+ include ActionController::Live
5
+ def stream_cmd(cmd)
6
+ response.headers["Content-Type"] = "text/event-stream"
7
+ Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
8
+ output = ""
9
+ last_output = Time.current
10
+ while line = stdout.gets
11
+ output += console_to_html(line)
12
+ if last_output < 1.seconds.ago
13
+ response.stream.write "event: command.data\n"
14
+ response.stream.write "data: #{output}\n\n"
15
+ last_output = Time.current
16
+ output = ""
17
+ end
18
+ end
19
+ response.stream.write "event: command.data\n"
20
+ response.stream.write "data: #{output}<br/><div class=\"command-finished\">Command Finished at: #{Time.current}</div>\n\n"
21
+ end
22
+ rescue IOError => e
23
+ response.stream.close
24
+ ensure
25
+ response.stream.close
26
+ end
27
+
28
+ def console_to_html(string)
29
+ string.gsub!("\n", '<br/>')
30
+ if string =~ /\[[0-9]{1,2}/
31
+ string.gsub!('[32m', '<span class="foreground-green">')
32
+ string.gsub!('[0m','</span>')
33
+ string = %Q{<span class="foreground-green">#{string}</span>}
34
+ end
35
+ return string
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Efflux
2
+ VERSION = "0.0.1"
3
+ end
data/lib/efflux.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'efflux/stream'
2
+
3
+ module Efflux
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :efflux do
3
+ # # Task goes here
4
+ # end
Binary file
@@ -0,0 +1,93 @@
1
+ $.fn.extend
2
+ efflux: (options) ->
3
+ return @each (index, elem)->
4
+ new Efflux(elem, options)
5
+
6
+
7
+
8
+
9
+
10
+ $ ->
11
+ $('.spec-terminal').efflux
12
+ url: '/command_stream'
13
+ title: 'rspec'
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ class Efflux
23
+ e_source: undefined
24
+ socket_open: false
25
+ lines: 0
26
+ title: ''
27
+ run_time: 0
28
+ container: undefined
29
+ running: false
30
+ constructor: (elem, options) ->
31
+ @e_source = new EventSource(options.url)
32
+ @e_source.onerror = @.socket_error
33
+ @e_source.onopen = @.socket_open
34
+ @e_source.addEventListener 'command.data', @.data_received
35
+ @container = $(elem)
36
+ @title = options.title || ''
37
+ @build_console()
38
+ socket_open: (e) =>
39
+ @running = true
40
+ @clock_timer = setTimeout(@update_timer, 1000)
41
+ socket_error: (e) =>
42
+ e.target.close()
43
+ @running = false
44
+ clearTimeout @clock_timer
45
+ @update_timer()
46
+ data_received: (e) =>
47
+ @lines++
48
+ scroll_top = @container.find('.console').scrollTop()
49
+ console_height = @container.find('.console').outerHeight()
50
+ scroll_height = @container.find('.console')[0].scrollHeight
51
+ auto_scroll = (scroll_height - scroll_top == console_height || scroll_top == 0)
52
+ @container.find('.console pre').append(e.data)
53
+ @container.find('.console').stop()
54
+ if auto_scroll
55
+ @container.find('.console').animate({
56
+ scrollTop: @container.find('.console')[0].scrollHeight
57
+ }, 500)
58
+ build_console: () =>
59
+ status = (@running) ? 'Running' : 'Finished'
60
+ @container.html "
61
+ <div class=\"console-frame\">
62
+ <div class=\"statusbar\">
63
+ <div class=\"title\">#{@title} [Starting] - 00m:00s</div>
64
+ <button type=\"button\" class=\"fullscreen\"/>
65
+ </div>
66
+ <div class=\"console\"><pre></pre>
67
+ </div>
68
+ </div>
69
+ "
70
+ get_status: =>
71
+ if @running
72
+ return 'Running'
73
+ else
74
+ return 'Finished'
75
+ update_timer: () =>
76
+ @run_time++
77
+ @container.find('.title').html "#{@title} [#{@get_status()}] - #{@format_runtime()}"
78
+ setTimeout @update_timer, 1000 if @running
79
+ format_runtime: =>
80
+ seconds = @run_time
81
+ minutes = 0
82
+ if seconds > 60
83
+ minutes = seconds / 60
84
+ seconds = seconds - (minutes * 60)
85
+ return "#{@pad(minutes,2)}m:#{@pad(seconds,2)}s"
86
+ pad: (val, length, padChar = '0') ->
87
+ val += ''
88
+ numPads = length - val.length
89
+ if (numPads > 0) then new Array(numPads + 1).join(padChar) + val else val
90
+
91
+
92
+
93
+
@@ -0,0 +1,68 @@
1
+ @import url(http://fonts.googleapis.com/css?family=Open+Sans);
2
+ .console-frame {
3
+ border: 1px solid #999;
4
+ -moz-box-shadow: 0 0 2px #888;
5
+ -webkit-box-shadow: 0 0 2px #888;
6
+ box-shadow: 0 0 2px #888;
7
+ padding: 5px;
8
+ padding-top: 0px;
9
+ position: relative;
10
+ background-color: #fff;
11
+ overflow: hidden;
12
+ border-radius: 5px;
13
+ .console {
14
+ font-family: "Lucida Console", Monaco, monospace;
15
+ font-size: 1em;
16
+ line-height: 1.375em;
17
+ background: #333;
18
+ color: #eee;
19
+ padding: 8px;
20
+ height: 300px;
21
+ overflow-x: scroll;
22
+ word-wrap: break-word;
23
+ -moz-box-shadow: inset 0 0 5px #161616;
24
+ -webkit-box-shadow: inset 0 0 5px #161616;
25
+ box-shadow: inner 0 0 5px #161616;
26
+ .command-finished {
27
+ border-top: 1px solid #ccc;
28
+ }
29
+ .foreground-green {
30
+ color: #00ff00;
31
+ }
32
+
33
+ }
34
+ .statusbar {
35
+ height: 26px;
36
+ border-bottom: 1px solid #000;
37
+ .title {
38
+ font-family: 'Open-Sans', sans-serif;
39
+ text-shadow: rgba(255,255,255,1) 0px 3px 3px;
40
+ float: left;
41
+ font-weight: 200;
42
+ font-size: 1em;
43
+ margin-top: 4px;
44
+ padding-left: 15px;
45
+ color: #666;
46
+ font-weight: bold;
47
+ }
48
+ button {
49
+ float:right;
50
+ margin-top: 3px;
51
+ margin-left: 3px;
52
+ height: 20px;
53
+ width: 20px;
54
+ border-radius: 4px;
55
+ box-shadow: none;
56
+ border: none;
57
+ background-color: transparent;
58
+ }
59
+ button.fullscreen {
60
+ background-image: url('fullscreen.png');
61
+ background-size: 75% 75%;
62
+ background-position: center center;
63
+ background-repeat: no-repeat;
64
+ cursor: pointer;
65
+ }
66
+
67
+ }
68
+ }
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: efflux
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joe Bellus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: coffee-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sass
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Efflux makes it easy to display live system commands in a browser based
70
+ console panel.
71
+ email:
72
+ - joe@confluentlight.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - Rakefile
78
+ - lib/efflux.rb
79
+ - lib/efflux/stream.rb
80
+ - lib/efflux/version.rb
81
+ - lib/tasks/efflux_tasks.rake
82
+ - vendor/assets/images/fullscreen.png
83
+ - vendor/assets/javascripts/efflux.js.coffee
84
+ - vendor/assets/stylesheets/efflux.css.scss
85
+ homepage: https://github.com/ViaoV/efflux
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.2.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: A rails gem to display live system commands
109
+ test_files: []