Merge pull request #42 from akahigeg/default-castle-name
set default castle name: 'dotfiles' for some commands
This commit is contained in:
@@ -12,6 +12,8 @@ class Homesick < Thor
|
|||||||
GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/
|
GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/
|
||||||
SUBDIR_FILENAME = '.homesick_subdir'
|
SUBDIR_FILENAME = '.homesick_subdir'
|
||||||
|
|
||||||
|
DEFAULT_CASTLE_NAME = 'dotfiles'
|
||||||
|
|
||||||
def initialize(args = [], options = {}, config = {})
|
def initialize(args = [], options = {}, config = {})
|
||||||
super
|
super
|
||||||
self.shell = Homesick::Shell.new
|
self.shell = Homesick::Shell.new
|
||||||
@@ -67,7 +69,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 = DEFAULT_CASTLE_NAME)
|
||||||
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 + '/', '') + ':'
|
||||||
@@ -80,20 +82,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 = DEFAULT_CASTLE_NAME)
|
||||||
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 = DEFAULT_CASTLE_NAME)
|
||||||
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 = DEFAULT_CASTLE_NAME)
|
||||||
check_castle_existance(name, 'symlink')
|
check_castle_existance(name, 'symlink')
|
||||||
|
|
||||||
inside castle_dir(name) do
|
inside castle_dir(name) do
|
||||||
@@ -110,7 +112,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 = DEFAULT_CASTLE_NAME)
|
||||||
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')
|
||||||
|
|||||||
@@ -175,6 +175,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
|
||||||
@@ -247,6 +258,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
|
||||||
|
|||||||
Reference in New Issue
Block a user