Class: Corundum::GemspecFiles

Inherits:
Mattock::TaskLib
  • Object
show all
Defined in:
lib/corundum/gemspec_files.rb

Instance Method Summary collapse

Instance Method Details

#default_configuration(toolkit) ⇒ Object



10
11
12
13
# File 'lib/corundum/gemspec_files.rb', line 10

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

#defineObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/corundum/gemspec_files.rb', line 15

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