Class: XMigra::SourceTreeInitializer
- Defined in:
- lib/xmigra/source_tree_initializer.rb
Defined Under Namespace
Classes: ConfigInfo
Instance Method Summary collapse
- #create_files! ⇒ Object
- #dbinfo_path ⇒ Object
- #get_user_input_block(input_type) ⇒ Object
-
#initialize(root_path) ⇒ SourceTreeInitializer
constructor
A new instance of SourceTreeInitializer.
- #vcs_system ⇒ Object
Constructor Details
#initialize(root_path) ⇒ SourceTreeInitializer
Returns a new instance of SourceTreeInitializer.
36 37 38 |
# File 'lib/xmigra/source_tree_initializer.rb', line 36 def initialize(root_path) @root_path = Pathname.new(root_path) end |
Instance Method Details
#create_files! ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 |
# File 'lib/xmigra/source_tree_initializer.rb', line 59 def create_files! schema_config = ConfigInfo.new(@root_path) if vcs_system.nil? puts "The indicated folder is not under version control. Some features" puts "of this system require version control for full functionality. If" puts "you later decide to use version control, you will need to configure" puts "it without assistance from this script." puts unless Console.yes_no("Continue configuring schema management", :no) return end end db_system = Console::Menu.new( "Supported Database Systems", DatabaseSupportModules, "Target system", :get_name => lambda {|m| m::SYSTEM_NAME} ).get_selection schema_config.dbinfo['system'] = db_system::SYSTEM_NAME if db_system.respond_to? :init_schema db_system.init_schema(schema_config) end if vcs_system.respond_to? :init_schema vcs_system.init_schema(schema_config) end puts "Enter a script comment. This comment will be prepended to each" puts "generated script exactly as given here." script_comment = get_user_input_block('script comment').extend(LiteralYamlStyle) schema_config.dbinfo['script comment'] = script_comment if script_comment != '' schema_config.root_path.mkpath dbinfo_path.open('w') do |dbinfo_io| $xmigra_yamler.dump(schema_config.dbinfo, dbinfo_io) end schema_config.created_file! dbinfo_path schema_config.run_steps_after_dbinfo_creation! return schema_config.created_files end |
#dbinfo_path ⇒ Object
40 41 42 |
# File 'lib/xmigra/source_tree_initializer.rb', line 40 def dbinfo_path @root_path + SchemaManipulator::DBINFO_FILE end |
#get_user_input_block(input_type) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/xmigra/source_tree_initializer.rb', line 44 def get_user_input_block(input_type) puts "Input ends on a line containing nothing but a single '.'." "".tap do |result| while (line = $stdin.gets).strip != '.' result << line end end end |
#vcs_system ⇒ Object
53 54 55 56 57 |
# File 'lib/xmigra/source_tree_initializer.rb', line 53 def vcs_system @vcs_system ||= VersionControlSupportModules.find do |m| m.manages(@root_path) end end |