Sha256: 1d4b46754fb8b81e793a881cba1fdd741ef518089cbcd00e296a11d4748c8843

Contents?: true

Size: 1.17 KB

Versions: 21

Compression:

Stored size: 1.17 KB

Contents

module RBS
  class Vendorer
    attr_reader :vendor_dir

    def initialize(vendor_dir:)
      @vendor_dir = vendor_dir
    end

    def ensure_dir
      unless vendor_dir.directory?
        vendor_dir.mkpath
      end

      yield
    end

    def clean!
      ensure_dir do
        RBS.logger.info "Cleaning vendor root: #{vendor_dir}..."
        vendor_dir.rmtree
      end
    end

    def stdlib!()
      ensure_dir do
        RBS.logger.info "Vendoring stdlib: #{EnvironmentLoader::STDLIB_ROOT} => #{vendor_dir + "stdlib"}..."
        FileUtils.copy_entry EnvironmentLoader::STDLIB_ROOT, vendor_dir + "stdlib"
      end
    end

    def gem!(name, version)
      ensure_dir do
        sig_path = EnvironmentLoader.gem_sig_path(name, version)
        RBS.logger.debug "Checking gem signature path: name=#{name}, version=#{version}, path=#{sig_path}"

        if sig_path&.directory?
          gems_dir = vendor_dir + "gems"
          gems_dir.mkpath unless gems_dir.directory?

          gem_dir = gems_dir + name
          RBS.logger.info "Vendoring gem(#{name}:#{version}): #{sig_path} => #{gem_dir}..."
          FileUtils.copy_entry sig_path, gem_dir
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
rbs-0.15.0 lib/rbs/vendorer.rb
rbs-0.14.0 lib/rbs/vendorer.rb
rbs-0.13.1 lib/rbs/vendorer.rb
rbs-0.13.0 lib/rbs/vendorer.rb
rbs-0.12.2 lib/rbs/vendorer.rb
rbs-0.12.1 lib/rbs/vendorer.rb
rbs-0.12.0 lib/rbs/vendorer.rb
rbs-0.11.0 lib/rbs/vendorer.rb
rbs-0.10.0 lib/rbs/vendorer.rb
rbs-0.9.1 lib/rbs/vendorer.rb
rbs-0.9.0 lib/rbs/vendorer.rb
rbs-0.8.0 lib/rbs/vendorer.rb
rbs-0.7.0 lib/rbs/vendorer.rb
rbs-0.6.0 lib/rbs/vendorer.rb
rbs-0.5.0 lib/rbs/vendorer.rb
rbs-0.4.0 lib/rbs/vendorer.rb
rbs-0.3.1 lib/rbs/vendorer.rb
rbs-0.3.0 lib/rbs/vendorer.rb
rbs-0.2.0 lib/rbs/vendorer.rb
steep-0.16.0 vendor/ruby-signature/lib/rbs/vendorer.rb