Class: Megam::WorkArea
- Inherits:
-
Object
- Object
- Megam::WorkArea
- Defined in:
- lib/megam/workarea.rb
Overview
a class which manages the work area, ie find the files in workarea, packaging script in it.
Instance Attribute Summary collapse
-
#del_if_exists ⇒ Object
Returns the value of attribute del_if_exists.
-
#dir_glob_files ⇒ Object
Returns the value of attribute dir_glob_files.
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#msg ⇒ Object
Returns the value of attribute msg.
Class Method Summary collapse
Instance Method Summary collapse
- #directory_avail? ⇒ Boolean
-
#find_files_via_dirglob(i_dir) ⇒ Object
Lists all the files under the dir.
- #find_package_script(dir, package_words) ⇒ Object
-
#initialize(options) ⇒ WorkArea
constructor
A new instance of WorkArea.
-
#list_directory(i_dir) ⇒ Object
Lists all the files under the workarea_installer/<directory> using a helper.
- #to_s ⇒ Object
- #workarea_install(i_dir) ⇒ Object
-
#workarea_install_not_found!(i_dir) ⇒ Object
:nodoc: Error out and print usage.
Constructor Details
#initialize(options) ⇒ WorkArea
Returns a new instance of WorkArea.
26 27 28 29 30 31 |
# File 'lib/megam/workarea.rb', line 26 def initialize () @del_if_exists = false @directory = [:directory] if [:directory] @del_if_exists = [:del_if_exists] if [:del_if_exists] @msg = [:message] if [:message] end |
Instance Attribute Details
#del_if_exists ⇒ Object
Returns the value of attribute del_if_exists.
22 23 24 |
# File 'lib/megam/workarea.rb', line 22 def del_if_exists @del_if_exists end |
#dir_glob_files ⇒ Object
Returns the value of attribute dir_glob_files.
25 26 27 |
# File 'lib/megam/workarea.rb', line 25 def dir_glob_files @dir_glob_files end |
#directory ⇒ Object
Returns the value of attribute directory.
23 24 25 |
# File 'lib/megam/workarea.rb', line 23 def directory @directory end |
#msg ⇒ Object
Returns the value of attribute msg.
24 25 26 |
# File 'lib/megam/workarea.rb', line 24 def msg @msg end |
Class Method Details
Instance Method Details
#directory_avail? ⇒ Boolean
33 34 35 |
# File 'lib/megam/workarea.rb', line 33 def directory_avail? directory end |
#find_files_via_dirglob(i_dir) ⇒ Object
Lists all the files under the dir
45 46 47 48 49 50 51 52 |
# File 'lib/megam/workarea.rb', line 45 def find_files_via_dirglob(i_dir) dir_files = {} Megam::Birr.text.info(Megam::Birr.text.color("GLOB :", :green, :bold) + "#{i_dir}") if Dir.exists?(i_dir) dir_files[i_dir] = Dir.glob("#{i_dir}/**/*") end dir_files end |
#find_package_script(dir, package_words) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/megam/workarea.rb', line 77 def find_package_script(dir,package_words) adir = dir.dup adir = adir.gsub(".", File.path("/")) package_script_files = {} matching_dir = nil while ( package_script_files.empty? ) && ( !package_words.empty? ) if (!matching_dir) && (!package_words.empty?) package_script ||= package_words.pop matching_dir ||= Megam::Install.workarea_loader[File.join(adir.strip)] package_script_files[matching_dir] = Dir.glob("#{matching_dir}/**"+ package_script) end end package_script_files end |
#list_directory(i_dir) ⇒ Object
Lists all the files under the workarea_installer/<directory> using a helper
39 40 41 42 |
# File 'lib/megam/workarea.rb', line 39 def list_directory(i_dir) @dir_glob_files = {} @dir_glob_files ||= (find_files_via_dirglob(i_dir).values).flatten end |
#to_s ⇒ Object
93 94 95 |
# File 'lib/megam/workarea.rb', line 93 def to_s "workarea[:directory =>"+directory+"]" end |
#workarea_install(i_dir) ⇒ Object
58 59 60 61 62 |
# File 'lib/megam/workarea.rb', line 58 def workarea_install(i_dir) unless workarea_install_not_found!(i_dir) File.join(workarea_install_directory,i_dir) end end |
#workarea_install_not_found!(i_dir) ⇒ Object
:nodoc: Error out and print usage. probably becuase the arguments given by the user could not be resolved to a subcommand.
67 68 69 70 71 72 73 74 75 |
# File 'lib/megam/workarea.rb', line 67 def workarea_install_not_found!(i_dir) missing_install_dir = nil if missing_install_dir = !(WORKAREA_PRECONFIG_DIRS.find {|wai| wai == i_dir} ) Megam::Birr.text.fatal("Cannot find workarea install dir for: '#{i_dir}'") exit 10 end missing_install_dir end |