Class: Swiftly::Package
- Inherits:
-
Object
- Object
- Swiftly::Package
- Defined in:
- lib/swiftly/package.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
- .all(type) ⇒ Object
- .file ⇒ Object
- .gather(type) ⇒ Object
-
.load(type, attributes) ⇒ type
Loads the class variable @package with an hash with package objects by package types.
-
.retrieve(type, name) ⇒ obj
Return a package back to the requester.
- .set(package_type, *args, &block) ⇒ Object
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
5 6 7 |
# File 'lib/swiftly/package.rb', line 5 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/swiftly/package.rb', line 4 def name @name end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/swiftly/package.rb', line 6 def status @status end |
Class Method Details
.all(type) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/swiftly/package.rb', line 88 def self.all type self.gather type return false if @packages[type].nil? && type == :plugin @packages end |
.file ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/swiftly/package.rb', line 8 def self.file @settings = Swiftly::Config.load :global File.join( @settings[:sites_path], "#{APP_NAME.capitalize}file", ) unless !File.exists?( File.join( @settings[:sites_path], "#{APP_NAME.capitalize}file" ) ) end |
.gather(type) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/swiftly/package.rb', line 97 def self.gather type # Set the type @type = type # Ready the package hash @packages = { type => [] } # Set defaults self.defaults proc = Proc.new {} # Evalutes the config file and runs the methods on the file eval( IO.read( self.file ), proc.binding, self.file) end |
.load(type, attributes) ⇒ type
Loads the class variable @package with an hash with package objects by package types
49 50 51 52 |
# File 'lib/swiftly/package.rb', line 49 def self.load type, attributes @packages[type] << attributes end |
.retrieve(type, name) ⇒ obj
Return a package back to the requester
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/swiftly/package.rb', line 61 def self.retrieve type, name # Gather all packages self.gather type # Check to see if the class variable packages # contain packages that match the passed in type if !@packages[type].nil? # If so the loop over all the packages @packages[type].each do |package| # Check to see if one thereis one # that matches the passed in name if package.name == name # If so the return it return package end end end # If all goes bad then return false return false end |
.set(package_type, *args, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/swiftly/package.rb', line 24 def self.set package_type, *args, &block unless package_type == @package_type && args[0][:type] == @type return end Swiftly::Smokestack.define do factory package_type, &block end self.load args[0][:type], Swiftly::Smokestack.build( package_type ) end |