Class: Rpdoc::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rpdoc/configuration.rb

Constant Summary collapse

RSPEC_RESPONSE_IDENTIFIERS =
[:rspec_location, nil].freeze
RPDOC_FOLDER_ORDERING =
[:asc, :desc].freeze
RPDOC_AUTO_PUSH_STRATEGIES =
[:push_and_create, :push_and_update].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rpdoc/configuration.rb', line 35

def initialize
  @rpdoc_enable = ENV["RPDOC_ENABLE"] != "false"

  @postman_host = "https://api.getpostman.com"
  @postman_collection_path = "/collections"
  @postman_apikey = nil

  @collection_workspace = nil
  @collection_uid = nil
  @collection_name = "Rpdoc"
  @collection_schema = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"

  @rspec_root = "spec"
  @rspec_server_host = "{{server_host}}"
  @rspec_request_allow_headers = ["User-Agent", "Content-Type", "Authorization"]
  @rspec_response_allow_headers = ["Content-Type", "Content-Length", "Location"]
  @rspec_response_identifier = :rspec_location

  @rpdoc_root = "rpdoc"
  @rpdoc_request_filename = "request.json"
  @rpdoc_description_filename = "description.md"
  @rpdoc_collection_filename = "collection.json"

  @rpdoc_clean_empty_folders = true
  @rpdoc_clean_empty_folders_except = []
  @rpdoc_folder_ordering = []

  @rpdoc_auto_push = false
  @rpdoc_auto_push_strategy = :push_and_create
end

Instance Attribute Details

#collection_name ⇒ Object

Returns the value of attribute collection_name.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def collection_name
  @collection_name
end

#collection_schema ⇒ Object (readonly)

Returns the value of attribute collection_schema.



5
6
7
# File 'lib/rpdoc/configuration.rb', line 5

def collection_schema
  @collection_schema
end

#collection_uid ⇒ Object

Returns the value of attribute collection_uid.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def collection_uid
  @collection_uid
end

#collection_workspace ⇒ Object

Returns the value of attribute collection_workspace.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def collection_workspace
  @collection_workspace
end

#postman_apikey ⇒ Object

Returns the value of attribute postman_apikey.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def postman_apikey
  @postman_apikey
end

#postman_collection_path ⇒ Object (readonly)

Returns the value of attribute postman_collection_path.



5
6
7
# File 'lib/rpdoc/configuration.rb', line 5

def postman_collection_path
  @postman_collection_path
end

#postman_host ⇒ Object (readonly)

Returns the value of attribute postman_host.



5
6
7
# File 'lib/rpdoc/configuration.rb', line 5

def postman_host
  @postman_host
end

#rpdoc_auto_push ⇒ Object

Returns the value of attribute rpdoc_auto_push.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_auto_push
  @rpdoc_auto_push
end

#rpdoc_auto_push_strategy ⇒ Object

Returns the value of attribute rpdoc_auto_push_strategy.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_auto_push_strategy
  @rpdoc_auto_push_strategy
end

#rpdoc_clean_empty_folders ⇒ Object

Returns the value of attribute rpdoc_clean_empty_folders.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_clean_empty_folders
  @rpdoc_clean_empty_folders
end

#rpdoc_clean_empty_folders_except ⇒ Object

Returns the value of attribute rpdoc_clean_empty_folders_except.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_clean_empty_folders_except
  @rpdoc_clean_empty_folders_except
end

#rpdoc_collection_filename ⇒ Object

Returns the value of attribute rpdoc_collection_filename.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_collection_filename
  @rpdoc_collection_filename
end

#rpdoc_description_filename ⇒ Object

Returns the value of attribute rpdoc_description_filename.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_description_filename
  @rpdoc_description_filename
end

#rpdoc_enable ⇒ Object

Returns the value of attribute rpdoc_enable.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_enable
  @rpdoc_enable
end

#rpdoc_folder_ordering ⇒ Object

Returns the value of attribute rpdoc_folder_ordering.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_folder_ordering
  @rpdoc_folder_ordering
end

#rpdoc_request_filename ⇒ Object

Returns the value of attribute rpdoc_request_filename.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_request_filename
  @rpdoc_request_filename
end

#rpdoc_root ⇒ Object

Returns the value of attribute rpdoc_root.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rpdoc_root
  @rpdoc_root
end

#rspec_request_allow_headers ⇒ Object

Returns the value of attribute rspec_request_allow_headers.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rspec_request_allow_headers
  @rspec_request_allow_headers
end

#rspec_response_allow_headers ⇒ Object

Returns the value of attribute rspec_response_allow_headers.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rspec_response_allow_headers
  @rspec_response_allow_headers
end

#rspec_response_identifier ⇒ Object

Returns the value of attribute rspec_response_identifier.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rspec_response_identifier
  @rspec_response_identifier
end

#rspec_root ⇒ Object

Returns the value of attribute rspec_root.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rspec_root
  @rspec_root
end

#rspec_server_host ⇒ Object

Returns the value of attribute rspec_server_host.



10
11
12
# File 'lib/rpdoc/configuration.rb', line 10

def rspec_server_host
  @rspec_server_host
end

Instance Method Details

#valid? ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
72
73
74
75
# File 'lib/rpdoc/configuration.rb', line 66

def valid?
  return true unless @rpdoc_enable && @rpdoc_auto_push
  return false if @postman_apikey.nil?
  return false unless RSPEC_RESPONSE_IDENTIFIERS.include?(@rspec_response_identifier&.to_sym)
  return false unless RPDOC_AUTO_PUSH_STRATEGIES.include?(@rpdoc_auto_push_strategy.to_sym)
  return false if @rpdoc_auto_push_strategy == :push_and_update && @collection_uid.nil?
  return false if @rpdoc_folder_ordering.present? && (RPDOC_FOLDER_ORDERING.exclude?(@rpdoc_folder_ordering) || !@rpdoc_folder_ordering.is_a?(Array))

  true
end