tabby 0.0.2 → 0.1.0
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.
- data/Gemfile.lock +6 -0
- data/README.markdown +2 -2
- data/Rakefile +1 -1
- data/bin/tabby +2 -2
- data/lib/tabby.rb +9 -70
- 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 +18 -18
- data/spec/.tabby/mismatch.rb +3 -0
- data/spec/.tabby/spec_blog.rb +2 -2
- data/spec/spec_helper.rb +25 -3
- data/spec/support/stub_constant.rb +25 -0
- data/spec/support/with_constants.rb +2 -2
- data/spec/{tabby_spec.rb → tabby/base_spec.rb} +8 -4
- 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/tabby.gemspec +8 -3
- data/templates/project.rb.erb +7 -0
- metadata +56 -14
- data/lib/tabby/version.rb +0 -3
- data/spec/runner_spec.rb +0 -36
- data/spec/support/with_stubbed_stdout.rb +0 -8
data/Gemfile.lock
CHANGED
@@ -2,11 +2,14 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
tabby (0.0.2)
|
5
|
+
thor (~> 0.14.6)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: http://rubygems.org/
|
8
9
|
specs:
|
9
10
|
diff-lcs (1.1.2)
|
11
|
+
fakeout (0.0.1)
|
12
|
+
mnoble-fakefs (0.3.2)
|
10
13
|
rspec (2.1.0)
|
11
14
|
rspec-core (~> 2.1.0)
|
12
15
|
rspec-expectations (~> 2.1.0)
|
@@ -15,10 +18,13 @@ GEM
|
|
15
18
|
rspec-expectations (2.1.0)
|
16
19
|
diff-lcs (~> 1.1.2)
|
17
20
|
rspec-mocks (2.1.0)
|
21
|
+
thor (0.14.6)
|
18
22
|
|
19
23
|
PLATFORMS
|
20
24
|
ruby
|
21
25
|
|
22
26
|
DEPENDENCIES
|
27
|
+
fakeout (>= 0.0.1)
|
28
|
+
mnoble-fakefs (>= 0.3.1)
|
23
29
|
rspec (~> 2.1.0)
|
24
30
|
tabby!
|
data/README.markdown
CHANGED
@@ -21,11 +21,11 @@ Creating tabs is just a matter of creating methods. There should be one method p
|
|
21
21
|
|
22
22
|
class Blog < Tabby::Base
|
23
23
|
basedir "~/Dev/Blog"
|
24
|
-
|
24
|
+
|
25
25
|
def jekyll
|
26
26
|
exec "jekyll --auto --server"
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def sass
|
30
30
|
exec "sass --watch public/css/main.sass:public/css/main.css"
|
31
31
|
end
|
data/Rakefile
CHANGED
data/bin/tabby
CHANGED
data/lib/tabby.rb
CHANGED
@@ -1,75 +1,14 @@
|
|
1
1
|
require "erb"
|
2
2
|
require "tempfile"
|
3
|
+
require "pathname"
|
4
|
+
require "thor"
|
3
5
|
|
4
6
|
module Tabby
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# Sets the project root directory.
|
9
|
-
#
|
10
|
-
# Parameters:
|
11
|
-
# dir Project's root directory path
|
12
|
-
#
|
13
|
-
def self.basedir(dir)
|
14
|
-
@_basedir = dir
|
15
|
-
end
|
16
|
-
|
17
|
-
# List of commands for the current tab to execute.
|
18
|
-
attr_accessor :commands
|
19
|
-
|
20
|
-
# Title of the current tab being created.
|
21
|
-
attr_accessor :title
|
22
|
-
|
23
|
-
# Rendered AppleScript source to be saved to a tempfile.
|
24
|
-
attr_accessor :template
|
25
|
-
|
26
|
-
def initialize
|
27
|
-
@commands = []
|
28
|
-
end
|
29
|
-
|
30
|
-
# Queue a command to be executed when the tab gets created.
|
31
|
-
#
|
32
|
-
# Parameters:
|
33
|
-
# command bash/zsh/etc command to be executed
|
34
|
-
#
|
35
|
-
def exec(command)
|
36
|
-
@commands << %{write text "#{command}"}
|
37
|
-
end
|
38
|
-
|
39
|
-
# Call each instance method and create a tab for each one.
|
40
|
-
# Method names become tab titles, with underscores replaced
|
41
|
-
# with spaces.
|
42
|
-
#
|
43
|
-
def call
|
44
|
-
self.class.instance_methods(false).each do |method|
|
45
|
-
@commands = []
|
46
|
-
@title = method
|
47
|
-
send(method)
|
48
|
-
create_tab
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Project's base directory. Each tab +cd+'s into this
|
53
|
-
# directory before executing commands.
|
54
|
-
#
|
55
|
-
def basedir
|
56
|
-
self.class._basedir
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def create_tab
|
62
|
-
tempfile = Tempfile.new("tabby-#{@title}")
|
63
|
-
tempfile.write(render_script)
|
64
|
-
tempfile.close
|
65
|
-
Kernel.system("osascript #{tempfile.path}")
|
66
|
-
end
|
67
|
-
|
68
|
-
def render_script
|
69
|
-
osapath = File.expand_path("../../script/tabby.osa.erb", __FILE__)
|
70
|
-
template = ERB.new(File.read(osapath))
|
71
|
-
commands = @commands.join("\n")
|
72
|
-
@template = template.result(binding)
|
73
|
-
end
|
74
|
-
end
|
7
|
+
ROOT = Pathname.new(File.dirname(__FILE__) + "/../").expand_path
|
8
|
+
TABBYDIR = Pathname.new("~/.tabby").expand_path
|
75
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
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
module Tabby
|
2
2
|
class Runner
|
3
|
-
TABBYDIR = File.expand_path("~/.tabby")
|
4
|
-
|
5
|
-
# Project name, should be the filename in ~/.tabby.
|
6
3
|
attr_reader :project
|
7
4
|
|
8
|
-
def initialize(
|
9
|
-
@project =
|
10
|
-
@
|
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
|
11
16
|
end
|
12
17
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
puts "=> ERROR: Project (#{TABBYDIR}/#{@project}.rb) does not exist."
|
21
|
-
rescue NameError
|
22
|
-
puts "=> ERROR: Project filename/classname mismatch."
|
23
|
-
puts " Filename is: #{@project}.rb"
|
24
|
-
puts " Classname should be: #{@klass}"
|
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
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/spec/.tabby/spec_blog.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,31 @@
|
|
1
1
|
require "rspec"
|
2
|
+
require "fakefs/spec_helpers"
|
3
|
+
require "fakeout/spec_helpers"
|
2
4
|
require "stringio"
|
3
5
|
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
4
6
|
$LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
5
7
|
require "tabby"
|
6
8
|
require "tabby/runner"
|
7
|
-
require "
|
8
|
-
require "
|
9
|
-
|
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
|
@@ -5,7 +5,7 @@ class Object
|
|
5
5
|
old_constants = {}
|
6
6
|
stderr = $stderr
|
7
7
|
$stderr = StringIO.new
|
8
|
-
|
8
|
+
|
9
9
|
constants.each do |constant, val|
|
10
10
|
old_constants[constant] = const_get(constant)
|
11
11
|
const_set(constant, val)
|
@@ -16,7 +16,7 @@ class Object
|
|
16
16
|
old_constants.each do |constant, val|
|
17
17
|
const_set(constant, val)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
$stderr = stderr
|
21
21
|
end
|
22
22
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
class TabbySpecBlog < Tabby::Base
|
4
4
|
basedir "~/Dev/Blog"
|
@@ -9,7 +9,11 @@ class TabbySpecBlog < Tabby::Base
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe Tabby::Base do
|
12
|
-
before
|
12
|
+
before do
|
13
|
+
Tempfile.stub(:new).and_return(FakeFile.new)
|
14
|
+
FakeFS.deactivate!
|
15
|
+
end
|
16
|
+
|
13
17
|
subject { TabbySpecBlog.new }
|
14
18
|
|
15
19
|
it "should set a base directory" do
|
@@ -30,7 +34,7 @@ describe Tabby::Base do
|
|
30
34
|
subject.call
|
31
35
|
subject.template.should match /launch session "Default"/
|
32
36
|
end
|
33
|
-
|
37
|
+
|
34
38
|
it "should set the title" do
|
35
39
|
subject.call
|
36
40
|
subject.template.should match /set name to "foo"/
|
@@ -40,7 +44,7 @@ describe Tabby::Base do
|
|
40
44
|
subject.call
|
41
45
|
subject.template.should match %r{write text "cd ~/Dev/Blog"}
|
42
46
|
end
|
43
|
-
|
47
|
+
|
44
48
|
it "should execute all commands" do
|
45
49
|
subject.call
|
46
50
|
subject.template.should match /write text "whoami"/
|
@@ -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/tabby.gemspec
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "tabby/version"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "tabby"
|
7
|
-
s.version =
|
6
|
+
s.version = "0.1.0"
|
8
7
|
s.platform = Gem::Platform::RUBY
|
9
8
|
s.authors = ["Matte Noble"]
|
10
9
|
s.email = ["me@mattenoble.com"]
|
@@ -18,5 +17,11 @@ Gem::Specification.new do |s|
|
|
18
17
|
s.extra_rdoc_files = ["README.markdown", "screenshot.png"]
|
19
18
|
s.require_paths = ["lib"]
|
20
19
|
|
21
|
-
|
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"
|
22
27
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: tabby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matte Noble
|
@@ -10,20 +10,52 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-05-12 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
16
|
+
name: thor
|
18
17
|
prerelease: false
|
19
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.14.6
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
20
30
|
none: false
|
21
31
|
requirements:
|
22
32
|
- - ~>
|
23
33
|
- !ruby/object:Gem::Version
|
24
34
|
version: 2.1.0
|
25
35
|
type: :development
|
26
|
-
version_requirements: *
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: fakeout
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.0.1
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mnoble-fakefs
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.3.1
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id004
|
27
59
|
description: Simple iTerm2 project environment setup.
|
28
60
|
email:
|
29
61
|
- me@mattenoble.com
|
@@ -44,19 +76,26 @@ files:
|
|
44
76
|
- Rakefile
|
45
77
|
- bin/tabby
|
46
78
|
- lib/tabby.rb
|
79
|
+
- lib/tabby/base.rb
|
80
|
+
- lib/tabby/cli.rb
|
81
|
+
- lib/tabby/creator.rb
|
82
|
+
- lib/tabby/editor.rb
|
47
83
|
- lib/tabby/runner.rb
|
48
|
-
- lib/tabby/version.rb
|
49
84
|
- screenshot.png
|
50
85
|
- script/tabby.osa.erb
|
86
|
+
- spec/.tabby/mismatch.rb
|
51
87
|
- spec/.tabby/spec_blog.rb
|
52
|
-
- spec/runner_spec.rb
|
53
88
|
- spec/spec_helper.rb
|
54
89
|
- spec/support/expand.rb
|
90
|
+
- spec/support/stub_constant.rb
|
55
91
|
- spec/support/with_constants.rb
|
56
|
-
- spec/
|
57
|
-
- spec/
|
92
|
+
- spec/tabby/base_spec.rb
|
93
|
+
- spec/tabby/cli_spec.rb
|
94
|
+
- spec/tabby/creator_spec.rb
|
95
|
+
- spec/tabby/editor_spec.rb
|
96
|
+
- spec/tabby/runner_spec.rb
|
58
97
|
- tabby.gemspec
|
59
|
-
|
98
|
+
- templates/project.rb.erb
|
60
99
|
homepage: http://github.com/mnoble/tabby
|
61
100
|
licenses: []
|
62
101
|
|
@@ -80,14 +119,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
119
|
requirements: []
|
81
120
|
|
82
121
|
rubyforge_project:
|
83
|
-
rubygems_version: 1.
|
122
|
+
rubygems_version: 1.7.2
|
84
123
|
signing_key:
|
85
124
|
specification_version: 3
|
86
125
|
summary: Simple iTerm2 project environment setup.
|
87
126
|
test_files:
|
88
|
-
- spec/runner_spec.rb
|
89
127
|
- spec/spec_helper.rb
|
90
128
|
- spec/support/expand.rb
|
129
|
+
- spec/support/stub_constant.rb
|
91
130
|
- spec/support/with_constants.rb
|
92
|
-
- spec/
|
93
|
-
- spec/
|
131
|
+
- spec/tabby/base_spec.rb
|
132
|
+
- spec/tabby/cli_spec.rb
|
133
|
+
- spec/tabby/creator_spec.rb
|
134
|
+
- spec/tabby/editor_spec.rb
|
135
|
+
- spec/tabby/runner_spec.rb
|
data/lib/tabby/version.rb
DELETED
data/spec/runner_spec.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.expand_path("../spec_helper", __FILE__)
|
2
|
-
require File.expand_path("../.tabby/spec_blog", __FILE__)
|
3
|
-
|
4
|
-
describe Tabby::Runner do
|
5
|
-
subject { Tabby::Runner.new(["blog"]) }
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
Kernel.stub(:system)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should tell the user when the project file is missing" do
|
12
|
-
with_stubbed_stdout do |output|
|
13
|
-
subject.should_receive(:require).and_raise(LoadError)
|
14
|
-
subject.start
|
15
|
-
output.should include "does not exist"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should tell the user when the filename and classname don't match" do
|
20
|
-
with_stubbed_stdout do |output|
|
21
|
-
ObjectSpace.class.should_receive(:const_get).and_raise(NameError)
|
22
|
-
subject.start
|
23
|
-
output.should include "mismatch"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should call the Tabby class" do
|
28
|
-
Tabby::Runner.with_constants :TABBYDIR => expand("../.tabby", __FILE__) do
|
29
|
-
blog = SpecBlog.new
|
30
|
-
blog.should_receive(:call)
|
31
|
-
SpecBlog.stub(:new) { blog }
|
32
|
-
runner = Tabby::Runner.new(["spec_blog"])
|
33
|
-
runner.start
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|