Class: Sycsvpro::ScriptList
- Inherits:
-
Object
- Object
- Sycsvpro::ScriptList
- Defined in:
- lib/sycsvpro/script_list.rb
Overview
Lists the contents of the script directory. Optionally listing a specific script file and also optionally the methods and associated description of the methods
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Hash holding the list of scripts.
-
#script_dir ⇒ Object
readonly
Directory that holds the scripts.
-
#script_file ⇒ Object
readonly
Script file of interest.
-
#show_methods ⇒ Object
readonly
Switch indicating whether to show methods.
Instance Method Summary collapse
-
#execute ⇒ Object
Retrieves the information about scripts and methods from the script directory.
-
#initialize(options = {}) ⇒ ScriptList
constructor
Creates a new ScriptList.
Constructor Details
#initialize(options = {}) ⇒ ScriptList
Creates a new ScriptList. Takes params script_dir, script_file and show_methods
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sycsvpro/script_list.rb', line 18 def initialize(={}) @script_dir = [:dir] @script_type = [:type] || 'script' @script_type.downcase! @script_file = [:script] || '*.rb' if @script_type == 'script' @script_file = [:script] || '*.ins' if @script_type == 'insert' @script_file = [:script] || '*.{rb,ins}' if @script_type == 'all' @show_methods = [:show_methods] if @script_type == 'script' @show_methods = false if @script_type == 'insert' @list = {} end |
Instance Attribute Details
#list ⇒ Object (readonly)
Hash holding the list of scripts
15 16 17 |
# File 'lib/sycsvpro/script_list.rb', line 15 def list @list end |
#script_dir ⇒ Object (readonly)
Directory that holds the scripts
9 10 11 |
# File 'lib/sycsvpro/script_list.rb', line 9 def script_dir @script_dir end |
#script_file ⇒ Object (readonly)
Script file of interest
11 12 13 |
# File 'lib/sycsvpro/script_list.rb', line 11 def script_file @script_file end |
#show_methods ⇒ Object (readonly)
Switch indicating whether to show methods
13 14 15 |
# File 'lib/sycsvpro/script_list.rb', line 13 def show_methods @show_methods end |
Instance Method Details
#execute ⇒ Object
Retrieves the information about scripts and methods from the script directory
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sycsvpro/script_list.rb', line 31 def execute scripts = Dir.glob(File.join(@script_dir, @script_file)) scripts.each do |script| list[script] = [] if show_methods list[script] = retrieve_methods(script) end end list end |