Class: Source::Base

Inherits:
Object show all
Includes:
HasOptionMethods
Defined in:
lib/gpm/source.rb

Direct Known Subclasses

Gem, Maven

Defined Under Namespace

Classes: Factory

Constant Summary collapse

DEFAULTS =
{
  # Default version is 1.0 in case nobody told us a specific version.
  :version => "1.0",
  :build_number => nil,
  :epoch => nil,
  # If architecture is nil, the target package should provide a default.
  # Special 'architecture' values include "all" (aka rpm's noarch, debian's all)
  # Another special includes "native" which will be the current platform's arch.
  :architecture => nil,
  :dependencies => [],
  :provides => [],
  :replaces => [],
  :conflicts => [],
  :scripts => [],
  :config_files => [],
  :settings => {},
  :url => "http://nourlgiven.example.com/no/url/given",
  :category => "default",
  :license => "unknown",
  :maintainer => nil,
  :description => "no description given"
}

Instance Attribute Summary collapse

Attributes included from HasOptionMethods

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasOptionMethods

included

Constructor Details

#initialize(files_provider, options = {}) ⇒ Base

Returns a new instance of Base.



70
71
72
73
# File 'lib/gpm/source.rb', line 70

def initialize(files_provider,options={})
  @options=options
  @files_provider=files_provider
end

Instance Attribute Details

#files_providerObject (readonly)

Returns the value of attribute files_provider.



68
69
70
# File 'lib/gpm/source.rb', line 68

def files_provider
  @files_provider
end

Class Method Details

.constant_field(name, value) ⇒ Object



35
36
37
38
39
# File 'lib/gpm/source.rb', line 35

def self.constant_field(name,value)
  define_method(name) do
    value
  end
end

Instance Method Details

#contains_file?(file_name) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
104
# File 'lib/gpm/source.rb', line 101

def contains_file?(file_name)
  file_name = FilePathAndPermissions.new(file_name) unless file_name.kind_of? FilePathAndPermissions
  file_contents.include? file_name
end

#file_contentsObject



106
107
108
# File 'lib/gpm/source.rb', line 106

def file_contents
files_provider.nil? ? {} : files_provider.file_contents
end

#filesObject



110
111
112
# File 'lib/gpm/source.rb', line 110

def files
  files_provider.files
end

#maintainerObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/gpm/source.rb', line 80

def maintainer
  # Default maintainer if none given.
  if @maintainer.nil? or @maintainer.empty?
    # Reference
    # http://www.debian.org/doc/manuals/maint-guide/first.en.html
    # http://wiki.debian.org/DeveloperConfiguration
    # https://github.com/jordansissel/fpm/issues/37
    if ENV.include?("DEBEMAIL") and ENV.include?("DEBFULLNAME")
      # Use DEBEMAIL and DEBFULLNAME as the default maintainer if available.
      @maintainer = "#{ENV["DEBFULLNAME"]} <#{ENV["DEBEMAIL"]}>"
    else
      # TODO(sissel): Maybe support using 'git config' for a default as well?
      # git config --get user.name, etc can be useful.
      # Maybe use 'whoami', in case we are not in a git repository?
      #
      # Otherwise default to user@currenthost
      @maintainer = "<#{ENV["USER"]}@#{Socket.gethostname}>"
    end
  end
end