Class: Eclipse::Feature::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/eclipse/feature.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jar_or_src_dir) ⇒ Info

Returns a new instance of Info.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/eclipse/feature.rb', line 27

def initialize(jar_or_src_dir)
  featureXml = File.join(jar_or_src_dir, 'feature.xml')
  if File.directory?(jar_or_src_dir)
    getFeatureInfo(File.read(featureXml))
    @workspace = File.dirname(featureXml)
  elsif File.exists?(jar_or_src_dir)
    @jarfile = Zip::File.open(jar_or_src_dir)
    if @jarfile.find_entry('feature.xml')
      getFeatureInfo(@jarfile.read('feature.xml'))
    else
      raise("#{jar_or_src_dir} must contain a feature.xml")
    end
  else
    raise("#{jar_or_src_dir} must be feature.jar or point to a directory containing a feature.xml")
  end    
end

Instance Attribute Details

Returns the value of attribute copyright.



11
12
13
# File 'lib/eclipse/feature.rb', line 11

def copyright
  @copyright
end

#descriptionObject (readonly)

Returns the value of attribute description.



11
12
13
# File 'lib/eclipse/feature.rb', line 11

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



11
12
13
# File 'lib/eclipse/feature.rb', line 11

def id
  @id
end

#included_featuresObject (readonly)

Returns the value of attribute included_features.



10
11
12
# File 'lib/eclipse/feature.rb', line 10

def included_features
  @included_features
end

#included_pluginsObject (readonly)

Returns the value of attribute included_plugins.



10
11
12
# File 'lib/eclipse/feature.rb', line 10

def included_plugins
  @included_plugins
end

#labelObject (readonly)

Returns the value of attribute label.



11
12
13
# File 'lib/eclipse/feature.rb', line 11

def label
  @label
end

#licenseObject (readonly)

Returns the value of attribute license.



11
12
13
# File 'lib/eclipse/feature.rb', line 11

def license
  @license
end

#providerObject (readonly)

Returns the value of attribute provider.



11
12
13
# File 'lib/eclipse/feature.rb', line 11

def provider
  @provider
end

#symbolicNameObject (readonly)

Returns the value of attribute symbolicName.



11
12
13
# File 'lib/eclipse/feature.rb', line 11

def symbolicName
  @symbolicName
end

#versionObject (readonly)

Returns the value of attribute version.



11
12
13
# File 'lib/eclipse/feature.rb', line 11

def version
  @version
end

#workspaceObject (readonly)

Returns the value of attribute workspace.



11
12
13
# File 'lib/eclipse/feature.rb', line 11

def workspace
  @workspace
end

Instance Method Details

#getFeatureInfo(content) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/eclipse/feature.rb', line 13

def getFeatureInfo(content)
  @included_plugins = []
  @included_features = []
  doc = Nokogiri::XML(content)
  @symbolicName = doc.root.attributes['id'].text
  @label        = doc.root.attributes['label'].text
  @version      = doc.root.attributes['version'].text
  @provider     = doc.root.attributes['provider'] ? doc.root.attributes['provider'].text     : ''
  @description  = doc.search('description') ? doc.search('description').text                 : ''
  @license      = doc.search('license')     ? doc.search('license').text.gsub(/\n\s*/, '')   : ''
  @copyright    = doc.search('copyright')   ? doc.search('copyright').text.gsub(/\n\s*/, '') : ''
  doc.search('plugin').each   { |s| @included_plugins  << s.attribute('id').text }
  doc.search('includes').each { |s| @included_features << s.attribute('id').text }
end