Class: Gem::Release::Files::Templates

Inherits:
Struct
  • Object
show all
Defined in:
lib/gem/release/files/templates.rb,
lib/gem/release/files/templates/group.rb

Defined Under Namespace

Classes: Group

Constant Summary collapse

BUILTIN =
[
  ['./.gem-release/%s'],
  ['~/.gem-release/%s'],
  ['../../templates/', __FILE__],
]
CUSTOM =
[
  ['./.gem-release/%s'],
  ['~/.gem-release/%s'],
  ['../../templates/%s', __FILE__],
]
EXECUTABLE =
[
  ['./.gem-release/executable'],
  ['~/.gem-release/executable'],
  ['../../templates/executable', __FILE__],
]
LICENSE =
[
  ['./.gem-release/licenses'],
  ['~/.gem-release/licenses'],
  ['../../templates/licenses', __FILE__],
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data


4
5
6
# File 'lib/gem/release/files/templates.rb', line 4

def data
  @data
end

#filesObject

Returns the value of attribute files

Returns:

  • (Object)

    the current value of files


4
5
6
# File 'lib/gem/release/files/templates.rb', line 4

def files
  @files
end

#groupsObject

Returns the value of attribute groups

Returns:

  • (Object)

    the current value of groups


4
5
6
# File 'lib/gem/release/files/templates.rb', line 4

def groups
  @groups
end

Class Method Details

.executable(target) ⇒ Object


29
30
31
32
33
# File 'lib/gem/release/files/templates.rb', line 29

def self.executable(target)
  file = Templates.new([".*"], [], {}).executable
  file.target = target if file
  file
end

.license(name, data) ⇒ Object


35
36
37
38
39
# File 'lib/gem/release/files/templates.rb', line 35

def self.license(name, data)
  file = Templates.new(["#{name}{,.*}"], [], data).license
  file.target = "LICENSE#{File.extname(file.target)}" if file
  file
end

Instance Method Details

#[](filename) ⇒ Object


41
42
43
# File 'lib/gem/release/files/templates.rb', line 41

def [](filename)
  all.detect { |file| file.filename == filename }
end

#allObject


45
46
47
48
# File 'lib/gem/release/files/templates.rb', line 45

def all
  all = builtin + custom
  all.flatten.uniq(&:target)
end

#builtinObject


50
51
52
# File 'lib/gem/release/files/templates.rb', line 50

def builtin
  templates_for(BUILTIN, files)
end

#customObject


54
55
56
# File 'lib/gem/release/files/templates.rb', line 54

def custom
  templates_for(CUSTOM, '**/*')
end

#executableObject


58
59
60
# File 'lib/gem/release/files/templates.rb', line 58

def executable
  templates_for(EXECUTABLE).first
end

#licenseObject


62
63
64
# File 'lib/gem/release/files/templates.rb', line 62

def license
  templates_for(LICENSE, files).first
end

#templates_for(sources, files = nil, opts = {}) ⇒ Object


66
67
68
69
# File 'lib/gem/release/files/templates.rb', line 66

def templates_for(sources, files = nil, opts = {})
  all = Group.new(groups, data, sources, files).all
  all.map { |source, target| Template.new(source, target, data, opts) }
end