muxilla 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +51 -0
- data/README.rdoc +39 -0
- data/Rakefile +2 -0
- data/lib/muxilla.rb +3 -0
- data/lib/muxilla/mux.rb +26 -0
- data/lib/muxilla/muxinate.rb +64 -0
- data/lib/muxilla/muxinator.rb +18 -0
- data/lib/muxilla/templates/tmux_config.tt +57 -0
- data/lib/muxilla/version.rb +3 -0
- data/muxilla.gemspec +27 -0
- data/spec/muxilla/mux_spec.rb +75 -0
- data/spec/muxilla/muxinate_spec.rb +177 -0
- data/spec/muxilla/muxinator_spec.rb +14 -0
- data/spec/spec_helper.rb +42 -0
- metadata +142 -0
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use ruby-1.9.2-p180@muxilla --create
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
muxilla (0.0.1)
|
5
|
+
json
|
6
|
+
thor
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
archive-tar-minitar (0.5.2)
|
12
|
+
chalofa_ruby-progressbar (0.0.9.1)
|
13
|
+
columnize (0.3.2)
|
14
|
+
diff-lcs (1.1.2)
|
15
|
+
fuubar (0.0.4)
|
16
|
+
chalofa_ruby-progressbar (~> 0.0.9)
|
17
|
+
rspec (~> 2.0)
|
18
|
+
rspec-instafail (~> 0.1.4)
|
19
|
+
json (1.5.1)
|
20
|
+
linecache19 (0.5.12)
|
21
|
+
ruby_core_source (>= 0.1.4)
|
22
|
+
rspec (2.5.0)
|
23
|
+
rspec-core (~> 2.5.0)
|
24
|
+
rspec-expectations (~> 2.5.0)
|
25
|
+
rspec-mocks (~> 2.5.0)
|
26
|
+
rspec-core (2.5.1)
|
27
|
+
rspec-expectations (2.5.0)
|
28
|
+
diff-lcs (~> 1.1.2)
|
29
|
+
rspec-instafail (0.1.7)
|
30
|
+
rspec-mocks (2.5.0)
|
31
|
+
ruby-debug-base19 (0.11.25)
|
32
|
+
columnize (>= 0.3.1)
|
33
|
+
linecache19 (>= 0.5.11)
|
34
|
+
ruby_core_source (>= 0.1.4)
|
35
|
+
ruby-debug19 (0.11.6)
|
36
|
+
columnize (>= 0.3.1)
|
37
|
+
linecache19 (>= 0.5.11)
|
38
|
+
ruby-debug-base19 (>= 0.11.19)
|
39
|
+
ruby_core_source (0.1.5)
|
40
|
+
archive-tar-minitar (>= 0.5.2)
|
41
|
+
thor (0.14.6)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
bundler
|
48
|
+
fuubar
|
49
|
+
muxilla!
|
50
|
+
rspec
|
51
|
+
ruby-debug19
|
data/README.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
== WARNING
|
2
|
+
This is not yet finished! The below usage information is how the initial release will work.
|
3
|
+
Current v1 release only respects the apps=code: directive, sets up code, rails, and resque foreach, and assumes your development directory is ~/dev
|
4
|
+
|
5
|
+
== INSTALLATION
|
6
|
+
thor install <gem-home>/muxilla/lib/muxilla/muxinate.rb
|
7
|
+
|
8
|
+
== USAGE
|
9
|
+
Configure:
|
10
|
+
thor muxinate:configure
|
11
|
+
- Prompts for your development directory (i.e. ~/dev)
|
12
|
+
- Configuration is stored in ~/.muxilla.conf
|
13
|
+
- Removing this file will require re-running the configure task
|
14
|
+
|
15
|
+
Feature:
|
16
|
+
thor muxinate:feature myfeaturename [--id 123] --apps=key:value [--with-spork]
|
17
|
+
- Will generate a myfeaturename.tmux (v1 always names this file tmux_config.tmux) configuration file
|
18
|
+
- Will checkout first branch that matches id (if provided) or featurename
|
19
|
+
|
20
|
+
Bug: (see Feature)
|
21
|
+
thor muxinate:bug mybugname
|
22
|
+
Chore: (see Feature)
|
23
|
+
thor muxinate:chore mychorename
|
24
|
+
|
25
|
+
== --apps Options
|
26
|
+
- Assumes app code is located at <development-directory>/app_name
|
27
|
+
|
28
|
+
code:list,of,apps
|
29
|
+
- Creates a window for each app and opens vi
|
30
|
+
|
31
|
+
rails:list,of,apps
|
32
|
+
- Creates one server window, opening each app in a new pane
|
33
|
+
|
34
|
+
resque:list,of,apps
|
35
|
+
- Assumes a resque.sh script exists in Rails.root/script
|
36
|
+
- Creates one resque window, booting one worker for each app in a new pane
|
37
|
+
|
38
|
+
== Future Plans
|
39
|
+
- Rails should imply code (declaring a rails app should boot the server and open code in vi)
|
data/Rakefile
ADDED
data/lib/muxilla.rb
ADDED
data/lib/muxilla/mux.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Muxilla
|
2
|
+
class Mux
|
3
|
+
attr_accessor :nickname, :type, :update, :id, :code, :rails, :resque
|
4
|
+
def initialize nickname, options
|
5
|
+
@nickname = nickname
|
6
|
+
@type = options[:type]
|
7
|
+
@update = options[:update]
|
8
|
+
@id = options[:id]
|
9
|
+
@code = @rails = @resque = []
|
10
|
+
if options[:apps]
|
11
|
+
@code = options[:apps]['code'].split ',' if options[:apps]['code']
|
12
|
+
@rails = options[:apps]['rails'].split ',' if options[:apps]['rails']
|
13
|
+
@resque = options[:apps]['resque'].split ',' if options[:apps]['resque']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def apps
|
18
|
+
# delete this once the call has been removed from the template
|
19
|
+
@code
|
20
|
+
end
|
21
|
+
|
22
|
+
def dev_root
|
23
|
+
"~/dev"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require `echo $GEM_HOME`.chomp + "/gems/muxilla-0.0.1/lib/muxilla/muxinator"
|
2
|
+
require `echo $GEM_HOME`.chomp + "/gems/muxilla-0.0.1/lib/muxilla/mux"
|
3
|
+
|
4
|
+
module Muxilla
|
5
|
+
class Muxinate < Thor
|
6
|
+
require 'json'
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
desc 'configure', 'Tell Muxilla about how your dev environment is setup'
|
10
|
+
def configure
|
11
|
+
configuration = {}
|
12
|
+
configuration[:development_dir] = shell.ask "what is your development directory?"
|
13
|
+
destination = File.expand_path('~/.muxilla.conf')
|
14
|
+
create_file(destination, configuration.to_json, :verbose => false)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'feature TITLE', 'generate a new tmux config from a feature branch'
|
18
|
+
method_options :update => :boolean,
|
19
|
+
:id => :numeric,
|
20
|
+
:apps => :hash
|
21
|
+
def feature nickname
|
22
|
+
if !check_config
|
23
|
+
return
|
24
|
+
end
|
25
|
+
muxinator_it :feature, nickname, options
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'bug TITLE', 'generate a new tmux config from a bug branch'
|
29
|
+
method_options :update => :boolean,
|
30
|
+
:id => :numeric,
|
31
|
+
:apps => :hash
|
32
|
+
def bug nickname
|
33
|
+
if !check_config
|
34
|
+
return
|
35
|
+
end
|
36
|
+
muxinator_it :bug, nickname, options
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'chore TITLE', 'generate a new tmux config from a bug branch'
|
40
|
+
method_options :update => :boolean,
|
41
|
+
:id => :numeric,
|
42
|
+
:apps => :hash
|
43
|
+
def chore nickname
|
44
|
+
if !check_config
|
45
|
+
return
|
46
|
+
end
|
47
|
+
muxinator_it :chore, nickname, options
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
def check_config
|
52
|
+
unless File.exists? File.expand_path('~/.muxilla.conf')
|
53
|
+
p "Please run muxilla configure to setup your environment first."
|
54
|
+
return false
|
55
|
+
end
|
56
|
+
true
|
57
|
+
end
|
58
|
+
|
59
|
+
def muxinator_it type, nickname, options
|
60
|
+
@mux = ::Muxilla::Mux.new nickname, options.merge(:type => type)
|
61
|
+
::Muxilla::Muxinator.start [@mux]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Muxilla
|
2
|
+
class Muxinator < Thor::Group
|
3
|
+
include Thor::Actions
|
4
|
+
argument :mux
|
5
|
+
|
6
|
+
def self.source_root
|
7
|
+
`echo $GEM_HOME`.chomp + "/gems/muxilla-0.0.1/lib/muxilla"
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_tmux_config
|
11
|
+
template 'templates/tmux_config.tt', self.class.output_file, :verbose => false
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.output_file
|
15
|
+
'~/tmux_config.tmux'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/bin/zsh
|
2
|
+
tmux start-server
|
3
|
+
|
4
|
+
if ! $(tmux has-session -t <%= mux.nickname %>); then
|
5
|
+
|
6
|
+
tmux new-session -d -s <%= mux.nickname %> -n zsh
|
7
|
+
|
8
|
+
# Create windows
|
9
|
+
tmux new-window -t <%= mux.nickname %>:1 -n editor
|
10
|
+
tmux new-window -t <%= mux.nickname %>:2 -n servers
|
11
|
+
tmux new-window -t <%= mux.nickname %>:3 -n workers
|
12
|
+
tmux new-window -t <%= mux.nickname %>:4 -n tests
|
13
|
+
tmux new-window -t <%= mux.nickname %>:5 -n console
|
14
|
+
|
15
|
+
tmux send-keys -t <%= mux.nickname %>:0 'cd <%= mux.dev_root %>/<%= mux.apps.first %>' C-m
|
16
|
+
tmux send-keys -t <%= mux.nickname %>:1 'cd <%= mux.dev_root %>/<%= mux.apps.first %> && vim .' C-m
|
17
|
+
tmux send-keys -t <%= mux.nickname %>:2 'cd <%= mux.dev_root %>/<%= mux.apps.first %> && rails s' C-m
|
18
|
+
tmux send-keys -t <%= mux.nickname %>:3 'cd <%= mux.dev_root %>/<%= mux.apps.first %> && ./script/resque.sh' C-m
|
19
|
+
tmux send-keys -t <%= mux.nickname %>:4 'cd <%= mux.dev_root %>/<%= mux.apps.first %> && spork' C-m
|
20
|
+
tmux send-keys -t <%= mux.nickname %>:5 'cd <%= mux.dev_root %>/<%= mux.apps.first %> && rails c' C-m
|
21
|
+
|
22
|
+
<%- mux.apps.each_with_index do |app, index| %>
|
23
|
+
<%- next if index == 0 %>
|
24
|
+
|
25
|
+
tmux new-window -t <%= mux.nickname %>:6 -n '<%= app %> editor'
|
26
|
+
tmux splitw -t <%= mux.nickname %>:servers
|
27
|
+
tmux splitw -t <%= mux.nickname %>:workers
|
28
|
+
tmux splitw -t <%= mux.nickname %>:console
|
29
|
+
tmux send-keys -t <%= mux.nickname %>:6 'cd <%= mux.dev_root %>/<%= app %> && vim .' C-m
|
30
|
+
|
31
|
+
tmux select-layout -t <%= mux.nickname %>:servers even-horizontal
|
32
|
+
tmux select-window -t <%= mux.nickname %>:servers
|
33
|
+
tmux select-pane -t right
|
34
|
+
tmux send-keys 'cd <%= mux.dev_root %>/<%= app %> && rails s -p <%= 3000 + index %>' C-m
|
35
|
+
|
36
|
+
tmux select-layout -t <%= mux.nickname %>:workers even-horizontal
|
37
|
+
tmux select-window -t <%= mux.nickname %>:workers
|
38
|
+
tmux select-pane -t right
|
39
|
+
tmux send-keys 'cd <%= mux.dev_root %>/<%= app %> && ./script/resque.sh' C-m
|
40
|
+
|
41
|
+
tmux select-layout -t <%= mux.nickname %>:console even-horizontal
|
42
|
+
tmux select-window -t <%= mux.nickname %>:console
|
43
|
+
tmux select-pane -t right
|
44
|
+
tmux send-keys 'cd <%= mux.dev_root %>/<%= app %> && rails c' C-m
|
45
|
+
|
46
|
+
<%- end %>
|
47
|
+
|
48
|
+
|
49
|
+
tmux select-window -t <%= mux.nickname %>:1
|
50
|
+
|
51
|
+
fi
|
52
|
+
|
53
|
+
if [ -z $TMUX ]; then
|
54
|
+
tmux -u attach-session -t <%= mux.nickname %>
|
55
|
+
else
|
56
|
+
tmux -u switch-client -t <%= mux.nickname %>
|
57
|
+
fi
|
data/muxilla.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "muxilla/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "muxilla"
|
7
|
+
s.version = Muxilla::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Chris Apolzon']
|
10
|
+
s.email = ['apolzon@gmail.com']
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Quickly create story-specific tmux scripts}
|
13
|
+
s.description = %q{A prompt-based cli to generate a tmux script based on the story name and related systems}
|
14
|
+
|
15
|
+
s.add_development_dependency 'rspec'
|
16
|
+
s.add_development_dependency 'bundler'
|
17
|
+
s.add_development_dependency 'ruby-debug19'
|
18
|
+
s.add_development_dependency 'fuubar'
|
19
|
+
|
20
|
+
s.add_runtime_dependency 'thor'
|
21
|
+
s.add_runtime_dependency 'json'
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
s.require_paths = ["lib"]
|
27
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Muxilla::Mux do
|
4
|
+
before do
|
5
|
+
@options = ['nickname', {}]
|
6
|
+
end
|
7
|
+
it 'responds to nickname' do
|
8
|
+
(Muxilla::Mux.new *@options).respond_to?(:nickname).should be
|
9
|
+
end
|
10
|
+
it 'responds to type' do
|
11
|
+
(Muxilla::Mux.new *@options).respond_to?(:type).should be
|
12
|
+
end
|
13
|
+
it 'responds to dev root' do
|
14
|
+
(Muxilla::Mux.new *@options).respond_to?(:dev_root).should be
|
15
|
+
end
|
16
|
+
describe '.new' do
|
17
|
+
it 'requires a nickname and options hash' do
|
18
|
+
expect { Muxilla::Mux.new }.to raise_error
|
19
|
+
end
|
20
|
+
it 'stores the nickname' do
|
21
|
+
mux = Muxilla::Mux.new *@options
|
22
|
+
mux.nickname.should == 'nickname'
|
23
|
+
end
|
24
|
+
it 'stores the type' do
|
25
|
+
@options.last.merge! :type => :feature
|
26
|
+
mux = Muxilla::Mux.new *@options
|
27
|
+
mux.type.should == :feature
|
28
|
+
end
|
29
|
+
it 'stores the update param' do
|
30
|
+
@options.last.merge! :update => true
|
31
|
+
mux = Muxilla::Mux.new *@options
|
32
|
+
mux.update.should be
|
33
|
+
end
|
34
|
+
it 'stores the id' do
|
35
|
+
@options.last.merge! :id => 1234
|
36
|
+
mux = Muxilla::Mux.new *@options
|
37
|
+
mux.id.should == 1234
|
38
|
+
end
|
39
|
+
it 'stores the code hash' do
|
40
|
+
@options.last.merge! :apps => {'code' => 'foo,bar,garply'}
|
41
|
+
mux = Muxilla::Mux.new *@options
|
42
|
+
mux.code.should include 'foo'
|
43
|
+
mux.code.should include 'bar'
|
44
|
+
mux.code.should include 'garply'
|
45
|
+
end
|
46
|
+
it 'stores the rails hash' do
|
47
|
+
@options.last.merge! :apps => {'rails' => 'foo,bar,garply'}
|
48
|
+
mux = Muxilla::Mux.new *@options
|
49
|
+
mux.rails.should include 'foo'
|
50
|
+
mux.rails.should include 'bar'
|
51
|
+
mux.rails.should include 'garply'
|
52
|
+
end
|
53
|
+
it 'stores the resque hash' do
|
54
|
+
@options.last.merge! :apps => {'resque' => 'baz,quux'}
|
55
|
+
mux = Muxilla::Mux.new *@options
|
56
|
+
mux.resque.should include 'baz'
|
57
|
+
mux.resque.should include 'quux'
|
58
|
+
mux.code.should == []
|
59
|
+
mux.rails.should == []
|
60
|
+
end
|
61
|
+
it 'returns an empty array when no apps options are specified' do
|
62
|
+
mux = Muxilla::Mux.new *@options
|
63
|
+
mux.code.should == []
|
64
|
+
mux.rails.should == []
|
65
|
+
mux.resque.should == []
|
66
|
+
end
|
67
|
+
it 'returns an empty array when an empty apps option is specified' do
|
68
|
+
@options.last.merge! :apps => {}
|
69
|
+
mux = Muxilla::Mux.new *@options
|
70
|
+
mux.code.should == []
|
71
|
+
mux.rails.should == []
|
72
|
+
mux.resque.should == []
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Muxilla::Muxinate do
|
4
|
+
describe 'help' do
|
5
|
+
it 'outputs information about available commands' do
|
6
|
+
output = capture { Muxilla::Muxinate.start }
|
7
|
+
output.should match /feature/
|
8
|
+
output.should match /configure/
|
9
|
+
end
|
10
|
+
it 'describes feature' do
|
11
|
+
output = capture { Muxilla::Muxinate.start }
|
12
|
+
output.should match /generate a new tmux config from a feature branch/
|
13
|
+
end
|
14
|
+
it 'describes bug' do
|
15
|
+
output = capture { Muxilla::Muxinate.start }
|
16
|
+
output.should match /generate a new tmux config from a bug branch/
|
17
|
+
end
|
18
|
+
it 'describes configure' do
|
19
|
+
output = capture { Muxilla::Muxinate.start }
|
20
|
+
output.should match /how your dev environment is setup/
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'tasks' do
|
25
|
+
describe '#configure' do
|
26
|
+
before do
|
27
|
+
$stdin.stub :gets => '~/dev'
|
28
|
+
if File.exists? File.expand_path('~/.muxilla.conf')
|
29
|
+
File.delete File.expand_path('~/.muxilla.conf')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
it 'prompts for the users development directory' do
|
33
|
+
$stdin.should_receive(:gets).and_return('~/dev')
|
34
|
+
output = capture { Muxilla::Muxinate.start ['configure'] }
|
35
|
+
output.should match /what is your development directory/
|
36
|
+
File.read(File.expand_path '~/.muxilla.conf').should match /~\/dev/
|
37
|
+
end
|
38
|
+
it 'outputs a muxilla.conf file in the users home directory' do
|
39
|
+
capture { Muxilla::Muxinate.start ['configure'] }
|
40
|
+
File.exists?(File.expand_path '~/.muxilla.conf').should be
|
41
|
+
end
|
42
|
+
after do
|
43
|
+
File.delete(File.expand_path '~/.muxilla.conf')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#feature' do
|
48
|
+
it 'requires configuration' do
|
49
|
+
Muxilla::Muxinator.should_not_receive :start
|
50
|
+
output = capture { Muxilla::Muxinate.start ['feature', 'foo'] }
|
51
|
+
output.should match /please run muxilla configure to setup/i
|
52
|
+
end
|
53
|
+
context 'after configuring' do
|
54
|
+
before do
|
55
|
+
$stdin.stub :gets => '~/dev'
|
56
|
+
capture { Muxilla::Muxinate.start ['configure'] }
|
57
|
+
end
|
58
|
+
it 'calls the muxilla generator' do
|
59
|
+
Muxilla::Muxinator.should_receive :start
|
60
|
+
Muxilla::Muxinate.start ['feature', 'foo']
|
61
|
+
end
|
62
|
+
it 'uses a feature branchname' do
|
63
|
+
Muxilla::Muxinator.should_receive(:start).with do |args|
|
64
|
+
mux = args.first
|
65
|
+
mux.type.should == :feature
|
66
|
+
end
|
67
|
+
Muxilla::Muxinate.start ['feature', 'foo']
|
68
|
+
end
|
69
|
+
it 'uses the nickname' do
|
70
|
+
Muxilla::Muxinator.should_receive(:start).with do |args|
|
71
|
+
mux = args.first
|
72
|
+
mux.nickname.should == 'foo'
|
73
|
+
end
|
74
|
+
Muxilla::Muxinate.start ['feature', 'foo']
|
75
|
+
end
|
76
|
+
it 'respects the update parameter' do
|
77
|
+
Muxilla::Muxinator.should_receive(:start).with do |args|
|
78
|
+
mux = args.first
|
79
|
+
mux.update.should be
|
80
|
+
end
|
81
|
+
Muxilla::Muxinate.start ['feature', 'foo', '--update']
|
82
|
+
end
|
83
|
+
it 'respects the id parameter' do
|
84
|
+
Muxilla::Muxinator.should_receive(:start).with do |args|
|
85
|
+
mux = args.first
|
86
|
+
mux.id.should == 1234
|
87
|
+
end
|
88
|
+
Muxilla::Muxinate.start ['feature', 'foo', '--id', 1234]
|
89
|
+
end
|
90
|
+
it 'respects the code parameter' do
|
91
|
+
Muxilla::Muxinator.should_receive(:start).with do |args|
|
92
|
+
mux = args.first
|
93
|
+
mux.code.should == ['fumanchu']
|
94
|
+
end
|
95
|
+
Muxilla::Muxinate.start ['feature', 'foo', '--apps=code:fumanchu']
|
96
|
+
end
|
97
|
+
it 'respects the rails parameter' do
|
98
|
+
Muxilla::Muxinator.should_receive(:start).with do |args|
|
99
|
+
mux = args.first
|
100
|
+
mux.rails.should == ['fumanchu']
|
101
|
+
end
|
102
|
+
Muxilla::Muxinate.start ['feature', 'foo', '--apps=rails:fumanchu']
|
103
|
+
end
|
104
|
+
it 'respects the resque parameter' do
|
105
|
+
Muxilla::Muxinator.should_receive(:start).with do |args|
|
106
|
+
mux = args.first
|
107
|
+
mux.resque.should == ['fumanchu']
|
108
|
+
end
|
109
|
+
Muxilla::Muxinate.start ['feature', 'foo', '--apps=resque:fumanchu']
|
110
|
+
end
|
111
|
+
it 'generates a config containing our branch nickname' do
|
112
|
+
Muxilla::Muxinate.start ['feature', 'foo']
|
113
|
+
File.read(tmux_config).should match 'foo'
|
114
|
+
end
|
115
|
+
after do
|
116
|
+
File.delete(File.expand_path '~/.muxilla.conf')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '#bug' do
|
122
|
+
before do
|
123
|
+
File.delete(File.expand_path '~/.muxilla.conf') if File.exists?(File.expand_path '~/.muxilla.conf')
|
124
|
+
end
|
125
|
+
it 'requires configuration' do
|
126
|
+
Muxilla::Muxinator.should_not_receive :start
|
127
|
+
output = capture { Muxilla::Muxinate.start ['bug', 'foo'] }
|
128
|
+
output.should match /please run muxilla configure to setup/i
|
129
|
+
end
|
130
|
+
context 'after configuring' do
|
131
|
+
before do
|
132
|
+
$stdin.stub :gets => '~/dev'
|
133
|
+
capture { Muxilla::Muxinate.start ['configure'] }
|
134
|
+
end
|
135
|
+
it 'calls the muxilla generator' do
|
136
|
+
Muxilla::Muxinator.should_receive :start
|
137
|
+
Muxilla::Muxinate.start ['bug', 'foo']
|
138
|
+
end
|
139
|
+
it 'uses a feature branchname' do
|
140
|
+
Muxilla::Muxinator.should_receive(:start).with do |args|
|
141
|
+
mux = args.first
|
142
|
+
mux.type.should == :bug
|
143
|
+
end
|
144
|
+
Muxilla::Muxinate.start ['bug', 'foo']
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe '#chore' do
|
150
|
+
before do
|
151
|
+
File.delete(File.expand_path '~/.muxilla.conf') if File.exists?(File.expand_path '~/.muxilla.conf')
|
152
|
+
end
|
153
|
+
it 'requires configuration' do
|
154
|
+
Muxilla::Muxinator.should_not_receive :start
|
155
|
+
output = capture { Muxilla::Muxinate.start ['chore', 'foo'] }
|
156
|
+
output.should match /please run muxilla configure to setup/i
|
157
|
+
end
|
158
|
+
context 'after configuring' do
|
159
|
+
before do
|
160
|
+
$stdin.stub :gets => '~/dev'
|
161
|
+
capture { Muxilla::Muxinate.start ['configure'] }
|
162
|
+
end
|
163
|
+
it 'calls the muxilla generator' do
|
164
|
+
Muxilla::Muxinator.should_receive :start
|
165
|
+
Muxilla::Muxinate.start ['chore', 'foo']
|
166
|
+
end
|
167
|
+
it 'uses a feature branchname' do
|
168
|
+
Muxilla::Muxinator.should_receive(:start).with do |args|
|
169
|
+
mux = args.first
|
170
|
+
mux.type.should == :chore
|
171
|
+
end
|
172
|
+
Muxilla::Muxinate.start ['chore', 'foo']
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Muxilla::Muxinator do
|
4
|
+
it 'outputs a .tmux file' do
|
5
|
+
Muxilla::Muxinator.start [Muxilla::Mux.new('foo', {:apps => {'code' => 'foo,bar'}})]
|
6
|
+
File.exists?(tmux_config).should be
|
7
|
+
File.read(tmux_config).should match /foo/
|
8
|
+
File.read(tmux_config).should match /bar/
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'doesnt use the home directory for output during tests' do
|
12
|
+
Muxilla::Muxinator.output_file.should_not match /~/
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
require 'thor'
|
5
|
+
require 'thor/group'
|
6
|
+
require 'muxilla'
|
7
|
+
require 'rspec'
|
8
|
+
require 'stringio'
|
9
|
+
ARGV.clear
|
10
|
+
|
11
|
+
Rspec.configure do |config|
|
12
|
+
|
13
|
+
def capture(stream = :stdout)
|
14
|
+
begin
|
15
|
+
stream = stream.to_s
|
16
|
+
eval "$#{stream} = StringIO.new"
|
17
|
+
yield
|
18
|
+
result = eval("$#{stream}").string
|
19
|
+
ensure
|
20
|
+
eval("$#{stream} = #{stream.upcase}")
|
21
|
+
end
|
22
|
+
result
|
23
|
+
end
|
24
|
+
|
25
|
+
def tmux_config
|
26
|
+
File.expand_path File.join(File.dirname(__FILE__), '..', 'output', 'tmux_config.tmux')
|
27
|
+
end
|
28
|
+
|
29
|
+
config.before :each do
|
30
|
+
if File.exists? tmux_config
|
31
|
+
File.delete tmux_config
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Muxilla
|
37
|
+
class Muxinator < Thor::Group
|
38
|
+
def self.output_file
|
39
|
+
'output/tmux_config.tmux'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: muxilla
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Apolzon
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-13 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: ruby-debug19
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: fuubar
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: thor
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
type: :runtime
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: json
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
type: :runtime
|
81
|
+
version_requirements: *id006
|
82
|
+
description: A prompt-based cli to generate a tmux script based on the story name and related systems
|
83
|
+
email:
|
84
|
+
- apolzon@gmail.com
|
85
|
+
executables: []
|
86
|
+
|
87
|
+
extensions: []
|
88
|
+
|
89
|
+
extra_rdoc_files: []
|
90
|
+
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- .rspec
|
94
|
+
- .rvmrc
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- README.rdoc
|
98
|
+
- Rakefile
|
99
|
+
- lib/muxilla.rb
|
100
|
+
- lib/muxilla/mux.rb
|
101
|
+
- lib/muxilla/muxinate.rb
|
102
|
+
- lib/muxilla/muxinator.rb
|
103
|
+
- lib/muxilla/templates/tmux_config.tt
|
104
|
+
- lib/muxilla/version.rb
|
105
|
+
- muxilla.gemspec
|
106
|
+
- spec/muxilla/mux_spec.rb
|
107
|
+
- spec/muxilla/muxinate_spec.rb
|
108
|
+
- spec/muxilla/muxinator_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
has_rdoc: true
|
111
|
+
homepage: ""
|
112
|
+
licenses: []
|
113
|
+
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: "0"
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: "0"
|
131
|
+
requirements: []
|
132
|
+
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 1.6.2
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: Quickly create story-specific tmux scripts
|
138
|
+
test_files:
|
139
|
+
- spec/muxilla/mux_spec.rb
|
140
|
+
- spec/muxilla/muxinate_spec.rb
|
141
|
+
- spec/muxilla/muxinator_spec.rb
|
142
|
+
- spec/spec_helper.rb
|