Class: Auto::Plugins::Plugin
- Inherits:
-
Object
- Object
- Auto::Plugins::Plugin
- Defined in:
- lib/auto/plugins.rb
Overview
Stores a plugin’s name, library, and tasks.
Instance Attribute Summary collapse
-
#library ⇒ Object
readonly
Returns the value of attribute library.
-
#module ⇒ Object
readonly
Returns the value of attribute module.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
Instance Method Summary collapse
-
#initialize(directory) ⇒ Plugin
constructor
Assigns attributes using a plugin directory path.
Constructor Details
#initialize(directory) ⇒ Plugin
Assigns attributes using a plugin directory path.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/auto/plugins.rb', line 79 def initialize(directory) name = File.basename(directory) name = name.split('-') return nil unless name.include?('auto') @name = name[name.index('auto') + 1] # ~/.auto/auto-plugin/lib/plugin.rb @library = "#{directory}/lib/#{@name}.rb" @library = nil unless File.exists?(@library) # Auto::Plugin if @library @module = File.basename(@library, '.rb').camelize else @module = nil end # ~/.auto/auto-plugin/auto/task.rb @tasks = Dir["#{directory}/.auto/**/*.rb"].sort.collect do |path| relative = path.gsub("#{directory}/.auto/", '') { :name => relative[0..-4].split('/').join(':').downcase, :path => path } end end |
Instance Attribute Details
#library ⇒ Object (readonly)
Returns the value of attribute library.
74 75 76 |
# File 'lib/auto/plugins.rb', line 74 def library @library end |
#module ⇒ Object (readonly)
Returns the value of attribute module.
75 76 77 |
# File 'lib/auto/plugins.rb', line 75 def module @module end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
73 74 75 |
# File 'lib/auto/plugins.rb', line 73 def name @name end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
76 77 78 |
# File 'lib/auto/plugins.rb', line 76 def tasks @tasks end |