Class: Eclipse::Feature::Info
- Inherits:
-
Object
- Object
- Eclipse::Feature::Info
- Defined in:
- lib/eclipse/feature.rb
Instance Attribute Summary collapse
-
#copyright ⇒ Object
readonly
Returns the value of attribute copyright.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#included_features ⇒ Object
readonly
Returns the value of attribute included_features.
-
#included_plugins ⇒ Object
readonly
Returns the value of attribute included_plugins.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#license ⇒ Object
readonly
Returns the value of attribute license.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#symbolicName ⇒ Object
readonly
Returns the value of attribute symbolicName.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #getFeatureInfo(content) ⇒ Object
-
#initialize(jar_or_src_dir) ⇒ Info
constructor
A new instance of Info.
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 |
# 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)) elsif File.exists?(jar_or_src_dir) @jarfile = Zip::ZipFile.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
#copyright ⇒ Object (readonly)
Returns the value of attribute copyright.
11 12 13 |
# File 'lib/eclipse/feature.rb', line 11 def copyright @copyright end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
11 12 13 |
# File 'lib/eclipse/feature.rb', line 11 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/eclipse/feature.rb', line 11 def id @id end |
#included_features ⇒ Object (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_plugins ⇒ Object (readonly)
Returns the value of attribute included_plugins.
10 11 12 |
# File 'lib/eclipse/feature.rb', line 10 def included_plugins @included_plugins end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
11 12 13 |
# File 'lib/eclipse/feature.rb', line 11 def label @label end |
#license ⇒ Object (readonly)
Returns the value of attribute license.
11 12 13 |
# File 'lib/eclipse/feature.rb', line 11 def license @license end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
11 12 13 |
# File 'lib/eclipse/feature.rb', line 11 def provider @provider end |
#symbolicName ⇒ Object (readonly)
Returns the value of attribute symbolicName.
11 12 13 |
# File 'lib/eclipse/feature.rb', line 11 def symbolicName @symbolicName end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
11 12 13 |
# File 'lib/eclipse/feature.rb', line 11 def version @version 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 |