Sha256: 2eba3a4effa0ad850661da615fda79c743083afa239e1c27008a4ab65202c9ae
Contents?: true
Size: 977 Bytes
Versions: 18
Compression:
Stored size: 977 Bytes
Contents
#!/usr/bin/env ruby $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'optparse' require 'rewritten' require 'multi_json' options = { :drop => false } op = OptionParser.new do |opts| opts.banner = "Usage: rewriten-dump.rb [options]" opts.on("-v", "--verbose", "be more verbose") do |v| options[:verbose] = v end opts.on("-f", "--file FILE", 'input file') do |o| options[:file] = o end opts.on("-u", "--uri URI", 'uri to the redis db') do |uri| options[:uri] = uri end opts.on("-d", "--drop", 'drop translations first') do options[:drop] = true end end op.parse! unless options[:file] puts op exit end Rewritten.redis = options[:uri] if options[:uri] Rewritten.clear_translations if options[:drop] File.open(options[:file]).each do |line| next if line =~ /^#/ from,to = line.split(";") puts "adding #{from} -> #{to}" if options[:verbose] Rewritten.add_translation(from,to.chomp) end
Version data entries
18 entries across 18 versions & 1 rubygems