Sha256: 1a26d5abd8870be28e8efe239c39bc55fb81b4ab31fef793ad003c28849994e3

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

class PluginManager
  class PluginDefinition
    attr_accessor :name,
                  :version,
                  :object_string,
                  :file,
                  :dependencies,
                  :definition_file
                  
    def inspect1              
      "<Plugin #{name} #{version} depends:[#{(dependencies||[]).map{|dep| dep.join("")}.join(", ")}] #{required_files.length} files>"
    end
    
    def inspect
      inspect1
    end
    
    def required_files
      @required_files ||= []
    end
    
    def load
      required_files.each {|file| $".delete(file) }
      load_file = File.expand_path(File.join(File.dirname(definition_file), file))
      $:.unshift(File.dirname(load_file))
      new_files = log_requires do
        require load_file
      end
      required_files.unshift(*new_files)
      if object.respond_to?(:loaded)
        object.loaded
      end
    end
    
    def object
      eval(object_string)
    end
    
    private
    
    def log_requires
      before = $".dup 
      yield
      after = $".dup
      result = after - before
      result
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
redcar-0.3.8.4 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.8.3 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.8.2 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.8.1 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.8 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.7.1 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.7 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.6 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.5 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.3 lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
redcar-0.3.2dev lib/plugin_manager/lib/plugin_manager/plugin_definition.rb
plugin_manager-1.1 lib/plugin_manager/plugin_definition.rb