Class: SGem

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/sgem.rb,
lib/sgem/version.rb

Overview

SGem is a simple, minimalistic way to build and publish gems using ‘rake`.

SGem is based on the excellent [mg](github.com/sr/mg) (written by [Ryan Tomayko](tomayko.com), extracted by [Simon Rozet](atonie.org)).

Constant Summary collapse

VERSION =

The semantic version of SGem.

'1.0.0'

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ SGem

Returns a new instance of SGem.

Parameters:

  • spec (String)

    the gemspec for this instance of SGem



28
29
30
31
# File 'lib/sgem.rb', line 28

def initialize(spec)
  @spec = Gem::Specification.load(spec)
  define_tasks
end

Class Attribute Details

.archive_formatString

Note:

This format must be supported by ‘git-archive`.

Returns the default archive format for SGem to use unless otherwise specified.

Returns:

  • (String)

    the default archive format for SGem to use unless otherwise specified

See Also:



24
25
26
# File 'lib/sgem.rb', line 24

def archive_format
  @archive_format
end

.package_dirString

Returns the default relative directory where SGem will place generated gems and archives unless otherwise specified.

Returns:

  • (String)

    the default relative directory where SGem will place generated gems and archives unless otherwise specified

See Also:



18
19
20
# File 'lib/sgem.rb', line 18

def package_dir
  @package_dir
end

Instance Method Details

#archive_formatString

Note:

This format must be supported by ‘git-archive`.

Returns the archive format for SGem to use.

Returns:

  • (String)

    the archive format for SGem to use



54
55
56
# File 'lib/sgem.rb', line 54

def archive_format
  @format ||= ENV['ARCHIVE'] || self.class.archive_format || '.tar.gz'
end

#nameString

Returns the name of the gem for this instance of SGem.

Returns:

  • (String)

    the name of the gem for this instance of SGem



34
35
36
# File 'lib/sgem.rb', line 34

def name
  @name ||= @spec.name
end

#package_dirString

Returns the relative directory where SGem will place generated gems and archives.

Returns:

  • (String)

    the relative directory where SGem will place generated gems and archives



46
47
48
49
50
# File 'lib/sgem.rb', line 46

def package_dir
  return @dir if @dir
  dir  = ENV['DEST'] || self.class.package_dir || 'pkg/'
  @dir = dir.end_with?('/') ? dir : "#{dir}/"
end

#versionGem::Version

Returns the version of the gemspec for this instance of SGem.

Returns:

  • (Gem::Version)

    the version of the gemspec for this instance of SGem



40
41
42
# File 'lib/sgem.rb', line 40

def version
  @version ||= @spec.version
end