Module: Lurker

Defined in:
lib/lurker/endpoint.rb,
lib/lurker.rb,
lib/lurker/cli.rb,
lib/lurker/spy.rb,
lib/lurker/json.rb,
lib/lurker/utils.rb,
lib/lurker/server.rb,
lib/lurker/request.rb,
lib/lurker/sandbox.rb,
lib/lurker/version.rb,
lib/lurker/response.rb,
lib/lurker/validator.rb,
lib/lurker/json/parser.rb,
lib/lurker/json/reader.rb,
lib/lurker/json/schema.rb,
lib/lurker/json/writer.rb,
lib/lurker/form_builder.rb,
lib/lurker/json/orderer.rb,
lib/lurker/json/schema/list.rb,
lib/lurker/validation_error.rb,
lib/lurker/json/schema/tuple.rb,
lib/lurker/spec_helper/rails.rb,
lib/lurker/erb_schema_context.rb,
lib/lurker/json/schema/object.rb,
lib/lurker/rendering_controller.rb,
lib/lurker/json/parser/expertise.rb,
lib/lurker/json/schema/attribute.rb,
lib/lurker/json/schema/polymorph.rb,
lib/lurker/json/schema/reference.rb,
lib/lurker/json/schema/extensions.rb,
lib/lurker/json/schema/tuple/all_of.rb,
lib/lurker/json/schema/tuple/any_of.rb,
lib/lurker/json/schema/tuple/one_of.rb,
lib/lurker/json/concerns/validatable.rb,
lib/lurker/json/parser/plain_strategy.rb,
lib/lurker/json/parser/typed_strategy.rb,
lib/lurker/json/schema/response_codes.rb

Overview

Endpoints represent the schema for an API endpoint The #consume_* methods will raise exceptions if input differs from the schema

Defined Under Namespace

Modules: Json, SpecHelper, Utils Classes: BasePresenter, Cli, Endpoint, EndpointPresenter, ErbSchemaContext, FormBuilder, JamlDescriptor, JsonPresenter, NotFound, RefObject, RenderingController, Request, Response, ResponseCodePresenter, Sandbox, SchemaPresenter, Server, Service, ServicePresenter, Spy, UndocumentedResponseCode, ValidationError, Validator

Constant Summary collapse

DEFAULT_SERVICE_PATH =
DEFAULT_URL_BASE = "lurker".freeze
LURKER_UPGRADE =
"LURKER_UPGRADE".freeze
BUNDLED_TEMPLATES_PATH =
Pathname.new('../templates').expand_path(__FILE__)
BUNDLED_ASSETS_PATH =
Pathname.new('../templates/public').expand_path(__FILE__)
VERSION =
"0.6.12"

Class Method Summary collapse

Class Method Details

.decide_success(*args) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/lurker.rb', line 43

def self.decide_success(*args)
  if @success_block
    @success_block.call(*args)
  else
    true
  end
end

.decide_success_with(&block) ⇒ Object



39
40
41
# File 'lib/lurker.rb', line 39

def self.decide_success_with(&block)
  @success_block = block
end

.safe_require(gem, desc = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/lurker.rb', line 7

def self.safe_require(gem, desc=nil)
  begin
    require gem
  rescue LoadError => e
    $stderr.puts(e.message)
    $stderr.puts(desc) if desc
    $stderr.puts("Please, bundle `gem #{gem}` in your Gemfile")
    exit 1 unless block_given?
  end
  yield if block_given?
end

.serviceObject



35
36
37
# File 'lib/lurker.rb', line 35

def self.service
  @service ||= Lurker::Service.new(service_path)
end

.service_pathObject



27
28
29
# File 'lib/lurker.rb', line 27

def self.service_path
  @service_path || DEFAULT_SERVICE_PATH
end

.service_path=(service_path) ⇒ Object



23
24
25
# File 'lib/lurker.rb', line 23

def self.service_path=(service_path)
  @service_path = service_path
end

.upgrade?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/lurker.rb', line 19

def self.upgrade?
  !!ENV[LURKER_UPGRADE]
end

.valid_service_path?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/lurker.rb', line 31

def self.valid_service_path?
  Dir.exist? service_path
end