<commit_before>require 'addressable/template'
require 'rest-client'
require 'json'

module Foaas
  class Client

  	URL = Addressable::Template.new("http://foaas.com/{method}{/name}/{from}{/other}")

    METHODS_ONE_PARAM = [:awesome, :because, :bye, :cool, :diabetes, :everyone, :everything, :fascinating, :flying, :life, :pink, :thanks, :this, :what]
    METHODS_TWO_PARAMS = [:bus, :donut, :caniuse, :chainsaw, :dalton, :king, :linus, :madison, :nugget, :off, :outside, :shakespeare, :you, :xmas, :yoda]
    METHODS_THREE_PARAMS = [:ballmer, :field]

    def method_missing(sym, *args, **kwargs, &block)
        if METHODS_TWO_PARAMS.include? sym
          make_request(URL.expand(method: sym, name: args[0], from: args[1]), args[2], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
        elsif  METHODS_ONE_PARAM.include? sym
          make_request(URL.expand(method: sym, from: args[0]), args[1], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
        elsif METHODS_THREE_PARAMS.include? sym
          make_request(URL.expand(method: sym, name: args[0], from: args[1], other: args[2]), args[3], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
        elsif sym == :thing
          make_request(URL.expand(method: args[0], from: args[1]), args[2], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
        else
          super(sym, *args, **kwargs, &block)
        end
    end

    def operations
      make_request(URL.expand(method: :operations), nil)
    end

    def respond_to?(sym, include_private = false)
      METHODS_ONE_PARAM.include?(sym) or METHODS_TWO_PARAMS.include?(sym) or sym == :thing or super(sym, include_private)
    end

    def version(type = nil)
      make_request(URL.expand(method: :version), type)
    end

  	private

  	def make_request(url, type, i18n=nil, shoutcloud=false)
      query_params = {}
      url = url.to_s
      accept_type = case type
        when nil
          :json
        when :text
          'text/plain'
        when :jsonp
          query_params['callback'] = 'fuck' 
          :json
        else
          type
      end<commit_msg>Change Foaas::Client#method_missing to be compatible with Ruby 1.9.3<commit_after>require 'addressable/template'
require 'rest-client'
require 'json'

module Foaas
  class Client

  	URL = Addressable::Template.new("http://foaas.com/{method}{/name}/{from}{/other}")

    METHODS_ONE_PARAM = [:awesome, :because, :bye, :cool, :diabetes, :everyone, :everything, :fascinating, :flying, :life, :pink, :thanks, :this, :what]
    METHODS_TWO_PARAMS = [:bus, :donut, :caniuse, :chainsaw, :dalton, :king, :linus, :madison, :nugget, :off, :outside, :shakespeare, :you, :xmas, :yoda]
    METHODS_THREE_PARAMS = [:ballmer, :field]

    def method_missing(sym, *args, &block)
        kwargs = {}
        kwargs = args[-1] if args[-1].class == Hash
        if METHODS_TWO_PARAMS.include? sym
          make_request(URL.expand(method: sym, name: args[0], from: args[1]), args[2], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
        elsif  METHODS_ONE_PARAM.include? sym
          make_request(URL.expand(method: sym, from: args[0]), args[1], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
        elsif METHODS_THREE_PARAMS.include? sym
          make_request(URL.expand(method: sym, name: args[0], from: args[1], other: args[2]), args[3], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
        elsif sym == :thing
          make_request(URL.expand(method: args[0], from: args[1]), args[2], i18n=kwargs[:i18n], shoutcloud=kwargs[:shoutcloud])
        else
          super(sym, *args, &block)
        end
    end

    def operations
      make_request(URL.expand(method: :operations), nil)
    end

    def respond_to?(sym, include_private = false)
      METHODS_ONE_PARAM.include?(sym) or METHODS_TWO_PARAMS.include?(sym) or sym == :thing or super(sym, include_private)
    end

    def version(type = nil)
      make_request(URL.expand(method: :version), type)
    end

  	private

  	def make_request(url, type, i18n=nil, shoutcloud=false)
      query_params = {}
      url = url.to_s
      accept_type = case type
        when nil
          :json
        when :text
          'text/plain'
        when :jsonp
          query_params['callback'] = 'fuck' 
          :json
        else
          type
      end
{'fraction_non_alphanumeric': 0.1420967368664661, 'fraction_numerical': 0.015042814163388105, 'mean_word_length': 3.3350050150451356, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3485262', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1470, 'n_words': 324}