tlux 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/tlux +25 -20
- data/lib/tlux.rb +7 -3
- data/lib/tlux/commands/run_command.rb +4 -7
- data/lib/tlux/config/generator.rb +1 -1
- data/lib/tlux/config/parser.rb +2 -0
- data/lib/tlux/session.rb +13 -1
- data/lib/tlux/version.rb +1 -1
- data/spec/session_spec.rb +27 -3
- data/tlux.gemspec +2 -0
- metadata +25 -25
- data/lib/tlux/commands.rb +0 -27
- data/lib/tlux/commands/start.rb +0 -13
- data/lib/tlux/commands/start_command.rb +0 -13
- data/lib/tlux/config.rb +0 -8
- data/spec/commands/commands_spec.rb +0 -28
- data/spec/commands/run_command_spec.rb +0 -45
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d7852ef8bf693e95567621d7cd689cd0c5bd1aa9
|
4
|
+
data.tar.gz: ecdd70d66741a9281da1056ccd839d199bf5155b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ff7bb91b1c9e2f3d29209802bd9668552c208957ccdc48d611e85ccea92ca31192d340697caea86e64284ff1efb60d8f7cc0096321e97c93741aee1e4742b24
|
7
|
+
data.tar.gz: 0e7c4382b520516cc61a7de9bb8a4a7f8e8be45dde7b01a9adc59b863cdb54250ad23c83a1641989460b825b939b58d784ef40768bea077adc7365ebb6217dad
|
data/bin/tlux
CHANGED
@@ -4,34 +4,39 @@ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
|
4
4
|
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
require 'tlux'
|
7
|
+
require 'commander/import'
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
program :name, 'tlux'
|
10
|
+
program :version, Tlux::VERSION
|
11
|
+
program :description, 'Luxurious tmux configuration'
|
10
12
|
|
11
|
-
|
13
|
+
command :run do |c|
|
14
|
+
c.syntax = 'tlux run <config>'
|
15
|
+
c.summary = 'Start a tmux session with the given config'
|
12
16
|
|
13
|
-
|
14
|
-
puts "You must define an editor in either $TMUX_EDITOR or $EDITOR to use this command"
|
15
|
-
exit 1
|
17
|
+
c.option '--dir STRING', String, 'The directory to run the session in'
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
c.action do |args, options|
|
20
|
+
options.default dir: Dir.pwd
|
21
|
+
config = args.shift || abort('config argument required')
|
22
|
+
Tlux::Commands::RunCommand.new(config, options.dir).run
|
23
|
+
end
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
exit 1
|
26
|
+
command :list do |c|
|
27
|
+
c.syntax = 'tlux list'
|
24
28
|
|
29
|
+
c.action do |args, options|
|
30
|
+
puts Tlux::Commands::ListCommand.new.run
|
25
31
|
end
|
26
|
-
|
32
|
+
end
|
27
33
|
|
28
|
-
|
29
|
-
|
34
|
+
command :open do |c|
|
35
|
+
c.syntax = 'tlux open <config>'
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
EOF
|
37
|
+
c.action do |args, options|
|
38
|
+
config = args.shift || abort('config argument required')
|
39
|
+
Tlux::Commands::OpenCommand.new(config).run
|
40
|
+
end
|
36
41
|
end
|
37
42
|
|
data/lib/tlux.rb
CHANGED
@@ -5,7 +5,6 @@ require "fileutils"
|
|
5
5
|
module Tlux
|
6
6
|
TEMPLATES_PATH = File.join(File.dirname(__FILE__), 'tlux', 'templates')
|
7
7
|
class EditorNotDefinedError < StandardError ; end
|
8
|
-
class CommandNotFoundError < StandardError ; end
|
9
8
|
end
|
10
9
|
|
11
10
|
require "tlux/splitable"
|
@@ -15,5 +14,10 @@ require "tlux/session"
|
|
15
14
|
require "tlux/window"
|
16
15
|
require "tlux/pane"
|
17
16
|
|
18
|
-
require "tlux/config"
|
19
|
-
require "tlux/
|
17
|
+
require "tlux/config/generator"
|
18
|
+
require "tlux/config/parser"
|
19
|
+
|
20
|
+
require 'tlux/commands/base'
|
21
|
+
require 'tlux/commands/list_command'
|
22
|
+
require 'tlux/commands/run_command'
|
23
|
+
require 'tlux/commands/open_command'
|
@@ -4,26 +4,23 @@ module Tlux
|
|
4
4
|
module Commands
|
5
5
|
class RunCommand < Tlux::Commands::Base
|
6
6
|
|
7
|
-
attr_reader :config_name
|
7
|
+
attr_reader :config_name, :dir
|
8
8
|
|
9
|
-
def initialize(config_name)
|
9
|
+
def initialize(config_name, dir = '')
|
10
10
|
@config_name = config_name
|
11
|
+
@dir = dir
|
11
12
|
end
|
12
13
|
|
13
14
|
def run
|
14
15
|
parser = Tlux::Config::Parser.from_file(config_file_path)
|
15
16
|
parser.parse!
|
16
|
-
parser.session.
|
17
|
+
parser.session.dir = dir unless dir.empty?
|
17
18
|
|
18
19
|
exec Tlux::Config::Generator.new(parser.session).generate!
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
22
23
|
|
23
|
-
def session_name
|
24
|
-
Pathname.new(Dir.pwd).basename.to_s.gsub(/\./, '-').gsub(/\:/, '-')
|
25
|
-
end
|
26
|
-
|
27
24
|
def config_file_path
|
28
25
|
File.join(config_path, config_name)
|
29
26
|
end
|
data/lib/tlux/config/parser.rb
CHANGED
data/lib/tlux/session.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
module Tlux
|
2
2
|
class Session
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :dir
|
4
4
|
attr_reader :windows
|
5
|
+
attr_writer :name
|
5
6
|
|
6
7
|
def initialize(name = "")
|
7
8
|
@name = name
|
9
|
+
@dir = Dir.pwd
|
8
10
|
@windows = []
|
9
11
|
end
|
10
12
|
|
@@ -14,8 +16,18 @@ module Tlux
|
|
14
16
|
window.instance_eval(&block) if block_given?
|
15
17
|
end
|
16
18
|
|
19
|
+
def name
|
20
|
+
@name.empty? ? name_from_dir : @name
|
21
|
+
end
|
22
|
+
|
17
23
|
def get_binding
|
18
24
|
binding
|
19
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def name_from_dir
|
30
|
+
Pathname.new(dir).basename.to_s.gsub(/\./, '-').gsub(/\:/, '-')
|
31
|
+
end
|
20
32
|
end
|
21
33
|
end
|
data/lib/tlux/version.rb
CHANGED
data/spec/session_spec.rb
CHANGED
@@ -4,9 +4,33 @@ describe Tlux::Session do
|
|
4
4
|
let(:session) { Tlux::Session.new }
|
5
5
|
|
6
6
|
describe "#name" do
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
context "default" do
|
8
|
+
before { Dir.stub!(:pwd).and_return('/path/to/project.js') }
|
9
|
+
|
10
|
+
subject { session.name }
|
11
|
+
|
12
|
+
it { should == "project-js" }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "settable" do
|
16
|
+
it "should have a name" do
|
17
|
+
session.name = "foo"
|
18
|
+
session.name.should == "foo"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#dir" do
|
24
|
+
before { Dir.stub!(:pwd).and_return(:pwd) }
|
25
|
+
subject { session }
|
26
|
+
|
27
|
+
context "default" do
|
28
|
+
its(:dir) { should == :pwd }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "settable" do
|
32
|
+
before { session.dir = :foo }
|
33
|
+
its(:dir) { should == :foo }
|
10
34
|
end
|
11
35
|
end
|
12
36
|
|
data/tlux.gemspec
CHANGED
@@ -15,6 +15,8 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Tlux::VERSION
|
17
17
|
|
18
|
+
gem.add_dependency('commander')
|
19
|
+
|
18
20
|
gem.add_development_dependency('rspec')
|
19
21
|
gem.add_development_dependency('rake')
|
20
22
|
#gem.add_development_dependency('fakefs')
|
metadata
CHANGED
@@ -1,46 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tlux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Oliver Nightingale
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: rspec
|
16
29
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
30
|
requirements:
|
19
|
-
- -
|
31
|
+
- - '>='
|
20
32
|
- !ruby/object:Gem::Version
|
21
33
|
version: '0'
|
22
34
|
type: :development
|
23
35
|
prerelease: false
|
24
36
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
37
|
requirements:
|
27
|
-
- -
|
38
|
+
- - '>='
|
28
39
|
- !ruby/object:Gem::Version
|
29
40
|
version: '0'
|
30
41
|
- !ruby/object:Gem::Dependency
|
31
42
|
name: rake
|
32
43
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
44
|
requirements:
|
35
|
-
- -
|
45
|
+
- - '>='
|
36
46
|
- !ruby/object:Gem::Version
|
37
47
|
version: '0'
|
38
48
|
type: :development
|
39
49
|
prerelease: false
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
51
|
requirements:
|
43
|
-
- -
|
52
|
+
- - '>='
|
44
53
|
- !ruby/object:Gem::Version
|
45
54
|
version: '0'
|
46
55
|
description: Luxurious tmux configuration
|
@@ -60,14 +69,10 @@ files:
|
|
60
69
|
- bin/tlux
|
61
70
|
- lib/tlux.rb
|
62
71
|
- lib/tlux/commandable.rb
|
63
|
-
- lib/tlux/commands.rb
|
64
72
|
- lib/tlux/commands/base.rb
|
65
73
|
- lib/tlux/commands/list_command.rb
|
66
74
|
- lib/tlux/commands/open_command.rb
|
67
75
|
- lib/tlux/commands/run_command.rb
|
68
|
-
- lib/tlux/commands/start.rb
|
69
|
-
- lib/tlux/commands/start_command.rb
|
70
|
-
- lib/tlux/config.rb
|
71
76
|
- lib/tlux/config/generator.rb
|
72
77
|
- lib/tlux/config/parser.rb
|
73
78
|
- lib/tlux/pane.rb
|
@@ -78,10 +83,8 @@ files:
|
|
78
83
|
- lib/tlux/version.rb
|
79
84
|
- lib/tlux/window.rb
|
80
85
|
- spec/commands/base_spec.rb
|
81
|
-
- spec/commands/commands_spec.rb
|
82
86
|
- spec/commands/list_command_spec.rb
|
83
87
|
- spec/commands/open_command_spec.rb
|
84
|
-
- spec/commands/run_command_spec.rb
|
85
88
|
- spec/config/generator_spec.rb
|
86
89
|
- spec/config/parser_spec.rb
|
87
90
|
- spec/fixtures/sample_config.rb
|
@@ -94,34 +97,31 @@ files:
|
|
94
97
|
- tlux.gemspec
|
95
98
|
homepage: ''
|
96
99
|
licenses: []
|
100
|
+
metadata: {}
|
97
101
|
post_install_message:
|
98
102
|
rdoc_options: []
|
99
103
|
require_paths:
|
100
104
|
- lib
|
101
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
106
|
requirements:
|
104
|
-
- -
|
107
|
+
- - '>='
|
105
108
|
- !ruby/object:Gem::Version
|
106
109
|
version: '0'
|
107
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
-
none: false
|
109
111
|
requirements:
|
110
|
-
- -
|
112
|
+
- - '>='
|
111
113
|
- !ruby/object:Gem::Version
|
112
114
|
version: '0'
|
113
115
|
requirements: []
|
114
116
|
rubyforge_project:
|
115
|
-
rubygems_version:
|
117
|
+
rubygems_version: 2.0.0
|
116
118
|
signing_key:
|
117
|
-
specification_version:
|
119
|
+
specification_version: 4
|
118
120
|
summary: Luxurious tmux configuration
|
119
121
|
test_files:
|
120
122
|
- spec/commands/base_spec.rb
|
121
|
-
- spec/commands/commands_spec.rb
|
122
123
|
- spec/commands/list_command_spec.rb
|
123
124
|
- spec/commands/open_command_spec.rb
|
124
|
-
- spec/commands/run_command_spec.rb
|
125
125
|
- spec/config/generator_spec.rb
|
126
126
|
- spec/config/parser_spec.rb
|
127
127
|
- spec/fixtures/sample_config.rb
|
data/lib/tlux/commands.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Tlux
|
2
|
-
module Commands
|
3
|
-
extend self
|
4
|
-
|
5
|
-
def run(command_name, args = [])
|
6
|
-
raise Tlux::CommandNotFoundError unless available?(command_name)
|
7
|
-
name_to_constant(command_name).new(*args).run
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def available?(command_name)
|
13
|
-
!!name_to_constant(command_name)
|
14
|
-
rescue NameError
|
15
|
-
false
|
16
|
-
end
|
17
|
-
|
18
|
-
def name_to_constant(command_name)
|
19
|
-
self.const_get("#{command_name.capitalize}Command")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'tlux/commands/base'
|
25
|
-
require 'tlux/commands/list_command'
|
26
|
-
require 'tlux/commands/run_command'
|
27
|
-
require 'tlux/commands/open_command'
|
data/lib/tlux/commands/start.rb
DELETED
data/lib/tlux/config.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Tlux::Commands do
|
4
|
-
describe ".run" do
|
5
|
-
let(:command) { double(Tlux::Commands::RunCommand, run: true) }
|
6
|
-
let(:args) { [1,2,3] }
|
7
|
-
|
8
|
-
before do
|
9
|
-
Tlux::Commands::RunCommand.stub!(:new).and_return(command)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "with an available command" do
|
13
|
-
it "should instantiate a command and run it" do
|
14
|
-
command.should_receive(:run)
|
15
|
-
Tlux::Commands::RunCommand.should_receive(:new).with(*args)
|
16
|
-
Tlux::Commands.run('run', args)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "with an unavailable command" do
|
21
|
-
it "should raise a CommandNotFoundError" do
|
22
|
-
expect {
|
23
|
-
Tlux::Commands.run('foo')
|
24
|
-
}.to raise_error(Tlux::CommandNotFoundError)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
#require 'spec_helper'
|
2
|
-
#
|
3
|
-
#describe Tlux::Commands::RunCommand do
|
4
|
-
# describe "#run" do
|
5
|
-
# before :each do
|
6
|
-
# FakeFS.activate!
|
7
|
-
# end
|
8
|
-
#
|
9
|
-
# after :each do
|
10
|
-
# FakeFS.deactivate!
|
11
|
-
# end
|
12
|
-
#
|
13
|
-
# let(:config_path) { File.join(Dir.home, '.tlux', 'test') }
|
14
|
-
# let(:current_dir) { Dir.pwd }
|
15
|
-
# let(:command) { Tlux::Commands::RunCommand.new(config_path, current_dir) }
|
16
|
-
#
|
17
|
-
# context "config file does not exist" do
|
18
|
-
# it "should raise a Tlux::Config::FileNotFoundError" do
|
19
|
-
# expect {
|
20
|
-
# command.run
|
21
|
-
# }.to raise_error(Tlux::Config::FileNotFoundError)
|
22
|
-
# end
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
# context "config file does exist" do
|
26
|
-
# before :each do
|
27
|
-
# Tlux::Config::Parser.stub!(:new).with
|
28
|
-
# end
|
29
|
-
#
|
30
|
-
# describe "parsing the config file" do
|
31
|
-
# it "should parse the config file" do
|
32
|
-
# parser.should_receive(:parse!)
|
33
|
-
# end
|
34
|
-
# end
|
35
|
-
#
|
36
|
-
# it "should generate the tmux config for the tlux config file" do
|
37
|
-
#
|
38
|
-
# end
|
39
|
-
#
|
40
|
-
# it "should write the file out to tlux directory" do
|
41
|
-
#
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
#end
|