Enable Style/DocumentationMethod cop
This commit is contained in:
@@ -11,6 +11,7 @@ module Calligraphy
|
||||
attr_reader :full_request_path, :mount_point, :request_body, :request_path,
|
||||
:root_dir
|
||||
|
||||
#:nodoc:
|
||||
def initialize(resource: nil, req: nil, mount: nil, root_dir: nil)
|
||||
@full_request_path = req&.original_url
|
||||
@mount_point = mount || req&.path&.tap { |s| s.slice! resource }
|
||||
|
||||
@@ -1,44 +1,53 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Calligraphy
|
||||
# Miscellaneous convenience methods.
|
||||
# Miscellaneous general convenience methods.
|
||||
module Utils
|
||||
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
|
||||
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].freeze
|
||||
|
||||
# Determines if a value is truthy.
|
||||
def true?(val)
|
||||
TRUE_VALUES.include? val
|
||||
end
|
||||
|
||||
# Determines if a value is falsy.
|
||||
def false?(val)
|
||||
FALSE_VALUES.include? val
|
||||
end
|
||||
|
||||
# Joins paths.
|
||||
def join_paths(*paths)
|
||||
paths.join '/'
|
||||
end
|
||||
|
||||
# Given a path and separator, splits the path string using the separator
|
||||
# and pops off the last element of the split array.
|
||||
def split_and_pop(path:, separator: '/')
|
||||
path.split(separator)[0..-2]
|
||||
end
|
||||
|
||||
# Determines if object exists and if existing object is of a given type.
|
||||
def obj_exists_and_is_not_type?(obj:, type:)
|
||||
obj.nil? ? false : obj != type
|
||||
end
|
||||
|
||||
# Given an array of hashes, returns an array of hash values.
|
||||
def map_array_of_hashes(arr_hashes)
|
||||
[].tap do |output_array|
|
||||
arr_hashes.each do |hash|
|
||||
output_array.push(hash.map { |_k, v| v })
|
||||
output_array.push hash.values
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Extracts a lock token from an If headers.
|
||||
def extract_lock_token(if_header)
|
||||
token = if_header.scan(Calligraphy::LOCK_TOKEN_REGEX)
|
||||
token.flatten.first if token.is_a? Array
|
||||
end
|
||||
|
||||
# Hash used in describing a supportedlock.
|
||||
def lockentry_hash(scope, type)
|
||||
{ lockentry: { lockscope: scope, locktype: type } }
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ module Calligraphy
|
||||
attr_accessor :resource, :response
|
||||
attr_reader :headers, :request
|
||||
|
||||
#:nodoc:
|
||||
def initialize(headers:, request:, response:, resource:)
|
||||
@headers = headers
|
||||
@request = request
|
||||
|
||||
@@ -10,6 +10,7 @@ module Calligraphy
|
||||
|
||||
desc 'Creates a Calligraphy initializer for your application'
|
||||
|
||||
#:nodoc:
|
||||
def copy_initializer
|
||||
template 'calligraphy.rb', 'config/initializers/calligraphy.rb'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user