Class: MCollective::PluginPackager::StandardDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/mcollective/pluginpackager/standard_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, name, vendor, preinstall, postinstall, iteration, dependencies, mcdependency, plugintype) ⇒ StandardDefinition

Returns a new instance of StandardDefinition.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 7

def initialize(path, name, vendor, preinstall, postinstall, iteration, dependencies, mcdependency, plugintype)
  @plugintype = plugintype
  @path = path
  @packagedata = {}
  @iteration = iteration || 1
  @preinstall = preinstall
  @postinstall = postinstall
  @vendor = vendor || "Puppet Labs"
  @dependencies = dependencies || []
  @target_path = File.expand_path(@path)
  @metadata, mcversion = PluginPackager.(@path, @plugintype)

  @mcname = mcdependency[:mcname] || "mcollective"
  @mcversion = mcdependency[:mcversion] || mcversion
  @dependencies << {:name => "#{mcname}-common", :version => @mcversion}
  @metadata[:name] = (name || @metadata[:name]).downcase.gsub(" ", "-")
  identify_packages
end

Instance Attribute Details

#dependenciesObject

Returns the value of attribute dependencies.



5
6
7
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 5

def dependencies
  @dependencies
end

#iterationObject

Returns the value of attribute iteration.



4
5
6
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 4

def iteration
  @iteration
end

#mcnameObject

Returns the value of attribute mcname.



5
6
7
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 5

def mcname
  @mcname
end

#mcversionObject

Returns the value of attribute mcversion.



5
6
7
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 5

def mcversion
  @mcversion
end

#metadataObject

Returns the value of attribute metadata.



4
5
6
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 4

def 
  @metadata
end

#packagedataObject

Returns the value of attribute packagedata.



4
5
6
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 4

def packagedata
  @packagedata
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 4

def path
  @path
end

#plugintypeObject

Returns the value of attribute plugintype.



5
6
7
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 5

def plugintype
  @plugintype
end

#postinstallObject

Returns the value of attribute postinstall.



5
6
7
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 5

def postinstall
  @postinstall
end

#preinstallObject

Returns the value of attribute preinstall.



5
6
7
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 5

def preinstall
  @preinstall
end

#target_pathObject

Returns the value of attribute target_path.



4
5
6
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 4

def target_path
  @target_path
end

#vendorObject

Returns the value of attribute vendor.



4
5
6
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 4

def vendor
  @vendor
end

Instance Method Details

#commonObject

Obtain list of common files



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 53

def common
  common = {:files => [],
            :dependencies => @dependencies.clone,
            :description => "Common libraries for #{@name} connector plugin"}

  commondir = File.join(@path, "util")
  if PluginPackager.check_dir_present commondir
    common[:files] = Dir.glob(File.join(commondir, "*"))
    return common
  else
    return nil
  end
end

#identify_packagesObject

Identify present packages and populate the packagedata hash



27
28
29
30
31
32
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 27

def identify_packages
  common_package = common
  @packagedata[:common] = common_package if common_package
  plugin_package = plugin
  @packagedata[@plugintype] = plugin_package if plugin_package
end

#pluginObject

Obtain standard plugin files and dependencies



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 35

def plugin
  plugindata = {:files => [],
                :dependencies => @dependencies.clone,
                :description => "#{@name} #{@plugintype} plugin for the Marionette Collective."}

  plugindir = File.join(@path, @plugintype.to_s)
  if PluginPackager.check_dir_present plugindir
    plugindata[:files] = Dir.glob(File.join(plugindir, "*"))
  else
    return nil
  end

  plugindata[:dependencies] << {:name => "#{@mcname}-#{@metadata[:name]}-common",
                                :version => @metadata[:version]} if @packagedata[:common]
  plugindata
end