Class: Redcar::Textmate::Bundle

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
plugins/textmate/lib/textmate/bundle.rb

Constant Summary

Constant Summary

Constants included from Observable

Observable::ASPECTS

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Observable

#add_listener, #notify_listeners, #remove_listener

Constructor Details

- (Bundle) initialize(path)

A new instance of Bundle



9
10
11
12
13
14
15
16
17
18
19
20
# File 'plugins/textmate/lib/textmate/bundle.rb', line 9

def initialize(path)
  @path = File.expand_path(path)
  info_path = File.join(path, "info.plist")
  if File.exist?(info_path)
    @plist = Plist.xml_to_plist(File.read(info_path))
  end
  @snippets = snippet_paths.map {|path|
    s = Snippet.new(path, self.name,self.uuid)
    deleted.include?(s.uuid) ? nil : s
  }.compact
  @preferences = preference_paths.map {|path| Preference.new(path) }
end

Instance Attribute Details

- (Object) path

Returns the value of attribute path



7
8
9
# File 'plugins/textmate/lib/textmate/bundle.rb', line 7

def path
  @path
end

- (Object) plist (readonly)

Returns the value of attribute plist



6
7
8
# File 'plugins/textmate/lib/textmate/bundle.rb', line 6

def plist
  @plist
end

- (Object) preferences (readonly)

Returns the value of attribute preferences



6
7
8
# File 'plugins/textmate/lib/textmate/bundle.rb', line 6

def preferences
  @preferences
end

- (Object) snippets

Returns the value of attribute snippets



7
8
9
# File 'plugins/textmate/lib/textmate/bundle.rb', line 7

def snippets
  @snippets
end

Instance Method Details

- (Object) build_menu(builder)



62
63
64
65
66
67
68
69
70
# File 'plugins/textmate/lib/textmate/bundle.rb', line 62

def build_menu(builder)
  if main_menu and main_menu["items"]
    builder.sub_menu name do |m|
      main_menu["items"].each do |item|
        build_menu_from_item(builder, item)
      end
    end
  end
end

- (Object) build_menu_from_item(builder, item)



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'plugins/textmate/lib/textmate/bundle.rb', line 72

def build_menu_from_item(builder, item)
  unless deleted.include?(item)
    if item =~ /^$/ #is a separator
      builder.separator
    elsif sub_menus[item] #is a submenu
      sub_menu = sub_menus[item]
      builder.sub_menu(sub_menu["name"]) do |sub_builder|
        sub_menu["items"].each do |sub_item|
          build_menu_from_item(sub_builder, sub_item)
        end
      end
    elsif Textmate.uuid_hash[item] #is a snippet
      snippet = Textmate.uuid_hash[item]
      if snippet.is_a?(Textmate::Snippet)
        return unless snippet.name and snippet.name != "" #has a name
        builder.item(snippet.to_menu_string) do
          doc = EditView.focussed_edit_view_document
          if doc
            controller = doc.controllers(Snippets::DocumentController).first
            controller.start_snippet!(snippet)
          end
        end
      end
    end
  end
end

- (Object) contact_email



42
43
44
# File 'plugins/textmate/lib/textmate/bundle.rb', line 42

def contact_email
  BundleEditor.rot13(@plist["contactEmailRot13"] ||= "")
end

- (Object) contact_name



38
39
40
# File 'plugins/textmate/lib/textmate/bundle.rb', line 38

def contact_name
  @plist["contactName"]
end

- (Object) deleted



50
51
52
# File 'plugins/textmate/lib/textmate/bundle.rb', line 50

def deleted
  @plist["deleted"] ||= []
end

- (Object) description



46
47
48
# File 'plugins/textmate/lib/textmate/bundle.rb', line 46

def description
  @plist["description"]
end


54
55
56
# File 'plugins/textmate/lib/textmate/bundle.rb', line 54

def main_menu
  @plist["mainMenu"]
end

- (Object) name



26
27
28
# File 'plugins/textmate/lib/textmate/bundle.rb', line 26

def name
  @plist["name"]
end

- (Object) ordering



34
35
36
# File 'plugins/textmate/lib/textmate/bundle.rb', line 34

def ordering
  @plist["ordering"]
end


58
59
60
# File 'plugins/textmate/lib/textmate/bundle.rb', line 58

def sub_menus
  main_menu["submenus"]
end

- (Object) uuid



30
31
32
# File 'plugins/textmate/lib/textmate/bundle.rb', line 30

def uuid
  @plist["uuid"]
end

- (Boolean) writable?

Returns:

  • (Boolean)


22
23
24
# File 'plugins/textmate/lib/textmate/bundle.rb', line 22

def writable?
  File.writable?(path)
end