set default castle name: 'dotfiles' for some commands

This commit is contained in:
akahige
2013-06-21 14:02:50 +09:00
committed by thilko
parent 8f2a9e6703
commit 8ee5165ccf
2 changed files with 31 additions and 5 deletions

View File

@@ -68,7 +68,7 @@ class Homesick < Thor
desc 'pull CASTLE', 'Update the specified castle' desc 'pull CASTLE', 'Update the specified castle'
method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles' method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles'
def pull(name = '') def pull(name = 'dotfiles')
if options[:all] if options[:all]
inside_each_castle do |castle| inside_each_castle do |castle|
shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':' shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':'
@@ -81,20 +81,20 @@ class Homesick < Thor
end end
desc 'commit CASTLE', "Commit the specified castle's changes" desc 'commit CASTLE', "Commit the specified castle's changes"
def commit(name) def commit(name = 'dotfiles')
commit_castle name commit_castle name
end end
desc 'push CASTLE', 'Push the specified castle' desc 'push CASTLE', 'Push the specified castle'
def push(name) def push(name = 'dotfiles')
push_castle name push_castle name
end end
desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle' desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle'
method_option :force, :default => false, :desc => 'Overwrite existing conflicting symlinks without prompting.' method_option :force, :default => false, :desc => 'Overwrite existing conflicting symlinks without prompting.'
def symlink(name) def symlink(name = 'dotfiles')
check_castle_existance(name, 'symlink') check_castle_existance(name, 'symlink')
inside castle_dir(name) do inside castle_dir(name) do
@@ -111,7 +111,7 @@ class Homesick < Thor
end end
desc 'track FILE CASTLE', 'add a file to a castle' desc 'track FILE CASTLE', 'add a file to a castle'
def track(file, castle) def track(file, castle = 'dotfiles')
castle = Pathname.new(castle) castle = Pathname.new(castle)
file = Pathname.new(file.chomp('/')) file = Pathname.new(file.chomp('/'))
check_castle_existance(castle, 'track') check_castle_existance(castle, 'track')

View File

@@ -176,6 +176,17 @@ describe 'homesick' do
home_someapp_dir.join('.some_appfile').readlink.should == someapp_dotfile home_someapp_dir.join('.some_appfile').readlink.should == someapp_dotfile
end end
end end
context "when call with no castle name" do
let(:castle) { given_castle('dotfiles') }
it 'using default castle name: "dotfiles"' do
dotfile = castle.file('.some_dotfile')
homesick.symlink
home.join('.some_dotfile').readlink.should == dotfile
end
end
end end
describe 'list' do describe 'list' do
@@ -248,6 +259,21 @@ describe 'homesick' do
some_nested_dir.realpath.should == tracked_file.realpath some_nested_dir.realpath.should == tracked_file.realpath
end end
context "when call with no castle name" do
it 'using default castle name: "dotfiles"' do
castle = given_castle('dotfiles')
some_rc_file = home.file '.some_rc_file'
homesick.track(some_rc_file.to_s)
tracked_file = castle.join('.some_rc_file')
tracked_file.should exist
some_rc_file.readlink.should == tracked_file
end
end
describe 'subdir_file' do describe 'subdir_file' do
it 'should add the nested files parent to the subdir_file' do it 'should add the nested files parent to the subdir_file' do