Sha256: 54742f8d0b7402b85d2cdfae55eb65c5c3c0840201e5d2c1f5766e02b5df1f94

Contents?: true

Size: 890 Bytes

Versions: 11

Compression:

Stored size: 890 Bytes

Contents

require 'rbkb/cli'

# Copyright 2009 emonti at matasano.com 
# See README.rdoc for license information
#
# urldec converts a url percent-encoded string back to its raw form.
# Input can be supplied via stdin, a string argument, or a file (with -f).
# (url percent-encoding is just fancy hex encoding)
class Rbkb::Cli::Urldec < Rbkb::Cli::Executable
  def make_parser()
    super()
    add_std_file_opt(:indat)
    arg = @oparse
    arg.banner += " <data | blank for stdin>"

    arg.on("-p", "--[no-]plus", "Convert '+' to space (default: true)") do |p|
      @opts[:noplus] = (not p)
    end
  end

  def parse(*args)
    super(*args)
    parse_string_argument(:indat)
    parse_catchall()
  end

  def go(*args)
    super(*args)
    # Default to standard input
    @opts[:indat] ||= @stdin.read()
    @stdout << @opts[:indat].urldec(:noplus => @opts[:noplus])
    self.exit(0)
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
emonti-rbkb-0.6.6 lib/rbkb/cli/urldec.rb
emonti-rbkb-0.6.7 lib/rbkb/cli/urldec.rb
emonti-rbkb-0.6.8 lib/rbkb/cli/urldec.rb
emonti-rbkb-0.6.9.1 lib/rbkb/cli/urldec.rb
emonti-rbkb-0.6.9 lib/rbkb/cli/urldec.rb
rbkb-0.7.2 lib/rbkb/cli/urldec.rb
rbkb-0.7.1 lib/rbkb/cli/urldec.rb
rbkb-0.7.0 lib/rbkb/cli/urldec.rb
rbkb-0.6.12 lib/rbkb/cli/urldec.rb
rbkb-0.6.11 lib/rbkb/cli/urldec.rb
rbkb-0.6.10 lib/rbkb/cli/urldec.rb