Module: Rigrate
- Defined in:
- lib/rigrate.rb,
lib/rigrate/error.rb,
lib/rigrate/parser.rb,
lib/rigrate/migration.rb,
lib/rigrate/data_source.rb,
lib/rigrate/interface/row.rb,
lib/rigrate/interface/mysql.rb,
lib/rigrate/interface/driver.rb,
lib/rigrate/interface/oracle.rb,
lib/rigrate/interface/sqlite.rb,
lib/rigrate/interface/result_set.rb
Defined Under Namespace
Modules: Migration, RowStatus
Classes: BasicError, Column, DataSource, DirverError, Driver, InterfaceError, MutiOutput, Mysql, Oracle, Parser, ParserError, ResultSet, ResultSetError, RigrateError, Row, Sqlite
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
90
91
92
|
# File 'lib/rigrate.rb', line 90
def self.config
@config
end
|
82
83
84
85
86
87
88
|
# File 'lib/rigrate.rb', line 82
def self.configure(opts)
opts.each do |k, v|
raise ParserError.new("arguments #{k} not valid.") unless config.keys.include? k.to_sym
end
config.merge! opts
end
|
.logger ⇒ Object
73
74
75
76
77
78
79
80
|
# File 'lib/rigrate.rb', line 73
def self.logger
logger_file = File.open(File.join(config[:logpath],logger_name), 'a')
@log = Logger.new MutiOutput.new(logger_file, config[:stdout])
@log.level = config[:loglevel]
@log
end
|
.logger_name ⇒ Object
94
95
96
|
# File 'lib/rigrate.rb', line 94
def self.logger_name
"#{Time.now.strftime('%Y-%m-%d')}.log"
end
|
.run(opts = {}) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/rigrate.rb', line 47
def self.run(opts = {})
scripts = []
configure(opts)
scripts << opts[:script] if opts[:script]
scripts << File.read(opts[:file]) if opts[:file]
if Dir.exist? opts[:dir].to_s
Dir["#{File.join(opts[:dir], '*')}"].each do |item|
scripts << File.read(item)
end
end
raise RigrateError.new("your should specify one script at least.") if scripts.size <= 0
parser = Parser.new
if File.exist? config[:ds]
parser.lex(File.read(config[:ds])).parsing
end
scripts.each do |script|
parser.lex(script).parsing
end
end
|