Class: Corundum::Core

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

Overview

This is the core tasklib for Corundum. It defines a series of lifecycle steps that define the release process. The real work is done by other Tasklibs that hook into the lifecycle.

The lifecycle steps (as implied by the Rakefile definition) are:

preflight

simple tests before we do anything at all

qa

quality assurance - make sure everything is acceptable before we build the gem

build

construct the actual gem

release

push the gem out to the world

press

send out notifications that the gem has been published

Instance Method Summary collapse

Instance Method Details

#defineObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/corundum/core.rb', line 91

def define
  in_namespace do
    directory finished_dir

    desc "Run preflight checks"
    task :preflight

    task :run_quality_assurance => [:preflight, finished_files.qa]

    task :run_continuous_integration

    desc "Run quality assurance tasks"
    task :qa => :run_quality_assurance do
      require 'corundum/qa-report'
      puts QA::ReportFormatter.new(qa_rejections).to_s
      unless qa_rejections.all?(&:passed)
        fail "There are QA tests that failed"
      end
    end

    desc "Run limited set of QA tasks appropriate for CI"
    task :ci => :run_continuous_integration do
      require 'corundum/qa-report'
      puts QA::ReportFormatter.new(qa_rejections).to_s
      if qa_rejections.all?(&:passed)
        puts "Passed"
      else
        fail "There are Continuous Integration tests that failed"
      end
    end


    file finished_files.qa =>
    [finished_dir] + file_lists.project + file_lists.code + file_lists.test do |task|
      Rake::Task[:qa].invoke
      touch task.name
    end

    desc "Build the package"
    task :build => [finished_files.qa, :preflight, finished_files.build]
    file finished_files.build =>
    [finished_dir] + file_lists.code + file_lists.project do |task|
      Rake::Task[:build].invoke
      touch task.name
    end

    desc "Push package out to the world"
    task :release => [finished_files.build, :preflight, finished_files.release]
    file finished_files.release => [finished_dir] do |task|
      Rake::Task[:release].invoke
      touch task.name
    end

    desc "Announce publication"
    task :press => [finished_files.release, finished_files.press]
    file finished_files.press => [finished_dir] do |task|
      Rake::Task[:press].invoke
      touch task.name
    end
  end
end

#guess_gemspecObject



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/corundum/core.rb', line 79

def guess_gemspec
  speclist = Dir[File.expand_path("*.gemspec", Rake::original_dir)]
  if speclist.length == 0
    puts "Found no *.gemspec files"
    exit 1
  elsif speclist.length > 1
    puts "Found too many *.gemspec files: #{speclist.inspect}"
    exit 1
  end
  speclist[0]
end

#load_gemspecObject



43
44
45
46
47
# File 'lib/corundum/core.rb', line 43

def load_gemspec
  @gemspec_path ||= guess_gemspec
  @gemspec ||= Gem::Specification::load(gemspec_path)
  return gemspec
end

#resolve_configurationObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/corundum/core.rb', line 49

def resolve_configuration
  super
  load_gemspec

  self.finished_dir ||= File::join(corundum_dir, "finished")
  @finished_files.build ||= File::join( package_dir, "#{gemspec.full_name}.gem")

  @finished_files.qa ||= File::join( finished_dir, "qa_#{gemspec.version}")
  @finished_files.release ||= File::join( finished_dir, "release_#{gemspec.version}")
  @finished_files.press ||= File::join( finished_dir, "press_#{gemspec.version}")

  @qa_rejections ||= []

  @files.code ||= file_patterns.code.map{ |pattern| gemspec.files.grep(pattern) }.flatten
  @files.test ||= file_patterns.test.map{ |pattern| gemspec.files.grep(pattern) }.flatten
  @files.docs ||= file_patterns.docs.map{ |pattern| gemspec.files.grep(pattern) }.flatten

  @file_lists.project << gemspec_path
  @file_lists.all  ||=
    file_lists.code +
    file_lists.test +
    file_lists.docs

  @rubyforge.group_id ||= gemspec.rubyforge_project
  @rubyforge.package_id ||= gemspec.name.downcase
  @rubyforge.release_name ||= gemspec.full_name
  @rubyforge.home_page ||= gemspec.homepage
  @rubyforge.project_page ||= "http://rubyforge.org/project/#{gemspec.rubyforge_project}/"
end