Class: LEWT::Extension
- Inherits:
-
Object
- Object
- LEWT::Extension
- Defined in:
- lib/extension.rb
Direct Known Subclasses
CalendarExtractors::CalExtractor, CalendarTimekeeping, LiquidRenderer, Metastat, SimpleExpenses, SimpleInvoices, SimpleMilestones, SimpleReports, Store
Constant Summary collapse
- @@lewt_extensions =
@@extensions is a registry shared between all extensions that impliment this class containing there class names for invocation by the core system.
Array.new
Instance Attribute Summary collapse
-
#command_name ⇒ Object
readonly
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
-
#customers ⇒ Object
readonly
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
-
#enterprise ⇒ Object
readonly
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
-
#lewt_settings ⇒ Object
readonly
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
-
#lewt_stash ⇒ Object
readonly
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
-
#options ⇒ Object
readonly
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
Instance Method Summary collapse
-
#get_matched_customers(query, suppress = nil) ⇒ Object
- This method mathes customers wth query strings provided by users in the CLI query [String]
-
A search string to query against.
-
#initialize(ext_init = { :cmd => "lewt_base_extension" }) ⇒ Extension
constructor
This method is inoked by subclasses to initialise themselves within Lewt’s extension registry.
-
#lewt_extensions ⇒ Object
returns all registered extensions as an array of class names.
Constructor Details
#initialize(ext_init = { :cmd => "lewt_base_extension" }) ⇒ Extension
This method is inoked by subclasses to initialise themselves within Lewt’s extension registry.
- ext_init [Hash]
-
contains the keys
:cmd
,:options
- which are the command name (String) and options (Hash) for the extension respectively.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/extension.rb', line 29 def initialize ( ext_init = { :cmd => "lewt_base_extension" } ) core_settings = YAML.load_file( File.( '../config/settings.yml', __FILE__) ) if File.exists? File.( '~/.lewt_settings', __FILE__) core_settings.merge! YAML.load_file( File.( '~/.lewt_settings', __FILE__) ) end @lewt_stash = core_settings['lewt_stash'] || File.('../', __FILE__) + "/config/" load_lewt_settings() @command_name = ext_init[:cmd] @options = ext_init[:options] || nil register_extension end |
Instance Attribute Details
#command_name ⇒ Object (readonly)
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
20 21 22 |
# File 'lib/extension.rb', line 20 def command_name @command_name end |
#customers ⇒ Object (readonly)
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
20 21 22 |
# File 'lib/extension.rb', line 20 def customers @customers end |
#enterprise ⇒ Object (readonly)
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
20 21 22 |
# File 'lib/extension.rb', line 20 def enterprise @enterprise end |
#lewt_settings ⇒ Object (readonly)
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
20 21 22 |
# File 'lib/extension.rb', line 20 def lewt_settings @lewt_settings end |
#lewt_stash ⇒ Object (readonly)
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
20 21 22 |
# File 'lib/extension.rb', line 20 def lewt_stash @lewt_stash end |
#options ⇒ Object (readonly)
LEWT Stash is the user configured stash path where all extensions, config file, templates etc are stored.
20 21 22 |
# File 'lib/extension.rb', line 20 def @options end |
Instance Method Details
#get_matched_customers(query, suppress = nil) ⇒ Object
This method mathes customers wth query strings provided by users in the CLI
- query [String]
-
A search string to query against.
- suppress [String]
-
A list of clients to exclude. Defaults to nil ie: none.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/extension.rb', line 50 def get_matched_customers( query, suppress = nil ) requestedClients = Array.new if query == nil @customers.each do |client| client_match = [ client["alias"], client["name"] ].join("|") if suppress == nil or client_match.match(suppress.gsub(Lewt::OPTION_DELIMITER_REGEX,"|")) == nil requestedClients.push(client) end end else @customers.each do |client| client_match = [ client["alias"], client["name"] ].join("|") if client_match.match( query.gsub(Lewt::OPTION_DELIMITER_REGEX,"|") ) != nil if suppress == nil or client_match.match(suppress.gsub(Lewt::OPTION_DELIMITER_REGEX,"|")) == nil requestedClients.push(client) end end end end return requestedClients end |
#lewt_extensions ⇒ Object
returns all registered extensions as an array of class names
43 44 45 |
# File 'lib/extension.rb', line 43 def lewt_extensions @@lewt_extensions end |