Module: R2OAS::Configuration

Extended by:
AppConfiguration, PluggableConfiguration
Included in:
R2OAS
Defined in:
lib/r2-oas/configuration.rb,
lib/r2-oas/configuration/paths_config.rb

Defined Under Namespace

Classes: PathsConfig

Constant Summary collapse

PUBLIC_VALID_OPTIONS_KEYS =
AppConfiguration::VALID_OPTIONS_KEYS + PluggableConfiguration::VALID_OPTIONS_KEYS
UNPUBLIC_VALID_OPTIONS_KEYS =
%i[
  paths_config
  logger
].freeze
VALID_OPTIONS_KEYS =
PUBLIC_VALID_OPTIONS_KEYS + UNPUBLIC_VALID_OPTIONS_KEYS

Constants included from AppConfiguration

AppConfiguration::DEFAULT_DEPLOY_DIR_PATH, AppConfiguration::DEFAULT_DEPRECATION, AppConfiguration::DEFAULT_DOC_SAVE_FILE_NAME, AppConfiguration::DEFAULT_FORCE_UPDATE_SCHEMA, AppConfiguration::DEFAULT_HTTP_METHODS_WHEN_GENERATE_REQUEST_BODY, AppConfiguration::DEFAULT_HTTP_STATUSES_WHEN_HTTP_METHOD, AppConfiguration::DEFAULT_IGNORED_HTTP_STATUSES_WHEN_GENERATE_COMPONENT_SCHEMA, AppConfiguration::DEFAULT_INTERVAL_TO_SAVE_EDITED_TMP_SCHEMA, AppConfiguration::DEFAULT_LOCAL_PLUGINS_DIR_NAME, AppConfiguration::DEFAULT_LOCAL_TASKS_DIR_NAME, AppConfiguration::DEFAULT_NAMESPACE_TYPE, AppConfiguration::DEFAULT_OUTPUT_PATH, AppConfiguration::DEFAULT_ROOT_DIR_PATH, AppConfiguration::DEFAULT_SCHEMA_SAVE_DIR_NAME, AppConfiguration::DEFAULT_SERVER, AppConfiguration::DEFAULT_SWAGGER, AppConfiguration::DEFAULT_USE_SCHEMA_NAMESPACE, AppConfiguration::DEFAULT_USE_TAG_NAMESPACE, AppConfiguration::DEFAULT_VERSION, AppConfiguration::EDFAULT_PLUGINS

Constants included from PluggableConfiguration

PluggableConfiguration::DEFAULT_USE_OBJECT_CLASSES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AppConfiguration

set_default

Class Method Details

.extended(base) ⇒ Object



36
37
38
39
# File 'lib/r2-oas/configuration.rb', line 36

def self.extended(base)
  base.send :set_default_for_configuration, base
  base.send :set_default_for_pluggable, base
end

Instance Method Details

#app_configuration_optionsObject



60
61
62
63
64
# File 'lib/r2-oas/configuration.rb', line 60

def app_configuration_options
  AppConfiguration::VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



41
42
43
44
# File 'lib/r2-oas/configuration.rb', line 41

def configure
  yield self if block_given?
  load_local_plugins
end

#initObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/r2-oas/configuration.rb', line 76

def init
  plugins_path = File.expand_path("#{root_dir_path}/#{local_plugins_dir_name}")
  plugins_helpers_path = "#{plugins_path}/helpers"
  tasks_path = File.expand_path("#{root_dir_path}/#{local_tasks_dir_name}")
  tasks_helpers_path = "#{tasks_path}/helpers"

  gitkeep_plugins_path = "#{plugins_path}/.gitkeep"
  gitkeep_plugins_helpers_path = "#{plugins_helpers_path}/.gitkeep"
  gitkeep_tasks_path = "#{tasks_path}/.gitkeep"
  gitkeep_tasks_helpers_path = "#{tasks_helpers_path}/.gitkeep"

  FileUtils.mkdir_p(plugins_helpers_path) unless FileTest.exists?(plugins_helpers_path)
  FileUtils.mkdir_p(tasks_helpers_path) unless FileTest.exists?(tasks_helpers_path)

  File.write(gitkeep_plugins_path, '') unless FileTest.exists?(gitkeep_plugins_path)
  File.write(gitkeep_plugins_helpers_path, '') unless FileTest.exists?(gitkeep_plugins_helpers_path)
  File.write(gitkeep_tasks_path, '') unless FileTest.exists?(gitkeep_tasks_path)
  File.write(gitkeep_tasks_helpers_path, '') unless FileTest.exists?(gitkeep_tasks_helpers_path)
  paths_config.create_dot_paths
end

#load_tasksObject



72
73
74
# File 'lib/r2-oas/configuration.rb', line 72

def load_tasks
  load_local_tasks
end

#loggerObject



52
53
54
# File 'lib/r2-oas/configuration.rb', line 52

def logger
  @_stdout_logger ||= StdoutLogger.new
end

#optionsObject



46
47
48
49
50
# File 'lib/r2-oas/configuration.rb', line 46

def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end

#output_dir_pathObject



97
98
99
# File 'lib/r2-oas/configuration.rb', line 97

def output_dir_path
  output_path.to_s.split('/').slice(0..-2).join('/')
end

#paths_configObject



56
57
58
# File 'lib/r2-oas/configuration.rb', line 56

def paths_config
  @_paths_config ||= PathsConfig.new(root_dir_path, schema_save_dir_name)
end

#pluggable_configuration_optionsObject



66
67
68
69
70
# File 'lib/r2-oas/configuration.rb', line 66

def pluggable_configuration_options
  PluggableConfiguration::VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end

#use_object_classes=(data) ⇒ Object

MEMO: override because deprecated



28
29
30
31
32
33
34
# File 'lib/r2-oas/configuration.rb', line 28

def use_object_classes=(data)
  ::R2OAS::Deprecation.will_remove(<<-MSG.squish)
    Using a R2OAS.use_object_classes= in configuration is deprecated and
    will be removed in r2-oas (v0.4.2).
  MSG
  @use_object_classes = data
end