Class: DevBall::PkgSpec::Gem

Inherits:
Base
  • Object
show all
Defined in:
lib/devball/pkgspec/gem.rb

Instance Method Summary collapse

Methods inherited from Base

#ball, #ball_file_name, #ball_name, #ball_version, #build_concurrent?, #build_dir_name, #build_targets, #configure_script_name, #depends_on, depends_on, find, #install_links, #install_service_links, #install_targets, #link_mappings, load_packages, #package_install_dir, #package_name, #recursive_depends_on, register_package, #remove_build, #remove_install, set_ball, set_lib_ball, set_patch, #step_environment_setup, #step_patch, #step_setup_links, #to_s

Instance Method Details

#configure_paramsObject



24
25
26
# File 'lib/devball/pkgspec/gem.rb', line 24

def configure_params()
  return {} # no need for prefix
end

#gem_repositoryObject

override to specify a different gem repository. Default returns nil and indicates to use the standard rubyforge repo.



29
30
31
# File 'lib/devball/pkgspec/gem.rb', line 29

def gem_repository()
  return nil
end

#step_buildObject



20
21
22
# File 'lib/devball/pkgspec/gem.rb', line 20

def step_build()
  # gems are all three steps in one at install time.
end

#step_configureObject



16
17
18
# File 'lib/devball/pkgspec/gem.rb', line 16

def step_configure()
  # gems are all three steps in one at install time.
end

#step_extractObject



12
13
14
# File 'lib/devball/pkgspec/gem.rb', line 12

def step_extract()
  # whether the gem is a local file or fetched from rubyforge, we don't extract it.
end

#step_installObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
78
79
80
81
82
83
84
85
86
# File 'lib/devball/pkgspec/gem.rb', line 33

def step_install()
  Dir.chdir($package_dir) {|dir|
    params = configure_params.collect {|key, val|
      if (val)
        "--#{key}=#{val}"
      else
        "--#{key}"
      end
    }

    if (params.length)
      params.unshift("--")
    end

    if (gem_repository)
      params.unshift(gem_repository)
      params.unshift("--source")
    end

    if (ENV['RUBINIUS'])
    #       params = ["rbx", "gem", "install", "--install-dir=/nexopia/packages/Rubinius/lib/rubinius/gems/1.8", ball, *params].collect {|i| %Q{"#{i}"} }
      params = ["rbx", "gem", "install", ball, *params].collect {|i| %Q{"#{i}"} }
    else
      params = ["gem", "install", ball, *params].collect {|i| %Q{"#{i}"} }
    end
    # and here this gets complicated, since gems don't return an error code if they fail. They just talk about it on their output.
    success = false
    errors = []
    open("|#{params.join(' ')} 2>&1", "r") {|io|
      io.each {|line|
        puts(line)
        if (match = /ERROR:\s+(.+)$/.match(line))
          errors.push(match[1])
        end
        if (match = /^[0-9]+ gems? installed/.match(line))
          success = true
        end
        if (match = /^Successfully installed/.match(line))
          success = true
        end
      }
    }
    if (!success)
      raise(InstallFailed, "Could not install gem: #{errors.join(', ')}")
    end
  }
  if (ENV['JRUBY'])
    return "JRuby"
  elsif (ENV['Rubinius'])
    return "Rubinius"
  else
    return "Ruby"
  end
end

#step_uninstallObject



88
89
90
91
92
93
94
95
# File 'lib/devball/pkgspec/gem.rb', line 88

def step_uninstall()
  if (ENV['RUBINIUS'])
    system("rbx", "gem", "uninstall", ball())
  else
    system("gem", "uninstall", ball())
  end
  super()
end