teamocil 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- teamocil (0.3.1)
4
+ teamocil (0.3.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -19,7 +19,7 @@ GEM
19
19
  diff-lcs (~> 1.1.2)
20
20
  rspec-mocks (2.6.0)
21
21
  syntax (1.0.0)
22
- yard (0.7.2)
22
+ yard (0.7.5)
23
23
 
24
24
  PLATFORMS
25
25
  ruby
data/Rakefile CHANGED
@@ -1,11 +1,28 @@
1
+ require "bundler"
2
+ Bundler.require(:development)
3
+
1
4
  require "bundler/gem_tasks"
5
+ require "rspec/core/rake_task"
6
+
7
+ task :default => :spec
2
8
 
3
- desc "Run specs"
4
- task :spec do # {{{
5
- sh "bundle exec rspec --color --format=nested #{Dir.glob(File.join(File.dirname(__FILE__), "spec/**/*_spec.rb")).join(" ")}"
9
+ desc "Run all specs"
10
+ RSpec::Core::RakeTask.new(:spec) do |task| # {{{
11
+ task.pattern = "spec/**/*_spec.rb"
12
+ task.rspec_opts = "--colour --format=documentation"
6
13
  end # }}}
7
14
 
8
- desc "Generate documentation"
9
- task :doc do # {{{
10
- sh "bundle exec yard doc"
15
+ desc "Generate YARD Documentation"
16
+ YARD::Rake::YardocTask.new do |task| # {{{
17
+ task.options = [
18
+ "-o", File.expand_path("../doc", __FILE__),
19
+ "--readme=README.md",
20
+ "--markup=markdown",
21
+ "--markup-provider=maruku",
22
+ "--no-private",
23
+ "--no-cache",
24
+ "--protected",
25
+ "--title=Teamocil",
26
+ ]
27
+ task.files = ["lib/**/*.rb"]
11
28
  end # }}}
data/lib/teamocil.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Teamocil
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  autoload :Layout, "teamocil/layout"
4
4
  autoload :CLI, "teamocil/cli"
5
5
  end
data/lib/teamocil/cli.rb CHANGED
@@ -12,8 +12,6 @@ module Teamocil
12
12
  # @param argv [Hash] the command line parameters hash (usually `ARGV`).
13
13
  # @param env [Hash] the environment variables hash (usually `ENV`).
14
14
  def initialize(argv, env) # {{{
15
- bail "You must be in a tmux session to use teamocil" unless env["TMUX"]
16
-
17
15
  parse_options! argv
18
16
  layout_path = File.join("#{env["HOME"]}", ".teamocil")
19
17
 
@@ -22,19 +20,16 @@ module Teamocil
22
20
  return print_layouts
23
21
  end
24
22
 
25
- if @options.include?(:layout)
26
- file = @options[:layout]
27
- else
28
- file = ::File.join(layout_path, "#{argv[0]}.yml")
29
- end
23
+ file = @options[:layout] || ::File.join(layout_path, "#{argv[0]}.yml")
30
24
 
31
25
  if @options[:edit]
32
26
  ::FileUtils.touch file unless File.exists?(file)
33
- system("$EDITOR \"#{file}\"")
27
+ Kernel.system("$EDITOR \"#{file}\"")
34
28
  else
35
29
  bail "There is no file \"#{file}\"" unless File.exists?(file)
36
- parsed_layout = YAML.load_file(file)
37
- @layout = Teamocil::Layout.new(parsed_layout, @options)
30
+ bail "You must be in a tmux session to use teamocil" unless env["TMUX"]
31
+
32
+ @layout = Teamocil::Layout.new(YAML.load_file(file), @options)
38
33
  @layout.compile!
39
34
  @layout.execute_commands(@layout.generate_commands)
40
35
  end
data/spec/cli_spec.rb CHANGED
@@ -1,26 +1,63 @@
1
+ # encoding: utf-8
1
2
  require File.join(File.dirname(__FILE__), "spec_helper.rb")
2
3
 
3
4
  describe Teamocil::CLI do
4
5
 
5
6
  context "executing" do
6
7
 
7
- before do # {{{
8
- @fake_env = { "TMUX" => 1, "HOME" => File.join(File.dirname(__FILE__), "fixtures") }
9
- end # }}}
8
+ before do # {{{
9
+ @fake_env = { "TMUX" => 1, "HOME" => File.join(File.dirname(__FILE__), "fixtures") }
10
+ end # }}}
10
11
 
11
- it "creates a layout" do # {{{
12
- @cli = Teamocil::CLI.new(["sample"], @fake_env)
13
- @cli.layout.session.name.should == "sample"
14
- @cli.layout.session.windows.length.should == 2
15
- @cli.layout.session.windows.first.name.should == "foo"
16
- @cli.layout.session.windows.last.name.should == "bar"
17
- end # }}}
12
+ context "not in tmux" do
18
13
 
19
- it "lists available layouts" do # {{{
20
- @cli = Teamocil::CLI.new(["--list"], @fake_env)
21
- @cli.layouts.should == ["sample", "sample-2"]
22
- end # }}}
14
+ it "should allow editing" do # {{{
15
+ FileUtils.stub(:touch)
16
+ Kernel.should_receive(:system).with(any_args())
23
17
 
24
- end
18
+ @cli = Teamocil::CLI.new(["--edit", "my-layout"], @fake_env)
19
+ end # }}}
20
+
21
+ end
22
+
23
+ context "in tmux" do
24
+
25
+ before :each do # {{{
26
+ Teamocil::CLI.messages = []
27
+ end # }}}
28
+
29
+ it "creates a layout from a name" do # {{{
30
+ @cli = Teamocil::CLI.new(["sample"], @fake_env)
31
+ @cli.layout.session.name.should == "sample"
32
+ @cli.layout.session.windows.length.should == 2
33
+ @cli.layout.session.windows.first.name.should == "foo"
34
+ @cli.layout.session.windows.last.name.should == "bar"
35
+ end # }}}
36
+
37
+ it "fails to create a layout from a layout that doesn’t exist" do # {{{
38
+ lambda { @cli = Teamocil::CLI.new(["i-do-not-exist"], @fake_env) }.should raise_error SystemExit
39
+ Teamocil::CLI.messages.should include("There is no file \"#{File.join(File.dirname(__FILE__), "fixtures", ".teamocil", "i-do-not-exist.yml")}\"")
40
+ end # }}}
25
41
 
42
+ it "creates a layout from a specific file" do # {{{
43
+ @cli = Teamocil::CLI.new(["--layout", "./spec/fixtures/.teamocil/sample.yml"], @fake_env)
44
+ @cli.layout.session.name.should == "sample"
45
+ @cli.layout.session.windows.length.should == 2
46
+ @cli.layout.session.windows.first.name.should == "foo"
47
+ @cli.layout.session.windows.last.name.should == "bar"
48
+ end # }}}
49
+
50
+ it "fails to create a layout from a file that doesn’t exist" do # {{{
51
+ lambda { @cli = Teamocil::CLI.new(["--layout", "./spec/fixtures/.teamocil/i-do-not-exist.yml"], @fake_env) }.should raise_error SystemExit
52
+ Teamocil::CLI.messages.should include("There is no file \"./spec/fixtures/.teamocil/i-do-not-exist.yml\"")
53
+ end # }}}
54
+
55
+ it "lists available layouts" do # {{{
56
+ @cli = Teamocil::CLI.new(["--list"], @fake_env)
57
+ @cli.layouts.should == ["sample", "sample-2"]
58
+ end # }}}
59
+
60
+ end
61
+
62
+ end
26
63
  end
data/spec/layout_spec.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.join(File.dirname(__FILE__), "spec_helper.rb")
2
3
 
3
4
  describe Teamocil::Layout do
@@ -8,90 +9,110 @@ describe Teamocil::Layout do
8
9
  @layout = Teamocil::Layout.new(layouts["two-windows"], {})
9
10
  end # }}}
10
11
 
11
- it "creates windows" do # {{{
12
- session = @layout.compile!
13
- session.windows.each do |window|
14
- window.should be_an_instance_of Teamocil::Layout::Window
15
- end
16
- end # }}}
17
-
18
- it "creates windows with names" do # {{{
19
- session = @layout.compile!
20
- session.windows[0].name.should == "foo"
21
- session.windows[1].name.should == "bar"
22
- end # }}}
23
-
24
- it "creates windows with root paths" do # {{{
25
- session = @layout.compile!
26
- session.windows[0].root.should == "/foo"
27
- session.windows[1].root.should == "/bar"
28
- end # }}}
29
-
30
- it "creates splits" do # {{{
31
- session = @layout.compile!
32
- session.windows.first.splits.each do |split|
33
- split.should be_an_instance_of Teamocil::Layout::Split
34
- end
35
- end # }}}
36
-
37
- it "creates splits with dimensions" do # {{{
38
- session = @layout.compile!
39
- session.windows.first.splits[0].width.should == nil
40
- session.windows.first.splits[1].width.should == 50
41
- end # }}}
42
-
43
- it "creates splits with commands specified in strings" do # {{{
44
- session = @layout.compile!
45
- session.windows.first.splits[0].cmd.should == "echo 'foo'"
46
- end # }}}
47
-
48
- it "creates splits with commands specified in an array" do # {{{
49
- session = @layout.compile!
50
- session.windows.last.splits[0].cmd.length.should == 2
51
- session.windows.last.splits[0].cmd.first.should == "echo 'bar'"
52
- session.windows.last.splits[0].cmd.last.should == "echo 'bar in an array'"
53
- end # }}}
54
-
55
- it "creates windows with before filters" do # {{{
56
- layout = Teamocil::Layout.new(layouts["two-windows-with-filters"], {})
57
- session = layout.compile!
58
- session.windows.first.filters["before"].length.should == 2
59
- session.windows.first.filters["before"].first.should == "echo first before filter"
60
- session.windows.first.filters["before"].last.should == "echo second before filter"
61
- end # }}}
62
-
63
- it "creates windows with after filters" do # {{{
64
- layout = Teamocil::Layout.new(layouts["two-windows-with-filters"], {})
65
- session = layout.compile!
66
- session.windows.first.filters["after"].length.should == 2
67
- session.windows.first.filters["after"].first.should == "echo first after filter"
68
- session.windows.first.filters["after"].last.should == "echo second after filter"
69
- end # }}}
70
-
71
- it "should handle blank filters" do # {{{
72
- session = @layout.compile!
73
- session.windows.first.filters.should have_key "after"
74
- session.windows.first.filters.should have_key "before"
75
- session.windows.first.filters["after"].should be_empty
76
- session.windows.first.filters["before"].should be_empty
77
- end # }}}
78
-
79
- it "should handle splits without a target" do # {{{
80
- session = @layout.compile!
81
- session.windows.last.splits.last.target.should == nil
82
- end # }}}
83
-
84
- it "should handle splits with a target" do # {{{
85
- session = @layout.compile!
86
- session.windows.last.splits.first.target.should == "bottom-right"
87
- end # }}}
88
-
89
- it "should handle windows within a session" do # {{{
90
- layout = Teamocil::Layout.new(layouts["three-windows-within-a-session"], {})
91
- session = layout.compile!
92
- session.windows.length.should == 3
93
- session.name.should == "my awesome session"
94
- end # }}}
12
+ describe "windows" do
13
+
14
+ it "creates windows" do # {{{
15
+ session = @layout.compile!
16
+ session.windows.each do |window|
17
+ window.should be_an_instance_of Teamocil::Layout::Window
18
+ end
19
+ end # }}}
20
+
21
+ it "creates windows with names" do # {{{
22
+ session = @layout.compile!
23
+ session.windows[0].name.should == "foo"
24
+ session.windows[1].name.should == "bar"
25
+ end # }}}
26
+
27
+ it "creates windows with root paths" do # {{{
28
+ session = @layout.compile!
29
+ session.windows[0].root.should == "/foo"
30
+ session.windows[1].root.should == "/bar"
31
+ end # }}}
32
+
33
+ end
34
+
35
+ describe "splits" do
36
+
37
+ it "creates splits" do # {{{
38
+ session = @layout.compile!
39
+ session.windows.first.splits.each do |split|
40
+ split.should be_an_instance_of Teamocil::Layout::Split
41
+ end
42
+ end # }}}
43
+
44
+ it "creates splits with dimensions" do # {{{
45
+ session = @layout.compile!
46
+ session.windows.first.splits[0].width.should == nil
47
+ session.windows.first.splits[1].width.should == 50
48
+ end # }}}
49
+
50
+ it "creates splits with commands specified in strings" do # {{{
51
+ session = @layout.compile!
52
+ session.windows.first.splits[0].cmd.should == "echo 'foo'"
53
+ end # }}}
54
+
55
+ it "creates splits with commands specified in an array" do # {{{
56
+ session = @layout.compile!
57
+ session.windows.last.splits[0].cmd.length.should == 2
58
+ session.windows.last.splits[0].cmd.first.should == "echo 'bar'"
59
+ session.windows.last.splits[0].cmd.last.should == "echo 'bar in an array'"
60
+ end # }}}
61
+
62
+ end
63
+
64
+ describe "filters" do
65
+
66
+ it "creates windows with before filters" do # {{{
67
+ layout = Teamocil::Layout.new(layouts["two-windows-with-filters"], {})
68
+ session = layout.compile!
69
+ session.windows.first.filters["before"].length.should == 2
70
+ session.windows.first.filters["before"].first.should == "echo first before filter"
71
+ session.windows.first.filters["before"].last.should == "echo second before filter"
72
+ end # }}}
73
+
74
+ it "creates windows with after filters" do # {{{
75
+ layout = Teamocil::Layout.new(layouts["two-windows-with-filters"], {})
76
+ session = layout.compile!
77
+ session.windows.first.filters["after"].length.should == 2
78
+ session.windows.first.filters["after"].first.should == "echo first after filter"
79
+ session.windows.first.filters["after"].last.should == "echo second after filter"
80
+ end # }}}
81
+
82
+ it "should handle blank filters" do # {{{
83
+ session = @layout.compile!
84
+ session.windows.first.filters.should have_key "after"
85
+ session.windows.first.filters.should have_key "before"
86
+ session.windows.first.filters["after"].should be_empty
87
+ session.windows.first.filters["before"].should be_empty
88
+ end # }}}
89
+
90
+ end
91
+
92
+ describe "targets" do
93
+
94
+ it "should handle splits without a target" do # {{{
95
+ session = @layout.compile!
96
+ session.windows.last.splits.last.target.should == nil
97
+ end # }}}
98
+
99
+ it "should handle splits with a target" do # {{{
100
+ session = @layout.compile!
101
+ session.windows.last.splits.first.target.should == "bottom-right"
102
+ end # }}}
103
+
104
+ end
105
+
106
+ describe "sessions" do
107
+
108
+ it "should handle windows within a session" do # {{{
109
+ layout = Teamocil::Layout.new(layouts["three-windows-within-a-session"], {})
110
+ session = layout.compile!
111
+ session.windows.length.should == 3
112
+ session.name.should == "my awesome session"
113
+ end # }}}
114
+
115
+ end
95
116
 
96
117
  end
97
118
 
data/spec/mock/cli.rb CHANGED
@@ -5,10 +5,28 @@ module Teamocil
5
5
  def self.included(base) # {{{
6
6
  base.class_eval do
7
7
 
8
+ # Return all messages
9
+ def self.messages # {{{
10
+ @@messages
11
+ end # }}}
12
+
13
+ # Change messages
14
+ def self.messages=(messages) # {{{
15
+ @@messages = messages
16
+ end # }}}
17
+
8
18
  # Do not print anything
9
- def print_layouts
19
+ def print_layouts # {{{
10
20
  # Nothing
11
- end
21
+ end # }}}
22
+
23
+ # Print an error message and exit the utility
24
+ #
25
+ # @param msg [Mixed] something to print before exiting.
26
+ def bail(msg) # {{{
27
+ Teamocil::CLI.messages << msg
28
+ exit 1
29
+ end # }}}
12
30
 
13
31
  end
14
32
  end # }}}
data/teamocil.gemspec CHANGED
@@ -25,5 +25,4 @@ spec = Gem::Specification.new do |s|
25
25
  s.add_development_dependency "rspec"
26
26
  s.add_development_dependency "yard"
27
27
  s.add_development_dependency "maruku"
28
-
29
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamocil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-05 00:00:00.000000000Z
12
+ date: 2012-03-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70203537739940 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70203537739940
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &70203539182320 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70203539182320
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: yard
38
- requirement: &70203539181900 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70203539181900
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: maruku
49
- requirement: &70203539181480 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70203539181480
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  description: Teamocil helps you set up window and splits layouts for tmux using YAML
59
79
  configuration files.
60
80
  email: remi@exomel.com
@@ -65,7 +85,6 @@ extra_rdoc_files: []
65
85
  files:
66
86
  - .gitignore
67
87
  - .travis.yml
68
- - .yardopts
69
88
  - Gemfile
70
89
  - Gemfile.lock
71
90
  - LICENSE
@@ -104,15 +123,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
123
  - - ! '>='
105
124
  - !ruby/object:Gem::Version
106
125
  version: '0'
126
+ segments:
127
+ - 0
128
+ hash: -2252634995689640042
107
129
  required_rubygems_version: !ruby/object:Gem::Requirement
108
130
  none: false
109
131
  requirements:
110
132
  - - ! '>='
111
133
  - !ruby/object:Gem::Version
112
134
  version: '0'
135
+ segments:
136
+ - 0
137
+ hash: -2252634995689640042
113
138
  requirements: []
114
139
  rubyforge_project:
115
- rubygems_version: 1.8.10
140
+ rubygems_version: 1.8.18
116
141
  signing_key:
117
142
  specification_version: 3
118
143
  summary: Easy window and split layouts for tmux
data/.yardopts DELETED
@@ -1,13 +0,0 @@
1
- --title "Teamocil"
2
-
3
- --no-cache
4
- --protected
5
- --no-private
6
-
7
- --markup "markdown"
8
- --markup-provider "maruku"
9
-
10
- --format html
11
-
12
- "README.mkd"
13
- "lib/**/*.rb"