Sha256: acb41eb90b87e219e4746edc93617f715ff8a8222d5c714a6647e94f15c29e42

Contents?: true

Size: 972 Bytes

Versions: 6

Compression:

Stored size: 972 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

6 entries across 6 versions & 1 rubygems

Version Path
rewritten-0.16.5 bin/rewritten-import.rb
rewritten-0.16.4 bin/rewritten-import.rb
rewritten-0.16.3 bin/rewritten-import.rb
rewritten-0.16.2 bin/rewritten-import.rb
rewritten-0.16.1 bin/rewritten-import.rb
rewritten-0.16.0 bin/rewritten-import.rb