lib/git_local/repository.rb in git_local-0.0.4 vs lib/git_local/repository.rb in git_local-0.0.5

- old
+ new

@@ -1,9 +1,8 @@ module GitLocal class Repository class NotFound < StandardError - end class InvalidArgument < StandardError end @@ -52,14 +51,14 @@ popened_io = IO.popen("(cd #{path} && git rev-parse HEAD)") head = popened_io.read.chomp.split("\n").last Process.wait(popened_io.pid) popened_io = IO.popen("(cd #{path} && git remote update && git rev-parse origin/#{branch}) 2>&1") - out = popened_io.map { |line| line.chomp } || [] + out = popened_io.map(&:chomp) || [] remote = popened_io.read.chomp Process.wait(popened_io.pid) - raise NotFound.new.exception(out.join(' ')) unless $?.to_i == 0 + raise NotFound.new.exception(out.join(" ")) unless $?.to_i == 0 remote != head end def path @@ -67,11 +66,11 @@ end def check_for_special_characters(*args) regexp = Regexp.new(/([A-Za-z0-9\-\_\/#]+)/) args.each do |arg| - raise InvalidArgument if arg.gsub(regexp, '').length > 0 + raise InvalidArgument unless arg.gsub(regexp, "").empty? end end private @@ -79,13 +78,13 @@ def clone_and_checkout FileUtils.makedirs(repo_path) unless Dir.exist?(repo_path) popened_io = IO.popen("(cd #{repo_path} && git clone git@github.com:#{org_repo}.git --branch #{branch} --single-branch #{branch} && cd #{path}) 2>&1") - out = popened_io.map { |line| line.chomp } || [] + out = popened_io.map(&:chomp) || [] Process.wait(popened_io.pid) - raise NotFound.new.exception(out.join(' ')) unless $?.to_i == 0 + raise NotFound.new.exception(out.join(" ")) unless $?.to_i == 0 end def org_repo @org_repo ||= "#{org}/#{repo}" end