Class: Corundum::GemCutter

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

Defined Under Namespace

Modules: CommandTweaks

Instance Method Summary collapse

Instance Method Details

#default_configuration(toolkit, build) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/corundum/gemcutter.rb', line 14

def default_configuration(toolkit, build)
  self.build = build
  self.gemspec = toolkit.gemspec
  self.build_finished_path = toolkit.finished_files.build
  self.gem_name = toolkit.gemspec.full_name
  self.package_dir = build.package_dir
end

#defineObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/corundum/gemcutter.rb', line 54

def define
  in_namespace do
    task :uninstall do |t|
      when_writing("Uninstalling #{gem_name}") do
        require "rubygems/commands/uninstall_command"
        uninstall = get_command Gem::Commands::UninstallCommand
        uninstall.options[:args] = [gem_path]
        uninstall.execute
      end
    end

    task :install => [gem_path] do |t|
      when_writing("Installing #{gem_path}") do
        require "rubygems/commands/install_command"
        install = get_command Gem::Commands::InstallCommand
        install.options[:args] = [gem_path]
        install.execute
      end
    end

    task :reinstall => [:uninstall, :install]

    task :dependencies_available do
      checker = Gem::SpecFetcher.new
      gemspec.runtime_dependencies.each do |dep|
        fulfilling = checker.find_matching(dep,false,false,false)
        if fulfilling.empty?
          fail "Dependency #{dep} is unfulfilled remotely"
        else
          puts "Remotely fulfilled: #{dep}" if verbose
        end
      end
    end

    task :is_unpushed do
      checker = Gem::SpecFetcher.new
      dep = Gem::Dependency.new(gemspec.name, "= #{gemspec.version}")
      fulfilling = checker.find_matching(dep,false,false,false)
      unless fulfilling.empty?
        p fulfilling
        fail "Gem #{gemspec.full_name} is already pushed"
      end
    end

    desc 'Push a gem up to Gemcutter'
    task :push => [:dependencies_available, :is_unpushed] do
      require "rubygems/commands/push_command"
      push = get_command(Gem::Commands::PushCommand)
      push.options[:args] = [gem_path]
      push.execute
    end
    task :push => build_finished_path
  end
  task :release => in_namespace(:push)
  task :preflight => in_namespace(:dependencies_available, :is_unpushed)
end

#get_command(klass, args = nil) ⇒ Object



47
48
49
50
51
52
# File 'lib/corundum/gemcutter.rb', line 47

def get_command(klass, args=nil)
  cmd = klass.new
  cmd.extend(CommandTweaks)
  cmd.setup_args(args)
  cmd
end

#resolve_configurationObject



22
23
24
# File 'lib/corundum/gemcutter.rb', line 22

def resolve_configuration
  self.gem_path ||= File::join(package_dir, gemspec.file_name)
end