consular-another-gnome-terminal 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ gem 'mocha'
2
+ gem 'minitest'
@@ -0,0 +1,13 @@
1
+ GEM
2
+ specs:
3
+ metaclass (0.0.1)
4
+ minitest (2.9.0)
5
+ mocha (0.10.0)
6
+ metaclass (~> 0.0.1)
7
+
8
+ PLATFORMS
9
+ ruby
10
+
11
+ DEPENDENCIES
12
+ minitest
13
+ mocha
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2011 Alex Gorkunov.
2
+ (The MIT License)
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ # ABOUT
2
+
3
+ Gnome Terminal adapter for [Consular](https://github.com/achiu/consular)
4
+
5
+ Official [Gnome-Terminal adapter](https://github.com/jc00ke/consular-gnome-terminal) uses keyboard emulation for creating new tabs and run commands.
6
+ This adapter build full command line for running gnome-terminal with tabs and windows instead of using some tools for emulation keyboards (such as xdotool).
7
+
8
+
9
+ # LICENSE
10
+
11
+ MIT
12
+
13
+ See LICENSE.txt
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new do |test|
5
+ test.libs << 'lib' << 'spec'
6
+ test.test_files = FileList['spec/*_spec.rb']
7
+ test.verbose = true
8
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.11
@@ -0,0 +1,21 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "consular/another-gnome-terminal/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'consular-another-gnome-terminal'
6
+ s.version = Consular::AnotherGnomeTerminal::VERSION
7
+ s.authors = ["Alex Gorkunov"]
8
+ s.email = ["alexander.gorkunov@gmail.com"]
9
+ s.licenses = ["MIT"]
10
+ s.homepage = %q{http://www.github.com/gorkunov/consular-another-gnome-terminal}
11
+ s.summary = %q{Gnome Terminal support for Consular (without using xdotool)}
12
+ s.description = %q{Gnome Terminal support for Consular without emulation keyboard events}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- spec/*`.split("\n")
16
+ s.require_paths = ["lib"]
17
+
18
+ s.add_runtime_dependency "consular"
19
+ s.add_development_dependency 'minitest'
20
+ s.add_development_dependency 'mocha'
21
+ end
@@ -0,0 +1,63 @@
1
+ require 'consular'
2
+
3
+ module Consular
4
+ class AnotherGnomeTerminal < Core
5
+ TERMINAL_CMD = "gnome-terminal"
6
+
7
+ Consular.add_core self
8
+
9
+ class << self
10
+
11
+ def platform
12
+ RUBY_PLATFORM
13
+ end
14
+
15
+ def valid_system?
16
+ !!(platform =~ /linux/ && !`which #{TERMINAL_CMD}`.empty?)
17
+ end
18
+
19
+ end
20
+
21
+ def initialize(path)
22
+ super
23
+ @tabidx = nil
24
+ end
25
+
26
+ def setup!
27
+ raise NotImplementedError
28
+ end
29
+
30
+ def get_name_cmd_option item
31
+ options = item[:options] || {}
32
+ name = options[:name]
33
+ name ? "-t '#{name}'" : ""
34
+ end
35
+
36
+ def process!
37
+ windows = @termfile[:windows]
38
+ default = windows.delete('default')
39
+
40
+ raise NotImplementedError, "Tabs aren't supported for current window" \
41
+ if default[:tabs].keys.count > 1
42
+
43
+ #run commands from default section
44
+ commands = default[:tabs].values.first[:commands] || []
45
+ STDOUT.puts `#{commands.join('; ')}` if commands.any?
46
+
47
+ windows.each do |wname, window|
48
+ cmd = [ TERMINAL_CMD ]
49
+ cmd << get_name_cmd_option(window)
50
+
51
+ before = window[:before]
52
+ window[:tabs].each do |tname, tab|
53
+ commands = tab[:commands]
54
+ commands = before + commands if before
55
+
56
+ cmd << "--tab #{get_name_cmd_option(tab)} -e 'bash -c '\\''#{commands.join('; ')}; exec bash'\\'"
57
+ end
58
+
59
+ `#{cmd.join(' ')}`
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,15 @@
1
+ require 'consular'
2
+
3
+ module Consular
4
+ class AnotherGnomeTerminal < Core
5
+ module Version
6
+ MAJOR = 1
7
+ MINOR = 0
8
+ PATCH = 0
9
+ end
10
+
11
+ VERSION = [
12
+ Version::MAJOR, Version::MINOR, Version::PATCH
13
+ ].compact.join('.')
14
+ end
15
+ end
@@ -0,0 +1,40 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ describe Consular::AnotherGnomeTerminal do
4
+ it 'should be added as a core to Consular' do
5
+ Consular.cores.must_include Consular::AnotherGnomeTerminal
6
+ end
7
+
8
+ it 'should accept linux and gnome-terminal as valid conditions for running' do
9
+ Consular::AnotherGnomeTerminal.expects(:platform).returns("linux")
10
+ Consular::AnotherGnomeTerminal.expects(:`).with("which gnome-terminal").returns("path")
11
+
12
+ Consular::AnotherGnomeTerminal.valid_system?.must_equal true
13
+ end
14
+
15
+ it 'should reject macos as valid os for running' do
16
+ Consular::AnotherGnomeTerminal.expects(:platform).returns("darwin")
17
+ Consular::AnotherGnomeTerminal.valid_system?.must_equal false
18
+ end
19
+
20
+ it "should corrent run termfile" do
21
+ Consular::AnotherGnomeTerminal.any_instance.expects(:`).with(%q{ps aux; uname -r})
22
+ Consular::AnotherGnomeTerminal.any_instance.expects(:`).with(%q{gnome-terminal -t 'test1' --tab -e 'bash -c '\\''ps a; exec bash'\\' --tab -t 'test' -e 'bash -c '\\''top; exec bash'\\'})
23
+
24
+ tmp = Tempfile.new('foo')
25
+ tmp.write(%q{
26
+ run "ps aux"
27
+ run "uname -r"
28
+ window "test1" do
29
+ run "ps a"
30
+ tab "test" do
31
+ run "top"
32
+ end
33
+ end
34
+ })
35
+ tmp.rewind
36
+
37
+ core = Consular::AnotherGnomeTerminal.new tmp.path
38
+ core.process!
39
+ end
40
+ end
@@ -0,0 +1,6 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'mocha'
4
+ require 'tempfile'
5
+
6
+ require File.expand_path('../../lib/consular/another-gnome-terminal', __FILE__)
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: consular-another-gnome-terminal
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex Gorkunov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-13 00:00:00.000000000 +04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: consular
17
+ requirement: &70168045902200 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70168045902200
26
+ - !ruby/object:Gem::Dependency
27
+ name: minitest
28
+ requirement: &70168045935040 !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: *70168045935040
37
+ - !ruby/object:Gem::Dependency
38
+ name: mocha
39
+ requirement: &70168045934620 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70168045934620
48
+ description: Gnome Terminal support for Consular without emulation keyboard events
49
+ email:
50
+ - alexander.gorkunov@gmail.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - Gemfile.lock
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - VERSION
62
+ - consular-another-gnome-terminal.gemspec
63
+ - lib/consular/another-gnome-terminal.rb
64
+ - lib/consular/another-gnome-terminal/version.rb
65
+ - spec/another-gnome-terminal_spec.rb
66
+ - spec/spec_helper.rb
67
+ has_rdoc: true
68
+ homepage: http://www.github.com/gorkunov/consular-another-gnome-terminal
69
+ licenses:
70
+ - MIT
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.6.2
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Gnome Terminal support for Consular (without using xdotool)
93
+ test_files:
94
+ - spec/another-gnome-terminal_spec.rb
95
+ - spec/spec_helper.rb