lib/gjp/project.rb in gjp-0.37.0 vs lib/gjp/project.rb in gjp-0.38.0

- old
+ new

@@ -3,16 +3,16 @@ require "find" module Gjp # encapsulates a Gjp project directory class Project - include Logger + include Logging attr_accessor :full_path attr_accessor :git - def initialize(path) + def initialize(path) @full_path = Gjp::Project.find_project_dir(File.expand_path(path)) @git = Gjp::Git.new(@full_path) end def name @@ -43,24 +43,21 @@ end # returns the package name corresponding to the specified dir, if any # raises NoPackageDirectoryError if dir is not a (sub)directory of a package def get_package_name(dir) - begin - dir_path = Pathname.new(File.expand_path(dir)).relative_path_from(Pathname.new(@full_path)) - components = dir_path.to_s.split(File::SEPARATOR) - - if components.count >= 2 && - components.first == "src" && - Dir.exist?(File.join(@full_path, components[0], components[1])) - components[1] - else - raise NoPackageDirectoryError - end - rescue ArgumentError, NoProjectDirectoryError - raise NoPackageDirectoryError.new(dir) - end + dir_path = Pathname.new(File.expand_path(dir)).relative_path_from(Pathname.new(@full_path)) + components = dir_path.to_s.split(File::SEPARATOR) + if components.count >= 2 && + components.first == "src" && + Dir.exist?(File.join(@full_path, components[0], components[1])) + components[1] + else + raise NoPackageDirectoryError + end + rescue ArgumentError, NoProjectDirectoryError + raise NoPackageDirectoryError.new(dir) end # inits a new project directory structure def self.init(dir) Dir.chdir(dir) do @@ -121,15 +118,17 @@ false end # takes a revertable snapshot of this project def take_snapshot(message, tag_prefix = nil, tag_message = nil) - tag = if tag_prefix - "#{tag_prefix}_#{latest_tag_count(tag_prefix) + 1}" - else - nil - end + tag = ( + if tag_prefix + "#{tag_prefix}_#{latest_tag_count(tag_prefix) + 1}" + else + nil + end + ) @git.commit_whole_directory(message, tag, tag_message) end # replaces content in path with new_content, takes a snapshot using @@ -206,10 +205,10 @@ [] end end # moves any .jar from src/ to kit/ and links it back - def purge_jars + def purge_jars from_directory do result = [] Find.find("src") do |file| if file =~ /.jar$/ && !File.symlink?(file) new_location = File.join("kit", "jars", Pathname.new(file).split[1])