From d3cb45f879b7368edbf141c39a1342fa8df5601c Mon Sep 17 00:00:00 2001 From: akahige Date: Mon, 24 Jun 2013 00:44:17 +0900 Subject: [PATCH] default castle name to constant --- lib/homesick.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/homesick.rb b/lib/homesick.rb index 1edcc45..a6480a6 100644 --- a/lib/homesick.rb +++ b/lib/homesick.rb @@ -13,6 +13,8 @@ class Homesick < Thor GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+\/[A-Za-z_-]+)\Z/ SUBDIR_FILENAME = '.homesick_subdir' + DEFAULT_CASTLE_NAME = 'dotfiles' + def initialize(args = [], options = {}, config = {}) super self.shell = Homesick::Shell.new @@ -68,7 +70,7 @@ class Homesick < Thor desc 'pull CASTLE', 'Update the specified castle' method_option :all, :type => :boolean, :default => false, :required => false, :desc => 'Update all cloned castles' - def pull(name = 'dotfiles') + def pull(name = DEFAULT_CASTLE_NAME) if options[:all] inside_each_castle do |castle| shell.say castle.to_s.gsub(repos_dir.to_s + '/', '') + ':' @@ -81,20 +83,20 @@ class Homesick < Thor end desc 'commit CASTLE', "Commit the specified castle's changes" - def commit(name = 'dotfiles') + def commit(name = DEFAULT_CASTLE_NAME) commit_castle name end desc 'push CASTLE', 'Push the specified castle' - def push(name = 'dotfiles') + def push(name = DEFAULT_CASTLE_NAME) push_castle name end desc 'symlink CASTLE', 'Symlinks all dotfiles from the specified castle' method_option :force, :default => false, :desc => 'Overwrite existing conflicting symlinks without prompting.' - def symlink(name = 'dotfiles') + def symlink(name = DEFAULT_CASTLE_NAME) check_castle_existance(name, 'symlink') inside castle_dir(name) do @@ -111,7 +113,7 @@ class Homesick < Thor end desc 'track FILE CASTLE', 'add a file to a castle' - def track(file, castle = 'dotfiles') + def track(file, castle = DEFAULT_CASTLE_NAME) castle = Pathname.new(castle) file = Pathname.new(file.chomp('/')) check_castle_existance(castle, 'track')