class Zeli

Constants

VERSION

Attributes

headers[RW]
options[RW]
url[RW]

Public Class Methods

load(filepath) click to toggle source
# File lib/zeli.rb, line 26
def self.load(filepath)
  raw_curl = File.read(filepath)
  parser = Parser.new(raw_curl, new)
  parser.go!
end
new() click to toggle source
# File lib/zeli.rb, line 21
def initialize
  @options = []
  @headers = {}
end

Public Instance Methods

data() click to toggle source
# File lib/zeli.rb, line 44
def data
  option = options.find { |o| o.name == '--data' }

  if !option.nil?
    option.value
  end
end
request_type() click to toggle source
# File lib/zeli.rb, line 32
def request_type
  return :get if options.empty?

  option = options.find { |o| o.name == '-X' }

  if !option.nil?
    option.value.downcase.to_sym
  else
    :get
  end
end
to_s() click to toggle source
# File lib/zeli.rb, line 52
def to_s
  curl = ["curl #{url}"]

  @options.each do |option|
    curl << "  #{option}"
  end

  @headers.each do |k, v|
    curl << "  --header \"#{[k, v].join(': ')}\""
  end

  curl.join("\\\n")
end