lib/flextures/flextures.rb in flextures-4.1.0 vs lib/flextures/flextures.rb in flextures-4.2.0
- old
+ new
@@ -28,19 +28,19 @@
# load configuration file, if file is exist
def self.load_configurations
if defined?(Rails) and Rails.root
[
- File.join( Rails.root.to_path,"/config/flextures.factory.rb" ),
+ File.join(Rails.root.to_path, "/config/flextures.factory.rb"),
].each { |fn| File.exist?(fn) && load(fn) }
end
end
# @return [Array] flextures useable table names
def self.deletable_tables
tables = ActiveRecord::Base.connection.tables
- Flextures::Configuration.ignore_tables.each { |name| tables.delete( name.to_s ) }
+ Flextures::Configuration.ignore_tables.each { |name| tables.delete(name.to_s) }
tables
end
# initialize table data
def self.init_tables
@@ -93,23 +93,23 @@
end
end
table_names = Flextures::deletable_tables.map{ |name| { table: name, file: name } } if table_names.empty?
- # parse env["FIXTURES"] paameter
+ # parse env["FIXTURES"] parameter
fixtures_args_parser = ->(s){
names = s.split(',')
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
}
# parse filename and define parameters.
- table_names = fixtures_args_parser.call env["FIXTURES"] if env["FIXTURES"]
- table_names = fixtures_args_parser.call env["FILE"] if env["FILE"]
- table_names = fixtures_args_parser.call env["F"] if env["F"]
+ table_names = fixtures_args_parser.call(env["FIXTURES"]) if env["FIXTURES"]
+ 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"]
table_names = table_names.map{ |option| option.merge(minus: env["MINUS"].to_s.split(",")) } if env["MINUS"]
@@ -125,10 +125,12 @@
table_names
end
# check exist filename block
def self.exist
- return->(name){ File.exists?(File.join(Flextures::Configuration.load_directory, "#{name}.csv")) or
- File.exists?(File.join(Flextures::Configuration.load_directory, "#{name}.yml")) }
+ return ->(name) {
+ File.exist?(File.join(Flextures::Configuration.load_directory, "#{name}.csv")) or
+ File.exist?(File.join(Flextures::Configuration.load_directory, "#{name}.yml"))
+ }
end
end
end