Class: Orasaurus::Application
- Inherits:
-
Object
- Object
- Orasaurus::Application
- Includes:
- DB
- Defined in:
- lib/orasaurus/application.rb
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
Returns the value of attribute base_dir.
-
#build_dirs ⇒ Object
Returns the value of attribute build_dirs.
-
#config ⇒ Object
Returns the value of attribute config.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#connect(*args) ⇒ Object
Connects to the database.
- #generate(type, sortOpts = {}) ⇒ Object
- #generate_scripts(type, sortOpts = {}) ⇒ Object
- #get_build_items(dir, sortOpts = {}) ⇒ Object
- #ignore_filenames ⇒ Object
-
#initialize(name, base_dir) ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize(name, base_dir) ⇒ Application
Returns a new instance of Application.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/orasaurus/application.rb', line 15 def initialize(name,base_dir) @name = name if File.directory? base_dir @base_dir = base_dir else raise "Directory not found." end @config = Orasaurus::Configuration.default @build_dirs = fill_build_dirs puts "Orasaurus has been awakened." puts "Build Dirs: #{@build_dirs.to_s}" end |
Instance Attribute Details
#base_dir ⇒ Object
Returns the value of attribute base_dir.
11 12 13 |
# File 'lib/orasaurus/application.rb', line 11 def base_dir @base_dir end |
#build_dirs ⇒ Object
Returns the value of attribute build_dirs.
11 12 13 |
# File 'lib/orasaurus/application.rb', line 11 def build_dirs @build_dirs end |
#config ⇒ Object
Returns the value of attribute config.
11 12 13 |
# File 'lib/orasaurus/application.rb', line 11 def config @config end |
#connection ⇒ Object
Returns the value of attribute connection.
11 12 13 |
# File 'lib/orasaurus/application.rb', line 11 def connection @connection end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/orasaurus/application.rb', line 11 def name @name end |
Instance Method Details
#connect(*args) ⇒ Object
Connects to the database. Use oci8 args to connect
29 30 31 |
# File 'lib/orasaurus/application.rb', line 29 def connect(*args) @connection = Connection.new(*args) end |
#generate(type, sortOpts = {}) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/orasaurus/application.rb', line 37 def generate(type,sortOpts={}) if [:build_scripts,:teardown_scripts].include? type.to_sym puts "generating #{type}" generate_scripts(type,sortOpts) else puts "Don't know how to generate " + type.to_s end end |
#generate_scripts(type, sortOpts = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/orasaurus/application.rb', line 63 def generate_scripts(type,sortOpts={}) if @build_dirs.length > 0 then @build_dirs.each do |dir| case type when :build_scripts Orasaurus::SqlBuildGenerator.new(dir,dir,config.build_file_name,get_build_items(dir,sortOpts)).generate when :teardown_scripts Orasaurus::SqlTeardownGenerator.new(dir,dir,config.teardown_file_name,get_build_items(dir,sortOpts)).generate end end else puts "nothing found to work on." end end |
#get_build_items(dir, sortOpts = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/orasaurus/application.rb', line 46 def get_build_items(dir,sortOpts={}) buildable_items = Array.new search_list = Dir.glob(dir + "/*.*" ) search_list.each do |f| #TODO refactor to regex if File.file?( f ) \ and not ignore_filenames.include?(File.basename(f)) \ and @config.buildable_file_extensions.include?(File.extname(f)) \ then buildable_items.push(File.basename(f)) end end puts "#{dir} build_items: #{buildable_items.to_s}" sortOpts[:db_connection] = @connection return Builder.sort(buildable_items,sortOpts) end |
#ignore_filenames ⇒ Object
33 34 35 |
# File 'lib/orasaurus/application.rb', line 33 def ignore_filenames files = %w{ @config.build_file_name @config.build_log_file_name @config.teardown_file_name @config.teardown_log_file_name } end |