lib/flextures/flextures.rb in flextures-2.0.2 vs lib/flextures/flextures.rb in flextures-2.0.3
- old
+ new
@@ -93,27 +93,36 @@
module ARGS
# 書き出し 、読み込み すべきファイルとオプションを書きだす
def self.parse option={}
table_names = []
if ENV["T"] or ENV["TABLE"]
- table_names = (ENV["T"] or ENV["TABLE"]).split(',').map{ |name| { table: name } }
+ table_names = (ENV["T"] or ENV["TABLE"]).split(',').map{ |name| { table: name, file: name } }
end
if ENV["M"] or ENV["MODEL"]
- table_names = (ENV["M"] or ENV["MODEL"]).split(',').map{ |name| { table: name.constantize.table_name } }
+ table_names = (ENV["M"] or ENV["MODEL"]).split(',').map do |name|
+ name = name.constantize.table_name
+ { table: name, file: name }
+ end
end
- if table_names.empty?
- table_names = Flextures::deletable_tables.map{ |table| { table: table } }
- end
+
+ table_names = Flextures::deletable_tables.map{ |table| { table: table } } if table_names.empty?
+
# ENV["FIXTURES"]の中身を解析
fixtures_args_parser =->(s){
names = s.split(',')
- ( names.size==1 and ENV.values_at("M", "MODEL", "T", "TABLE").first ) ?
- [ table_names.first.merge( file: names.first ) ] :
+ if ENV["TABLE"] or ENV["T"] or ENV["MODEL"] or ENV["M"]
+ [ table_names.first.merge( file: names.first ) ]
+ else
names.map{ |name| { table: name, file: name } }
+ end
}
+ # ファイル名を調整
table_names = fixtures_args_parser.call ENV["FIXTURES"] if ENV["FIXTURES"]
- table_names = fixtures_args_parser.call ENV["F"] if ENV["F"]
+ table_names = fixtures_args_parser.call ENV["FILE"] if ENV["FILE"]
+ table_names = fixtures_args_parser.call ENV["F"] if ENV["F"]
+
table_names = table_names.map{ |option| option.merge dir: ENV["DIR"] } if ENV["DIR"]
+ table_names = table_names.map{ |option| option.merge dir: ENV["D"] } if ENV["D"]
# read mode だとcsvもyaml存在しないファイルは返さない
table_names.select! &exist if option[:mode] && option[:mode] == 'read'
table_names
end