tabby2 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gemtest +0 -0
- data/.gitignore +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +30 -0
- data/LICENSE +19 -0
- data/README.markdown +42 -0
- data/Rakefile +10 -0
- data/bin/tabby +4 -0
- data/lib/tabby.rb +14 -0
- data/lib/tabby/base.rb +72 -0
- data/lib/tabby/cli.rb +26 -0
- data/lib/tabby/creator.rb +44 -0
- data/lib/tabby/editor.rb +19 -0
- data/lib/tabby/runner.rb +27 -0
- data/screenshot.png +0 -0
- data/script/tabby.osa.erb +10 -0
- data/spec/.tabby/mismatch.rb +3 -0
- data/spec/.tabby/spec_blog.rb +11 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/expand.rb +5 -0
- data/spec/support/stub_constant.rb +25 -0
- data/spec/support/with_constants.rb +22 -0
- data/spec/tabby/base_spec.rb +52 -0
- data/spec/tabby/cli_spec.rb +29 -0
- data/spec/tabby/creator_spec.rb +59 -0
- data/spec/tabby/editor_spec.rb +25 -0
- data/spec/tabby/runner_spec.rb +37 -0
- data/tabby2.gemspec +27 -0
- data/templates/project.rb.erb +7 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 21319252f40ee8728aa3e3ea385703992193383939f2140f54375fbeaa1c36f7
|
4
|
+
data.tar.gz: 1ac6dc464e39229135a630dc41f443a01a67e6892d3b1ed3b186a5775097658a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5534eefdb0ebe76878015626b594d7c61ee2c9d5bea5f9d6138be17a997ae741f9bc038bf9df3253ea2982fb5ea05090092bdc44bcd38c41b22b40c1bf916ea0
|
7
|
+
data.tar.gz: 2fbde15314b26b0048dab5cc7a8479665f5d7ef7b67c430820a325f7fa28e93f7ecc6cd2fb433e99e53d5599d52d778ab5a9a38b06d84bd6181ec30636b7857b
|
data/.gemtest
ADDED
File without changes
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
tabby (0.0.2)
|
5
|
+
thor (~> 0.14.6)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.1.2)
|
11
|
+
fakeout (0.0.1)
|
12
|
+
mnoble-fakefs (0.3.2)
|
13
|
+
rspec (2.1.0)
|
14
|
+
rspec-core (~> 2.1.0)
|
15
|
+
rspec-expectations (~> 2.1.0)
|
16
|
+
rspec-mocks (~> 2.1.0)
|
17
|
+
rspec-core (2.1.0)
|
18
|
+
rspec-expectations (2.1.0)
|
19
|
+
diff-lcs (~> 1.1.2)
|
20
|
+
rspec-mocks (2.1.0)
|
21
|
+
thor (0.14.6)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
fakeout (>= 0.0.1)
|
28
|
+
mnoble-fakefs (>= 0.3.1)
|
29
|
+
rspec (~> 2.1.0)
|
30
|
+
tabby!
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011 by Matte Noble
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE
|
data/README.markdown
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Tabby
|
2
|
+
Tabby is a simple iTerm2 environment configuration tool. It allows you to create different environments for different projects, each with their own set of tabs and command sets.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
|
6
|
+
### Defining Environments
|
7
|
+
Environments should be stored in `~/.tabby/`, using a simple and short name. We'll walk through building my `~/.tabby/blog.rb` environment.
|
8
|
+
|
9
|
+
Tabby environments are just regular Ruby classes. The filename and classname should match, with the classname following regular Ruby standards:
|
10
|
+
|
11
|
+
class Blog < Tabby::Base
|
12
|
+
end
|
13
|
+
|
14
|
+
Define your project's root directory with `basedir`:
|
15
|
+
|
16
|
+
class Blog < Tabby::Base
|
17
|
+
basedir "~/Dev/Blog"
|
18
|
+
end
|
19
|
+
|
20
|
+
Creating tabs is just a matter of creating methods. There should be one method per tab. The method name becomes the tab's title; replacing underscores with spaces.
|
21
|
+
|
22
|
+
class Blog < Tabby::Base
|
23
|
+
basedir "~/Dev/Blog"
|
24
|
+
|
25
|
+
def jekyll
|
26
|
+
exec "jekyll --auto --server"
|
27
|
+
end
|
28
|
+
|
29
|
+
def sass
|
30
|
+
exec "sass --watch public/css/main.sass:public/css/main.css"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Each tab will start off by `cd`'ing into the environment's `basedir`. Then it will execute it's list of commands in order.
|
35
|
+
|
36
|
+
### Starting An Environment
|
37
|
+
tabby blog
|
38
|
+
|
39
|
+

|
40
|
+
|
41
|
+
## License
|
42
|
+
See LICENSE
|
data/Rakefile
ADDED
data/bin/tabby
ADDED
data/lib/tabby.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "erb"
|
2
|
+
require "tempfile"
|
3
|
+
require "pathname"
|
4
|
+
require "thor"
|
5
|
+
|
6
|
+
module Tabby
|
7
|
+
ROOT = Pathname.new(File.dirname(__FILE__) + "/../").expand_path
|
8
|
+
TABBYDIR = Pathname.new("~/.tabby").expand_path
|
9
|
+
end
|
10
|
+
|
11
|
+
require "tabby/base"
|
12
|
+
require "tabby/runner"
|
13
|
+
require "tabby/creator"
|
14
|
+
require "tabby/editor"
|
data/lib/tabby/base.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module Tabby
|
2
|
+
class Base
|
3
|
+
class << self; attr_reader :_basedir; end
|
4
|
+
|
5
|
+
# Sets the project root directory.
|
6
|
+
#
|
7
|
+
# Parameters:
|
8
|
+
# dir Project's root directory path
|
9
|
+
#
|
10
|
+
def self.basedir(dir)
|
11
|
+
@_basedir = dir
|
12
|
+
end
|
13
|
+
|
14
|
+
# List of commands for the current tab to execute.
|
15
|
+
attr_accessor :commands
|
16
|
+
|
17
|
+
# Title of the current tab being created.
|
18
|
+
attr_accessor :title
|
19
|
+
|
20
|
+
# Rendered AppleScript source to be saved to a tempfile.
|
21
|
+
attr_accessor :template
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@commands = []
|
25
|
+
end
|
26
|
+
|
27
|
+
# Queue a command to be executed when the tab gets created.
|
28
|
+
#
|
29
|
+
# Parameters:
|
30
|
+
# command bash/zsh/etc command to be executed
|
31
|
+
#
|
32
|
+
def exec(command)
|
33
|
+
@commands << %{write text "#{command}"}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Call each instance method and create a tab for each one.
|
37
|
+
# Method names become tab titles, with underscores replaced
|
38
|
+
# with spaces.
|
39
|
+
#
|
40
|
+
def call
|
41
|
+
self.class.instance_methods(false).each do |method|
|
42
|
+
@commands = []
|
43
|
+
@title = method
|
44
|
+
send(method)
|
45
|
+
create_tab
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Project's base directory. Each tab +cd+'s into this
|
50
|
+
# directory before executing commands.
|
51
|
+
#
|
52
|
+
def basedir
|
53
|
+
self.class._basedir
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def create_tab
|
59
|
+
tempfile = Tempfile.new("tabby-#{@title}")
|
60
|
+
tempfile.write(render_script)
|
61
|
+
tempfile.close
|
62
|
+
system("osascript #{tempfile.path}")
|
63
|
+
end
|
64
|
+
|
65
|
+
def render_script
|
66
|
+
osapath = ROOT.join("script/tabby.osa.erb")
|
67
|
+
template = ERB.new(File.read(osapath))
|
68
|
+
commands = @commands.join("\n")
|
69
|
+
@template = template.result(binding)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/tabby/cli.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Tabby
|
2
|
+
class CLI < Thor
|
3
|
+
desc "open [project]", "Starts up the environment for a project."
|
4
|
+
def open(project=nil)
|
5
|
+
Tabby::Runner.new(project).run!
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "create [project]", "Creates an empty project config."
|
9
|
+
def create(project=nil)
|
10
|
+
Tabby::Creator.new(project).run!
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "edit [project]", "Opens the project config with $EDITOR."
|
14
|
+
def edit(project=nil)
|
15
|
+
Tabby::Editor.new(project).run!
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "list", "List all projects."
|
19
|
+
def list
|
20
|
+
puts "Tabby Projects"
|
21
|
+
Pathname.glob("#{TABBYDIR}/*.rb").each do |project|
|
22
|
+
puts " - #{project.basename(".rb")}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Tabby
|
2
|
+
class Creator
|
3
|
+
TEMPLATE = ROOT.join("templates/project.rb.erb")
|
4
|
+
|
5
|
+
attr_reader :project, :template
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@project = name
|
9
|
+
@template = ERB.new(TEMPLATE.expand_path.read)
|
10
|
+
end
|
11
|
+
|
12
|
+
def run!
|
13
|
+
if exists?
|
14
|
+
puts ">> Project already exists."
|
15
|
+
else
|
16
|
+
create_project_directory
|
17
|
+
create_project_file
|
18
|
+
puts ">> Successfully created #{@project}."
|
19
|
+
Tabby::Editor.new(@project).run!
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def exist?
|
24
|
+
project_path.exist?
|
25
|
+
end
|
26
|
+
alias :exists? :exist?
|
27
|
+
|
28
|
+
def create_project_directory
|
29
|
+
FileUtils.mkdir_p(TABBYDIR) unless File.directory?(TABBYDIR)
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_project_file
|
33
|
+
project_path.open("w") { |f| f << template.result(binding) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def project_path
|
37
|
+
TABBYDIR.join("#{project}.rb").expand_path
|
38
|
+
end
|
39
|
+
|
40
|
+
def klass
|
41
|
+
project.gsub(/_|-/, " ").split.map { |w| w.capitalize }.join
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/tabby/editor.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Tabby
|
2
|
+
class Editor
|
3
|
+
def initialize(project=nil)
|
4
|
+
@project = project
|
5
|
+
end
|
6
|
+
|
7
|
+
def run!
|
8
|
+
if path.exist?
|
9
|
+
system("$EDITOR #{TABBYDIR.join("#{@project}.rb")}")
|
10
|
+
else
|
11
|
+
Tabby::Creator.new(@project).run!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def path
|
16
|
+
TABBYDIR.join("#{@project}.rb")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/tabby/runner.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Tabby
|
2
|
+
class Runner
|
3
|
+
attr_reader :project
|
4
|
+
|
5
|
+
def initialize(project)
|
6
|
+
@project = project
|
7
|
+
@path = TABBYDIR.join("#{@project}.rb")
|
8
|
+
end
|
9
|
+
|
10
|
+
def dasherize
|
11
|
+
@project.gsub("_", "-")
|
12
|
+
end
|
13
|
+
|
14
|
+
def klass
|
15
|
+
@project.split(/_|-/).map { |p| p.capitalize }.join.to_sym
|
16
|
+
end
|
17
|
+
|
18
|
+
def run!
|
19
|
+
if @path.expand_path.exist?
|
20
|
+
require TABBYDIR.join("#{@project}.rb")
|
21
|
+
ObjectSpace.class.const_get(klass).new.call
|
22
|
+
else
|
23
|
+
puts ">> Project '#{@project}' does not exist."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/screenshot.png
ADDED
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "rspec"
|
2
|
+
require "fakefs/spec_helpers"
|
3
|
+
require "fakeout/spec_helpers"
|
4
|
+
require "stringio"
|
5
|
+
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
6
|
+
$LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
7
|
+
require "tabby"
|
8
|
+
require "tabby/runner"
|
9
|
+
require "tabby/creator"
|
10
|
+
require "tabby/cli"
|
11
|
+
|
12
|
+
require "support/stub_constant"
|
13
|
+
|
14
|
+
class FakeFile < StringIO
|
15
|
+
def path; "/tmp/#{object_id}"; end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Disable Kernel#system
|
19
|
+
module Kernel
|
20
|
+
def system(*args); end
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.include(Fakeout::SpecHelpers)
|
25
|
+
config.include(FakeFS::SpecHelpers)
|
26
|
+
|
27
|
+
config.before do
|
28
|
+
tabbydir = File.dirname(__FILE__) + "/.tabby/"
|
29
|
+
Tabby.stub_constant(:TABBYDIR => Pathname.new(tabbydir).expand_path)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Kernel
|
2
|
+
def stub_constant(constants)
|
3
|
+
silence!
|
4
|
+
constants.each do |name, value|
|
5
|
+
instance_variable_set("@unstubbed_#{name}", const_get(name))
|
6
|
+
const_set(name, value)
|
7
|
+
end
|
8
|
+
noise!
|
9
|
+
end
|
10
|
+
|
11
|
+
def silence!
|
12
|
+
@__verbose = $VERBOSE
|
13
|
+
$VERBOSE = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def noise!
|
17
|
+
$VERBOSE = @__verbose
|
18
|
+
end
|
19
|
+
|
20
|
+
def unstub_constant(name)
|
21
|
+
silence!
|
22
|
+
const_set(name, instance_variable_get("@unstubbed_#{name}"))
|
23
|
+
noise!
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "stringio"
|
2
|
+
|
3
|
+
class Object
|
4
|
+
def self.with_constants(constants, &block)
|
5
|
+
old_constants = {}
|
6
|
+
stderr = $stderr
|
7
|
+
$stderr = StringIO.new
|
8
|
+
|
9
|
+
constants.each do |constant, val|
|
10
|
+
old_constants[constant] = const_get(constant)
|
11
|
+
const_set(constant, val)
|
12
|
+
end
|
13
|
+
|
14
|
+
block.call
|
15
|
+
|
16
|
+
old_constants.each do |constant, val|
|
17
|
+
const_set(constant, val)
|
18
|
+
end
|
19
|
+
|
20
|
+
$stderr = stderr
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
class TabbySpecBlog < Tabby::Base
|
4
|
+
basedir "~/Dev/Blog"
|
5
|
+
def foo
|
6
|
+
exec "whoami"
|
7
|
+
exec "pwd"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Tabby::Base do
|
12
|
+
before do
|
13
|
+
Tempfile.stub(:new).and_return(FakeFile.new)
|
14
|
+
FakeFS.deactivate!
|
15
|
+
end
|
16
|
+
|
17
|
+
subject { TabbySpecBlog.new }
|
18
|
+
|
19
|
+
it "should set a base directory" do
|
20
|
+
subject.basedir.should == "~/Dev/Blog"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should queue commands to be executed" do
|
24
|
+
subject.exec("ls")
|
25
|
+
subject.commands.should include("write text \"ls\"")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should call all tab methods" do
|
29
|
+
subject.should_receive(:foo)
|
30
|
+
subject.call
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should create actual iTerm2 tab before each method call" do
|
34
|
+
subject.call
|
35
|
+
subject.template.should match /launch session "Default"/
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should set the title" do
|
39
|
+
subject.call
|
40
|
+
subject.template.should match /set name to "foo"/
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should change directory into the base directory" do
|
44
|
+
subject.call
|
45
|
+
subject.template.should match %r{write text "cd ~/Dev/Blog"}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should execute all commands" do
|
49
|
+
subject.call
|
50
|
+
subject.template.should match /write text "whoami"/
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Tabby::CLI do
|
4
|
+
let(:path) { Tabby::TABBYDIR.join("battle.rb") }
|
5
|
+
let(:runner) { mock('Tabby::Runner').as_null_object }
|
6
|
+
|
7
|
+
before do
|
8
|
+
Fakeout.activate!
|
9
|
+
Tempfile.stub(:new).and_return { FakeFile.new }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should open an existing project" do
|
13
|
+
Tabby::Runner.should_receive(:new).with("battle").and_return(runner)
|
14
|
+
Tabby::CLI.start(["open", "battle"])
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should create an empty project config" do
|
18
|
+
Tabby::CLI.start(["create", "battle"])
|
19
|
+
path.should exist
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should list available projects" do
|
23
|
+
FileUtils.mkdir_p(Tabby::TABBYDIR)
|
24
|
+
FileUtils.touch(path.expand_path.to_s)
|
25
|
+
|
26
|
+
Tabby::CLI.start(["list"])
|
27
|
+
stdout.should include "- battle"
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Tabby::Creator do
|
4
|
+
let(:basedir) { Tabby::TABBYDIR }
|
5
|
+
let(:path) { basedir.join("helicopter.rb") }
|
6
|
+
let(:creator) { Tabby::Creator.new("helicopter") }
|
7
|
+
|
8
|
+
before do
|
9
|
+
FakeFS.activate!
|
10
|
+
creator.run!
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create the tabby directory if it is missing" do
|
14
|
+
File.directory?(path.dirname).should be_true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should create a tabby file" do
|
18
|
+
File.exists?(path).should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have a project path" do
|
22
|
+
creator.project_path.to_s.should =~ /helicopter\.rb/
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should determine the class name for single word projects" do
|
26
|
+
creator.klass.should == "Helicopter"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should determine the class name for multi word projects with underscores" do
|
30
|
+
creator = Tabby::Creator.new("long_name_project")
|
31
|
+
creator.klass.should == "LongNameProject"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should determine the class name for multi word projects with hyphens" do
|
35
|
+
creator = Tabby::Creator.new("long-name-project")
|
36
|
+
creator.klass.should == "LongNameProject"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should create a templated project file" do
|
40
|
+
File.read(path).should == <<-PROJECT
|
41
|
+
class Helicopter < Tabby::Base
|
42
|
+
basedir "~/Dev/helicopter"
|
43
|
+
|
44
|
+
def server
|
45
|
+
exec "rails s"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
PROJECT
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should know if it already exists or not" do
|
52
|
+
creator.should exist
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should not create projects that already exist" do
|
56
|
+
creator.run!
|
57
|
+
stdout.should include "Project already exists."
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Tabby::Editor do
|
4
|
+
let(:basedir) { Tabby::TABBYDIR }
|
5
|
+
let(:path) { basedir.join("helicopter.rb") }
|
6
|
+
let(:editor) { Tabby::Editor.new("helicopter") }
|
7
|
+
|
8
|
+
before do
|
9
|
+
Fakeout.deactivate!
|
10
|
+
editor.stub(:path) { path }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should open a project file with $EDITOR" do
|
14
|
+
path.stub(:exist?) { true }
|
15
|
+
editor.should_receive(:system).with("$EDITOR #{path.expand_path}")
|
16
|
+
editor.run!
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should create a new project if it doesn't exist" do
|
20
|
+
path.stub(:exist?) { false }
|
21
|
+
creator = mock("Tabby::Creator").as_null_object
|
22
|
+
Tabby::Creator.should_receive(:new).with("helicopter").and_return(creator)
|
23
|
+
editor.run!
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
require File.dirname(__FILE__) + "/../.tabby/spec_blog"
|
3
|
+
|
4
|
+
describe Tabby::Runner do
|
5
|
+
let(:tabbydir) { Pathname.new(File.dirname(__FILE__) + "/../.tabby").expand_path }
|
6
|
+
let(:runner) { Tabby::Runner.new("spec_blog") }
|
7
|
+
|
8
|
+
before do
|
9
|
+
Tabby::Base.stub(:new).and_return(mock.as_null_object)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should convert an underscored project to hyphenated" do
|
13
|
+
Tabby::Runner.new("time_cop").dasherize.should == "time-cop"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should determine the class of a project with underscores" do
|
17
|
+
Tabby::Runner.new("time_cop").klass.should == :TimeCop
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should determine the class of a project with hyphens" do
|
21
|
+
Tabby::Runner.new("time-cop").klass.should == :TimeCop
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should determine the class of a project with underscores and hyphens" do
|
25
|
+
Tabby::Runner.new("jean-claude_van_damme").klass.should == :JeanClaudeVanDamme
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should find the project file" do
|
29
|
+
runner.should_receive(:require).with(tabbydir.join("spec_blog.rb"))
|
30
|
+
runner.run!
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should call the project class" do
|
34
|
+
SpecBlog.should_receive(:new).and_return(mock.as_null_object)
|
35
|
+
runner.run!
|
36
|
+
end
|
37
|
+
end
|
data/tabby2.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "tabby2"
|
6
|
+
s.version = "0.2.1"
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Jacques Crocker", "Matte Noble"]
|
9
|
+
s.email = ["jacques@nodeknockout.com", "me@mattenoble.com"]
|
10
|
+
s.homepage = "http://github.com/jacquescrocker/tabby2"
|
11
|
+
s.summary = %q{Simple iTerm2 project environment setup.}
|
12
|
+
s.description = %q{Simple iTerm2 project environment setup.}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.extra_rdoc_files = ["README.markdown", "screenshot.png"]
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
# Runtime
|
21
|
+
s.add_dependency "thor", "~> 0.14.6"
|
22
|
+
|
23
|
+
# Development
|
24
|
+
s.add_development_dependency "rspec", "~> 2.1.0"
|
25
|
+
s.add_development_dependency "fakeout", ">= 0.0.1"
|
26
|
+
s.add_development_dependency "mnoble-fakefs", ">= 0.3.1"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tabby2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jacques Crocker
|
8
|
+
- Matte Noble
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2019-06-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.14.6
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.14.6
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.1.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.1.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: fakeout
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.0.1
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.0.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: mnoble-fakefs
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.3.1
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.3.1
|
70
|
+
description: Simple iTerm2 project environment setup.
|
71
|
+
email:
|
72
|
+
- jacques@nodeknockout.com
|
73
|
+
- me@mattenoble.com
|
74
|
+
executables:
|
75
|
+
- tabby
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files:
|
78
|
+
- README.markdown
|
79
|
+
- screenshot.png
|
80
|
+
files:
|
81
|
+
- ".gemtest"
|
82
|
+
- ".gitignore"
|
83
|
+
- Gemfile
|
84
|
+
- Gemfile.lock
|
85
|
+
- LICENSE
|
86
|
+
- README.markdown
|
87
|
+
- Rakefile
|
88
|
+
- bin/tabby
|
89
|
+
- lib/tabby.rb
|
90
|
+
- lib/tabby/base.rb
|
91
|
+
- lib/tabby/cli.rb
|
92
|
+
- lib/tabby/creator.rb
|
93
|
+
- lib/tabby/editor.rb
|
94
|
+
- lib/tabby/runner.rb
|
95
|
+
- screenshot.png
|
96
|
+
- script/tabby.osa.erb
|
97
|
+
- spec/.tabby/mismatch.rb
|
98
|
+
- spec/.tabby/spec_blog.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/support/expand.rb
|
101
|
+
- spec/support/stub_constant.rb
|
102
|
+
- spec/support/with_constants.rb
|
103
|
+
- spec/tabby/base_spec.rb
|
104
|
+
- spec/tabby/cli_spec.rb
|
105
|
+
- spec/tabby/creator_spec.rb
|
106
|
+
- spec/tabby/editor_spec.rb
|
107
|
+
- spec/tabby/runner_spec.rb
|
108
|
+
- tabby2.gemspec
|
109
|
+
- templates/project.rb.erb
|
110
|
+
homepage: http://github.com/jacquescrocker/tabby2
|
111
|
+
licenses: []
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.7.5
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Simple iTerm2 project environment setup.
|
133
|
+
test_files:
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
- spec/support/expand.rb
|
136
|
+
- spec/support/stub_constant.rb
|
137
|
+
- spec/support/with_constants.rb
|
138
|
+
- spec/tabby/base_spec.rb
|
139
|
+
- spec/tabby/cli_spec.rb
|
140
|
+
- spec/tabby/creator_spec.rb
|
141
|
+
- spec/tabby/editor_spec.rb
|
142
|
+
- spec/tabby/runner_spec.rb
|