Class: MVCLI::Core

Inherits:
Object
  • Object
show all
Extended by:
Enumerable
Defined in:
lib/mvcli/core.rb

Direct Known Subclasses

App, Std, Plugins

Defined Under Namespace

Classes: Std

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Core

Returns a new instance of Core.



14
15
16
17
18
19
# File 'lib/mvcli/core.rb', line 14

def initialize(options = {})
  options = Map options
  @path = options[:path]
  @name = options[:name]
  @namespace = options[:namespace]
end

Class Attribute Details

.identifierObject

Returns the value of attribute identifier.



72
73
74
# File 'lib/mvcli/core.rb', line 72

def identifier
  @identifier
end

.namespaceObject

Returns the value of attribute namespace.



72
73
74
# File 'lib/mvcli/core.rb', line 72

def namespace
  @namespace
end

.pathObject

Returns the value of attribute path.



72
73
74
# File 'lib/mvcli/core.rb', line 72

def path
  @path
end

.versionObject

Returns the value of attribute version.



72
73
74
# File 'lib/mvcli/core.rb', line 72

def version
  @version
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/mvcli/core.rb', line 12

def name
  @name
end

#namespaceObject

Returns the value of attribute namespace.



12
13
14
# File 'lib/mvcli/core.rb', line 12

def namespace
  @namespace
end

#pathObject

Returns the value of attribute path.



12
13
14
# File 'lib/mvcli/core.rb', line 12

def path
  @path
end

Class Method Details

.<<(base) ⇒ Object



82
83
84
# File 'lib/mvcli/core.rb', line 82

def <<(base)
  all << base
end

.allObject



78
79
80
# File 'lib/mvcli/core.rb', line 78

def all
  @all ||= []
end

.drain(&visitor) ⇒ Object



90
91
92
93
# File 'lib/mvcli/core.rb', line 90

def drain(&visitor)
  each &visitor
  all.clear
end

.each(&visitor) ⇒ Object



86
87
88
# File 'lib/mvcli/core.rb', line 86

def each(&visitor)
  all.each &visitor
end

.inherited(base) ⇒ Object



74
75
76
# File 'lib/mvcli/core.rb', line 74

def inherited(base)
  ::MVCLI::Core << base
end

Instance Method Details

#activate!Object



21
22
# File 'lib/mvcli/core.rb', line 21

def activate!
end

#exists?(extension_type, name) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/mvcli/core.rb', line 43

def exists?(extension_type, name)
  loader.exists? path, extension_type, name
end

#read(extension_type, name, options = {}) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/mvcli/core.rb', line 47

def read(extension_type, name, options = {})
  unless exists? extension_type, name
    fail ExtensionNotFound, "unable to locate #{extension_type} '#{name}'"
  end
  this = self
  loader.read(path, extension_type, name, namespace).tap do |ext|
    [ext, ext.singleton_class].each do |cls|
      cls.send(:define_method, :core) { this } if cls.respond_to?(:define_method, true)
    end
  end
end

#versionObject



38
39
40
41
# File 'lib/mvcli/core.rb', line 38

def version
  spec = Gem::Specification.load path.nearest('.gemspec$').to_s
  spec.version
end