Sha256: eee9e2c871a5b2c31feb99afe5525335ae76fbcab9a7a6c814f4d0ddade5cd8b

Contents?: true

Size: 875 Bytes

Versions: 4

Compression:

Stored size: 875 Bytes

Contents

# frozen_string_literal: true

require 'git'

module A0
  module TZMigration
    class DataGenerator
      def repo
        return @repo if defined? @repo

        File.exist?(@path) ? repo_update : repo_clone
      end

      def repo_update
        puts "Updating #{@url} repo at #{@path}"

        @repo = Git.open @path
        @repo.pull

        @repo
      end

      def repo_clone
        puts "Cloning #{@url} repo at #{@path}"

        @repo = Git.clone @url, @path
      end

      def repo_use(tag)
        tag_path = File.join(@out, 'repo', tag)
        lib_path = File.join(tag_path, 'lib')
        $LOAD_PATH.unshift File.expand_path(lib_path)

        return if File.exist? lib_path

        FileUtils.rm_rf tag_path
        FileUtils.copy_entry @path, tag_path

        tag_repo = Git.open tag_path
        tag_repo.checkout tag
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
a0-tzmigration-ruby-1.0.2 lib/a0/tzmigration/data_generator/git.rb
a0-tzmigration-ruby-1.0.1 lib/a0/tzmigration/data_generator/git.rb
a0-tzmigration-ruby-1.0.0 lib/a0/tzmigration/data_generator/git.rb
a0-tzmigration-ruby-0.1.1 lib/a0/tzmigration/data_generator/git.rb