Module: RubyAPI

Defined in:
lib/ruby_api.rb,
lib/ruby_api/config.rb,
lib/ruby_api/request.rb,
lib/ruby_api/version.rb,
lib/ruby_api/cli/main.rb,
lib/ruby_api/response.rb,
lib/ruby_api/operation.rb,
lib/ruby_api/cli/server.rb,
lib/ruby_api/application.rb,
lib/ruby_api/cli/generate.rb

Overview

RubyAPI

Defined Under Namespace

Modules: Cli Classes: Application, Config, Operation, Request, Response

Constant Summary collapse

CONFIG_DIR =
'config'
CONFIG_FILE =
'app.yml'
BOOT_SCRIPT =
'boot'
VERSION =
'1.0.3'

Class Method Summary collapse

Class Method Details

.application(root, overrides = {}) ⇒ Object



24
25
26
27
# File 'lib/ruby_api.rb', line 24

def self.application(root, overrides = {})
  @root = root
  Application.new(config(overrides)).boot
end

.config(overrides = {}) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/ruby_api.rb', line 29

def self.config(overrides = {})
  path = overrides[:config_file]
  path ||= File.join CONFIG_DIR, CONFIG_FILE
  path = path(path)
  raise "Config missing at #{path}" unless File.exist?(path)
  Config.new YAML.load_file(path)
end

.development?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/ruby_api.rb', line 53

def self.development?
  %w[development test].include? environment
end

.environmentObject



49
50
51
# File 'lib/ruby_api.rb', line 49

def self.environment
  ENV['RACK_ENV'] || 'development'
end

.path(path) ⇒ Object



45
46
47
# File 'lib/ruby_api.rb', line 45

def self.path(path)
  File.join @root, path
end

.rootObject



41
42
43
# File 'lib/ruby_api.rb', line 41

def self.root
  @root
end

.root=(path) ⇒ Object



37
38
39
# File 'lib/ruby_api.rb', line 37

def self.root=(path)
  @root = path
end