Sha256: 7b351fdae0a0473b45d3d8ea8c0e10418e14b5a971b70dceff3c916cc73d6872
Contents?: true
Size: 1.86 KB
Versions: 9
Compression:
Stored size: 1.86 KB
Contents
#!/usr/bin/env ruby require 'rubygems' require 'optparse' require 'blueprints' require 'blueprints/convertable' options = {} optparse = OptionParser.new do |opts| opts.on('-s','--source-files=PATTERN', 'Define pattern for source files (used by Dir.glob)') do |files| options[:source_files] = files end opts.on('-o', '--output-file=FILE', 'Define output file for converted data (used by Dir.glob)') do |file| options[:output_file] = file end opts.on('-h', '--help', 'Show help (this screen)') do puts opts exit end opts.banner = "Usage: #{File.basename($0)} format --source-files=PATTERN --output-file=blueprints.rb\n" end begin optparse.parse! rescue OptionParser::ParseError => error puts error puts optparse.banner exit end format = ARGV.shift unless [:fixtures, :factory_girl].include?(format.to_sym) puts "Invalid format: #{format}" puts "Supported formats are: fixtures, factory_girl" puts optparse.banner exit end if format converter = Blueprints::Converter.for(format).new(options) converter.process! else # require 'pp' # pp optparse puts optparse.banner end # fixture_files = Dir.glob('{spec,test}/fixtures/**/*.yml') # # def parameterize(object) # if object.is_a?(String) # %Q(#{object}).inspect # elsif object.nil? # 'nil' # else # object.to_s # end # end # # fixture_files.each do |fixture_file| # puts "Processing #{fixture_files}..." # # klass = File.basename(fixture_file, '.yml').singularize.capitalize # # loaded_yaml = YAML.load(File.read(fixture_file)) # # blueprints = loaded_yaml.collect do |title,yaml_obj| # params = yaml_obj.collect do |k,v| # ":#{k} => #{parameterize(v)}" # end.join(', ') # # "#{klass}.blueprint(:#{title}, {#{params}})" # end # # puts "Created #{blueprints.size} blueprints: #{loaded_yaml.keys.join(', ')}." # end
Version data entries
9 entries across 9 versions & 1 rubygems