Sha256: 3889b18f0ad6e5b71bf95282bc87fbb39214e51d1cb943fd034d1bb3664c9c17

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 KB

Contents

require 'mattock/tasklib'

module Corundum
  class GemspecFiles < Mattock::TaskLib
    default_namespace :gemspec_files

    setting(:gemspec)
    setting(:extra_files, Rake::FileList[])

    def default_configuration(toolkit)
      super
      self.gemspec = toolkit.gemspec
    end

    def define
      in_namespace do
        task :has_files do
          if gemspec.files.nil? or gemspec.files.empty?
            fail "No files mentioned in gemspec - do you intend an empty gem?"
          end
        end

        task :has_extras => :has_files do
          missing_files = extra_files.to_a.find_all{|path| File.file?(path)} - gemspec.files
          unless missing_files.empty?
            fail "Untested extra files are not mentioned in gemspec: #{missing_files.inspect}"
          end
        end

        task :files_exist do
          missing = gemspec.files.find_all do |path|
            not File::exists?(path)
          end

          fail "Files mentioned in gemspec are missing: #{missing.join(", ")}" unless missing.empty?
        end
      end

      task :preflight => in_namespace(:files_exist, :has_extras, :has_files)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
corundum-0.6.3 lib/corundum/gemspec_files.rb
corundum-0.6.2 lib/corundum/gemspec_files.rb
corundum-0.6.1 lib/corundum/gemspec_files.rb
corundum-0.6.0 lib/corundum/gemspec_files.rb
corundum-0.5.0 lib/corundum/gemspec_files.rb
corundum-0.4.1 lib/corundum/gemspec_files.rb
corundum-0.4.0 lib/corundum/gemspec_files.rb
corundum-0.3.9 lib/corundum/gemspec_files.rb
corundum-0.3.8 lib/corundum/gemspec_files.rb
corundum-0.3.7 lib/corundum/gemspec_files.rb
corundum-0.3.6 lib/corundum/gemspec_files.rb
corundum-0.3.5 lib/corundum/gemspec_files.rb
corundum-0.3.4 lib/corundum/gemspec_files.rb
corundum-0.3.3 lib/corundum/gemspec_files.rb
corundum-0.3.2 lib/corundum/gemspec_files.rb