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

Version Path
rewritten-0.15.2 bin/rewritten-import.rb
rewritten-0.15.1 bin/rewritten-import.rb
rewritten-0.15.0 bin/rewritten-import.rb
rewritten-0.14.2 bin/rewritten-import.rb
rewritten-0.14.1 bin/rewritten-import.rb
rewritten-0.14.0 bin/rewritten-import.rb
rewritten-0.13.1 bin/rewritten-import.rb
rewritten-0.13.0 bin/rewritten-import.rb
rewritten-0.12.1 bin/rewritten-import.rb
rewritten-0.12.0 bin/rewritten-import.rb
rewritten-0.11.1 bin/rewritten-import.rb
rewritten-0.11.0 bin/rewritten-import.rb
rewritten-0.10.0 bin/rewritten-import.rb
rewritten-0.9.1 bin/rewritten-import.rb
rewritten-0.9.0 bin/rewritten-import.rb
rewritten-0.8.2 bin/rewritten-import.rb
rewritten-0.8.1 bin/rewritten-import.rb
rewritten-0.8.0 bin/rewritten-import.rb