null+****@clear*****
null+****@clear*****
Fri Jun 22 20:18:04 JST 2012
SUZUKI Miho 2012-06-22 20:18:04 +0900 (Fri, 22 Jun 2012) New Revision: 78d5f29be528d8ba967b6606fa688fad6bbdb308 https://github.com/logaling/logaling-command/commit/78d5f29be528d8ba967b6606fa688fad6bbdb308 Log: Move Application#find_dorfile to Project.find_dotfile Modified files: lib/logaling/command/application.rb lib/logaling/project.rb Modified: lib/logaling/command/application.rb (+4 -21) =================================================================== --- lib/logaling/command/application.rb 2012-06-22 19:18:59 +0900 (680aacb) +++ lib/logaling/command/application.rb 2012-06-22 20:18:04 +0900 (54bba26) @@ -19,6 +19,7 @@ require 'thor' require 'rainbow' require 'pathname' require "logaling/repository" +require "logaling/project" require "logaling/glossary" require "logaling/glossary_source" require "logaling/config" @@ -34,10 +35,10 @@ module Logaling::Command @repository = Logaling::Repository.new(@logaling_home) @config = Logaling::Config.load(@repository.config_path) - @dotfile_path = options["logaling-config"] ? options["logaling-config"] : find_dotfile + @dotfile_path = options["logaling-config"] ? options["logaling-config"] : Logaling::Project.find_dotfile @project_config_path = File.join(@dotfile_path, 'config') @config.load(@project_config_path) - rescue Logaling::CommandFailed # can't find .logaling + rescue Logaling::ProjectNotFound => e @project_config_path = nil ensure @config.merge!(options) @@ -72,7 +73,7 @@ module Logaling::Command config.save(File.join(logaling_config_path, "config")) unless options["no-register"] - @dotfile_path = options["logaling-config"] ? options["logaling-config"] : find_dotfile + @dotfile_path = options["logaling-config"] ? options["logaling-config"] : Logaling::Project.find_dotfile @project_config_path = File.join(@dotfile_path, 'config') @config.load(@project_config_path) register_and_index @@ -327,24 +328,6 @@ module Logaling::Command exit 1 end - def find_dotfile - dir = Dir.pwd - searched_path = [] - loop do - path = File.join(dir, '.logaling') - if File.exist?(path) - return path - else - unless Pathname.new(dir).root? - searched_path << dir - dir = File.dirname(dir) - else - raise(Logaling::CommandFailed, "Can't found .logaling in #{searched_path}") - end - end - end - end - def logaling_config_path if options["logaling-config"] options["logaling-config"] Modified: lib/logaling/project.rb (+18 -0) =================================================================== --- lib/logaling/project.rb 2012-06-22 19:18:59 +0900 (3670bbe) +++ lib/logaling/project.rb 2012-06-22 20:18:04 +0900 (8444d15) @@ -15,6 +15,24 @@ module Logaling class Project + class << self + def find_dotfile(dir=Dir.pwd) + searched_path = [] + loop do + path = File.join(dir, '.logaling') + if File.exist?(path) + return path + else + unless Pathname.new(dir).root? + searched_path << dir + dir = File.dirname(dir) + else + raise Logaling::ProjectNotFound, "Can't found .logaling in #{searched_path}" + end + end + end + end + end attr_reader :path, :repository def initialize(path, repository=nil) -------------- next part -------------- An HTML attachment was scrubbed... ダウンロード