Class: Eclipse::Workspace

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workspace_dir) ⇒ Workspace

Returns a new instance of Workspace.



6
7
8
9
10
11
12
13
14
15
# File 'lib/eclipse/workspace.rb', line 6

def initialize(workspace_dir)
  @workspace_dir             = workspace_dir
  @views                     = Hash.new
  @view_categories           = Hash.new
  @preferencePages           = Hash.new
  @perspectives              = Hash.new
  @preferencePage_categories = Hash.new
  @plugins                   = Hash.new
  @features                  = Hash.new
end

Instance Attribute Details

#featuresObject (readonly)

Returns the value of attribute features.



5
6
7
# File 'lib/eclipse/workspace.rb', line 5

def features
  @features
end

#perspectivesObject (readonly)

Returns the value of attribute perspectives.



5
6
7
# File 'lib/eclipse/workspace.rb', line 5

def perspectives
  @perspectives
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



5
6
7
# File 'lib/eclipse/workspace.rb', line 5

def plugins
  @plugins
end

#preferencePage_categoriesObject (readonly)

Returns the value of attribute preferencePage_categories.



5
6
7
# File 'lib/eclipse/workspace.rb', line 5

def preferencePage_categories
  @preferencePage_categories
end

#preferencePagesObject (readonly)

Returns the value of attribute preferencePages.



5
6
7
# File 'lib/eclipse/workspace.rb', line 5

def preferencePages
  @preferencePages
end

#view_categoriesObject (readonly)

Returns the value of attribute view_categories.



5
6
7
# File 'lib/eclipse/workspace.rb', line 5

def view_categories
  @view_categories
end

#viewsObject (readonly)

Returns the value of attribute views.



5
6
7
# File 'lib/eclipse/workspace.rb', line 5

def views
  @views
end

#workspace_dirObject (readonly)

Returns the value of attribute workspace_dir.



5
6
7
# File 'lib/eclipse/workspace.rb', line 5

def workspace_dir
  @workspace_dir
end

Instance Method Details

#parseObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/eclipse/workspace.rb', line 27

def parse
  isInstallation = false
  ['plugins', 'features'].each{ |subdir|
    dir = File.join(@workspace_dir, subdir)
    if File.directory?(dir)
      isInstallation = true if parsePluginDir(dir)        
    end
  }
  parse_sub_dirs unless isInstallation
end

#parse_sub_dirsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/eclipse/workspace.rb', line 38

def parse_sub_dirs
  (Dir.glob("#{@workspace_dir}/*")+Dir.glob("#{@workspace_dir}/*/*")).compact.each{
    |item|
      proj = File.join(item, '.project')
      name = nil
      name = Document.new(File.new(proj).read).root.elements['name'].text if File.exists?(proj)
      next unless item and File.directory?(item)
      info = Plugin::Info.new(item)
      next unless info # ex. we read a feature
      add_info(info, item)
      if name and info.symbolicName and name != info.symbolicName
        puts "Warning: in #{item} the symbolicName (#{info.symbolicName}) of the plugin differs from the project name #{name}"
      end
  }
  show if $VERBOSE
end

#parsePluginDir(plugins_dir = File.join(@workspace_dir, "plugins")) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/eclipse/workspace.rb', line 17

def parsePluginDir(plugins_dir = File.join(@workspace_dir, "plugins"))
  Dir.glob("#{plugins_dir}/*.jar").each{
    |jarname|
    info = Plugin::Info.new(jarname)
    next unless info
    add_info(info, jarname) 
  }
  show if $VERBOSE
end

#showObject



54
55
56
# File 'lib/eclipse/workspace.rb', line 54

def show
  puts "Workspace #{@workspace_dir} with #{@plugins.size} plugins #{@views.size}/#{@view_categories.size} views #{@preferencePages.size}/#{@preferencePage_categories.size} preferencePages #{@perspectives.size} perspectives"
end