Class: Jax::Plugin::Manifest

Inherits:
ActiveSupport::HashWithIndifferentAccess
  • Object
show all
Defined in:
lib/jax/plugin/manifest.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin_name) ⇒ Manifest

Returns a new instance of Manifest.



11
12
13
14
15
# File 'lib/jax/plugin/manifest.rb', line 11

def initialize(plugin_name)
  super()
  self[:name] = plugin_name
  defaults
end

Class Method Details

.find(name) ⇒ Object



5
6
7
8
# File 'lib/jax/plugin/manifest.rb', line 5

def find(name)
  man = new name
  man.load
end

Instance Method Details

#defaultsObject



66
67
68
69
70
# File 'lib/jax/plugin/manifest.rb', line 66

def defaults
  self[:description] ||= ""
  self[:version] ||= "0.0.1"
  self
end

#descriptionObject



33
34
35
# File 'lib/jax/plugin/manifest.rb', line 33

def description
  self[:description]
end

#description=(n) ⇒ Object



37
38
39
# File 'lib/jax/plugin/manifest.rb', line 37

def description=(n)
  self[:description] = n
end

#loadObject



41
42
43
# File 'lib/jax/plugin/manifest.rb', line 41

def load
  load_from path
end

#load_from(path) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/jax/plugin/manifest.rb', line 45

def load_from(path)
  yml = YAML::load(File.read(path))
  yml.each do |key, value|
    self[key] = value
  end
  self
end

#nameObject



17
18
19
# File 'lib/jax/plugin/manifest.rb', line 17

def name
  self[:name]
end

#name=(n) ⇒ Object



21
22
23
# File 'lib/jax/plugin/manifest.rb', line 21

def name=(n)
  self[:name] = n
end

#pathObject



62
63
64
# File 'lib/jax/plugin/manifest.rb', line 62

def path
  File.join(Jax.root, "vendor/plugins", name, "manifest.yml")
end

#saveObject



53
54
55
# File 'lib/jax/plugin/manifest.rb', line 53

def save
  save_to path
end

#save_to(path) ⇒ Object



57
58
59
60
# File 'lib/jax/plugin/manifest.rb', line 57

def save_to(path)
  File.open(path, "w") { |f| f.print to_yaml }
  self
end

#versionObject



25
26
27
# File 'lib/jax/plugin/manifest.rb', line 25

def version
  self[:version]
end

#version=(n) ⇒ Object



29
30
31
# File 'lib/jax/plugin/manifest.rb', line 29

def version=(n)
  self[:version] = n
end