Sha256: de0acc12c03ee17365e2c04807a25a1581894b547c889ee71a3f5999374085fb

Contents?: true

Size: 1.8 KB

Versions: 5

Compression:

Stored size: 1.8 KB

Contents

Apipie.configure do |config|
  config.app_name = "Test app"
  config.copyright = "© 2012 Pavel Pokorny"
  config.doc_base_url = "/apidoc"
  config.api_base_url = "/api"

  # set to true to turn on/off the cache. To generate the cache use:
  #
  #     rake apipie:cache
  #
  # config.use_cache = Rails.env.production?
  # config.cache_dir = File.join(Rails.root, "public", "apipie-cache") # optional

  # set to enable/disable reloading controllers (and the documentation with it),
  # by default enabled in development
  # config.reload_controllers = false

  # for reloading to work properly you need to specify where your api controllers are (like in Dir.glob):
  config.api_controllers_matcher = File.join(Rails.root, "app", "controllers", "**","*.rb")

  # config.api_base_url = "/api"
  # config.markup = choose one of:
  #   Apipie::Markup::RDoc.new [default]
  #   Apipie::Markup::Markdown.new
  #   Apipie::Markup::Textile.new
  # or provide another class with to_html(text) instance method
  # config.validate = false

  path = File.expand_path(File.dirname(__FILE__)+'/../../../../README.rdoc')
  config.app_info = File.read(path)
end


# integer validator
class Apipie::Validator::IntegerValidator < Apipie::Validator::BaseValidator

  def initialize(param_description, argument)
    super(param_description)
    @type = argument
  end

  def validate(value)
    return false if value.nil?
    !!(value.to_s =~ /^[-+]?[0-9]+$/)
  end

  def self.build(param_description, argument, options, block)
    if argument == Integer || argument == Fixnum
      self.new(param_description, argument) 
    end
  end

  def error
    "Parameter #{param_name} expecting to be #{@type.name}, got: #{@error_value.class.name}"
  end

  def description
    "Parameter has to be #{@type}."
  end
  
  def expected_type
    'numeric'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
apipie-rails-0.0.11 spec/dummy/config/initializers/apipie.rb
apipie-rails-0.0.10 spec/dummy/config/initializers/apipie.rb
apipie-rails-0.0.9 spec/dummy/config/initializers/apipie.rb
apipie-rails-0.0.8 spec/dummy/config/initializers/apipie.rb
apipie-rails-0.0.7 spec/dummy/config/initializers/apipie.rb