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(configuration, mcdependency, plugintype) ⇒ StandardDefinition

Returns a new instance of StandardDefinition.



6
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 6

def initialize(configuration, mcdependency, plugintype)
  @plugintype = plugintype
  @path = PluginPackager.get_plugin_path(configuration[:target])
  @packagedata = {}
  @revision = configuration[:revision] || 1
  @preinstall = configuration[:preinstall]
  @postinstall = configuration[:postinstall]
  @vendor = configuration[:vendor] || "Choria.IO User"
  @dependencies = configuration[:dependency] || []
  @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] = (configuration[:pluginname] || @metadata[:name]).downcase.gsub(/\s+|_/, "-")
  @metadata[:version] = (configuration[:version] || @metadata[:version])

  identify_packages
end

Instance Attribute Details

#dependenciesObject

Returns the value of attribute dependencies.



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

def dependencies
  @dependencies
end

#mcnameObject

Returns the value of attribute mcname.



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

def mcname
  @mcname
end

#mcversionObject

Returns the value of attribute mcversion.



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

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.



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

def plugintype
  @plugintype
end

#postinstallObject

Returns the value of attribute postinstall.



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

def postinstall
  @postinstall
end

#preinstallObject

Returns the value of attribute preinstall.



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

def preinstall
  @preinstall
end

#revisionObject

Returns the value of attribute revision.



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

def revision
  @revision
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



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 61

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
  end

  nil
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.to_sym] = 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
51
52
53
54
55
56
57
58
# File 'lib/mcollective/pluginpackager/standard_definition.rb', line 35

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

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

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

  plugindata
end