Module: Ore::RubyGems

Includes:
Paths
Included in:
Project
Defined in:
lib/ore/rubygems.rb

Instance Method Summary collapse

Methods included from Paths

#bin_dir, #directory?, #each_path, #file?, #glob, #lib_dir, #lib_directory?, #lib_file?, #lib_path, #path, #pkg_dir, #pkg_file

Methods included from Naming

#module_of, #modules_of, #names_in, #namespace_dirs_of, #namespace_of, #namespace_path_of, #underscore

Instance Method Details

#to_gemPathname

Builds a gem for the project.

Returns:

  • (Pathname)

    The path to the built gem file within the pkg/ directory.

Since:

  • 0.1.5



121
122
123
124
125
126
127
128
129
130
# File 'lib/ore/rubygems.rb', line 121

def to_gem
  pkg_dir = @root.join(@@pkg_dir)
  FileUtils.mkdir_p(pkg_dir)

  gem_file = Gem::Builder.new(self.to_gemspec).build
  pkg_path = @root.join(pkg_file)

  FileUtils.mv(gem_file,pkg_path)
  return pkg_path
end

#to_gemspec {|gemspec| ... } ⇒ Gem::Specification

Populates a Gem Specification using the metadata of the project.

Yields:

  • (gemspec)

    The given block will be passed the populated Gem Specification object.

Yield Parameters:

  • gemspec (Gem::Specification)

    The newly created Gem Specification.

Returns:

  • (Gem::Specification)

    The Gem Specification.

See Also:

Since:

  • 0.1.5



26
27
28
29
30
31
32
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/ore/rubygems.rb', line 26

def to_gemspec
  Gem::Specification.new do |gemspec|
    gemspec.name = @name.to_s
    gemspec.version = @version.to_s
    gemspec.summary = @summary.to_s
    gemspec.description = @description.to_s
    gemspec.licenses = @licenses
    gemspec.authors = @authors
    gemspec.homepage = @homepage
    gemspec.email = @emails
    gemspec.date = @date

    @require_paths.each do |path|
      unless gemspec.require_paths.include?(path)
        gemspec.require_paths << path
      end
    end

    gemspec.executables = @executables

    # default_executable is deprecated in RubyGems 1.7.0 and will be
    # removed after 2011-10-01.
    if Gem::VERSION < '1.7.'
      gemspec.default_executable = @default_executable
    end

    # forcibly set the @has_rdoc ivar, as RubyGems 1.5.x disables the
    # #has_rdoc= writer method.
    if gemspec.instance_variable_defined?('@has_rdoc')
      case @documentation
      when :yard
        gemspec.instance_variable_set('@has_rdoc','yard')
      when :rdoc
        gemspec.instance_variable_set('@has_rdoc',true)
      when nil
        gemspec.instance_variable_set('@has_rdoc',false)
      end
    end

    gemspec.extra_rdoc_files = @extra_doc_files
    gemspec.files = @files
    gemspec.test_files = @test_files
    gemspec.post_install_message = @post_install_message

    gemspec.requirements = @requirements

    if gemspec.respond_to?(:required_ruby_version=)
      gemspec.required_ruby_version = @required_ruby_version
    end

    if gemspec.respond_to?(:required_rubygems_version=)
      gemspec.required_rubygems_version = @required_rubygems_version
    end

    @dependencies.each do |dep|
      gemspec.add_dependency(dep.name,*dep.versions)
    end

    if gemspec.respond_to?(:add_runtime_dependency)
      @runtime_dependencies.each do |dep|
        gemspec.add_runtime_dependency(dep.name,*dep.versions)
      end
    else
      @runtime_dependencies.each do |dep|
        gemspec.add_dependency(dep.name,*dep.versions)
      end
    end

    if gemspec.respond_to?(:add_development_dependency)
      @development_dependencies.each do |dep|
        gemspec.add_development_dependency(dep.name,*dep.versions)
      end
    else
      @development_dependencies.each do |dep|
        gemspec.add_dependency(dep.name,*dep.versions)
      end
    end

    # legacy information
    if gemspec.respond_to?(:rubyforge_project=)
      gemspec.rubyforge_project = gemspec.name
    end

    yield gemspec if block_given?
  end
end