Sha256: d9ba344fc6e482d2f86c15d79d52489dccb459ad8259b61996c6368538c5f744

Contents?: true

Size: 1.46 KB

Versions: 10

Compression:

Stored size: 1.46 KB

Contents

require 'rubygems/gem_runner'
require 'berkeley_library/tind/module_info'

gem_root_module = BerkeleyLibrary::TIND

class << gem_root_module
  def project_root
    @project_root ||= File.expand_path('..', __dir__)
  end

  def artifacts_dir
    return project_root unless ENV['CI']

    @artifacts_dir ||= File.join(project_root, 'artifacts')
  end

  def gemspec_file
    @gemspec_file ||= begin
      gemspec_files = Dir.glob(File.expand_path('*.gemspec', project_root))
      raise ArgumentError, "Too many .gemspecs: #{gemspec_files.join(', ')}" if gemspec_files.size > 1
      raise ArgumentError, 'No .gemspec file found' if gemspec_files.empty?

      gemspec_files[0]
    end
  end

  def gemspec_basename
    File.basename(gemspec_file)
  end

  def output_file
    @output_file ||= begin
      gem_name = File.basename(gemspec_file, '.*')
      version = self::ModuleInfo::VERSION
      basename = "#{gem_name}-#{version}.gem"
      File.join(artifacts_dir, basename)
    end
  end

  def output_file_relative
    return File.basename(output_file) unless ENV['CI']

    @output_file_relative ||= begin
      artifacts_dir_relative = File.basename(artifacts_dir)
      File.join(artifacts_dir_relative, File.basename(output_file))
    end
  end
end

desc "Build #{gem_root_module.gemspec_basename} as #{gem_root_module.output_file_relative}"
task :gem do
  args = ['build', gem_root_module.gemspec_file, "--output=#{gem_root_module.output_file}"]
  Gem::GemRunner.new.run(args)
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
berkeley_library-tind-0.7.2 rakelib/gem.rake
berkeley_library-tind-0.7.1 rakelib/gem.rake
berkeley_library-tind-0.7.0 rakelib/gem.rake
berkeley_library-tind-0.6.0 rakelib/gem.rake
berkeley_library-tind-0.5.1 rakelib/gem.rake
berkeley_library-tind-0.5.0 rakelib/gem.rake
berkeley_library-tind-0.4.3 rakelib/gem.rake
berkeley_library-tind-0.4.2 rakelib/gem.rake
berkeley_library-tind-0.4.1 rakelib/gem.rake
berkeley_library-tind-0.4.0 rakelib/gem.rake