Sha256: 6887ad3ee43b2d9c7bffc2835828f1387c946557424edfb722b4c67c3a50c8e9

Contents?: true

Size: 923 Bytes

Versions: 3

Compression:

Stored size: 923 Bytes

Contents

module Fullstop
  class Repo

    include Methadone::CLILogging
    include Methadone::SH
    include Methadone::ExitNow

    def self.clone_from(repo_url,force=false)
      repo_dir = repo_url.split(/\//)[-1].gsub(/\.git$/,'')
      # vvv
      debug "Cloning #{repo_url} into #{repo_dir}"
      # ^^^
      if force && Dir.exists?(repo_dir)
        warn "deleting #{repo_dir} before cloning"
        FileUtils.rm_rf repo_dir
      end
      unless sh("git clone #{repo_url}") == 0
        exit_now!(1,"checkout dir already exists, use --force to overwrite")
      end
      Repo.new(repo_dir)
    end

    attr_reader :repo_dir
    def initialize(repo_dir)
      @repo_dir = repo_dir
    end

    def files
      Dir.entries(@repo_dir).each do |file|
        next if file == '.' || file == '..' || file == '.git'
        # vvv
        debug "Yielding #{file}"
        # ^^^
        yield file
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
methadone-1.0.0.rc5 tutorial/code/fullstop/lib/fullstop/repo.rb
methadone-1.0.0.rc4 tutorial/code/fullstop/lib/fullstop/repo.rb
methadone-1.0.0.rc3 tutorial/code/fullstop/lib/fullstop/repo.rb