Enable Style/DocumentationMethod cop
This commit is contained in:
@@ -16,3 +16,5 @@ Metrics/MethodLength:
|
|||||||
- 'lib/calligraphy/rails/mapper.rb'
|
- 'lib/calligraphy/rails/mapper.rb'
|
||||||
Style/ClassVars:
|
Style/ClassVars:
|
||||||
Enabled: False
|
Enabled: False
|
||||||
|
Style/DocumentationMethod:
|
||||||
|
Enabled: True
|
||||||
|
|||||||
2
Gemfile
2
Gemfile
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|||||||
63
Rakefile
Normal file → Executable file
63
Rakefile
Normal file → Executable file
@@ -1,64 +1,73 @@
|
|||||||
#!/usr/bin/env rake
|
#!/usr/bin/env rake
|
||||||
require "rake/clean"
|
# frozen_string_literal: true
|
||||||
require "rspec/core/rake_task"
|
|
||||||
|
|
||||||
task default: %w(spec litmus:run)
|
require 'rake/clean'
|
||||||
|
require 'rspec/core/rake_task'
|
||||||
|
require 'rubocop/rake_task'
|
||||||
|
|
||||||
desc "Run rspec tests"
|
task default: %w[spec litmus:run]
|
||||||
|
|
||||||
|
desc 'Run rspec tests'
|
||||||
RSpec::Core::RakeTask.new :spec
|
RSpec::Core::RakeTask.new :spec
|
||||||
|
|
||||||
desc "Run litmus test suite"
|
desc 'Run litmus test suite'
|
||||||
task :litmus => %w(litmus:run)
|
task litmus: %w[litmus:run]
|
||||||
|
|
||||||
|
desc 'Run Rubocop'
|
||||||
|
RuboCop::RakeTask.new :rubocop
|
||||||
|
|
||||||
namespace :litmus do
|
namespace :litmus do
|
||||||
tmp_dir = "#{Dir.pwd}/tmp"
|
tmp_dir = "#{Dir.pwd}/tmp"
|
||||||
litmus_archive = "#{tmp_dir}/litmus-0.13.tar.gz"
|
litmus_archive = "#{tmp_dir}/litmus-0.13.tar.gz"
|
||||||
|
|
||||||
desc "Fetch litmus test suite zip file"
|
desc 'Fetch litmus test suite zip file'
|
||||||
task :fetch do
|
task :fetch do
|
||||||
sh "mkdir tmp" unless File.directory? "#{tmp_dir}"
|
sh 'mkdir tmp' unless File.directory? tmp_dir.to_s
|
||||||
sh "mkdir tmp/webdav" unless File.directory? "#{tmp_dir}/webdav"
|
sh 'mkdir tmp/webdav' unless File.directory? "#{tmp_dir}/webdav"
|
||||||
|
|
||||||
unless File.exist? litmus_archive
|
unless File.exist? litmus_archive
|
||||||
sh "wget -O #{tmp_dir}/litmus-0.13.tar.gz https://github.com/eanlain/litmus/releases/download/v0.13/litmus-0.13.tar.gz"
|
litmus_url = 'https://github.com/eanlain/litmus/releases/download/v0.13/litmus-0.13.tar.gz'
|
||||||
|
sh "wget -O #{tmp_dir}/litmus-0.13.tar.gz #{litmus_url}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
CLEAN.include("tmp")
|
CLEAN.include('tmp')
|
||||||
|
|
||||||
desc "Unarchive litmus test suite zip file"
|
desc 'Unarchive litmus test suite zip file'
|
||||||
task :unarchive => :fetch do
|
task unarchive: :fetch do
|
||||||
unless File.directory? "#{Dir.pwd}/litmus-0.13"
|
unless File.directory? "#{Dir.pwd}/litmus-0.13"
|
||||||
sh "tar -xvzf #{tmp_dir}/litmus-0.13.tar.gz"
|
sh "tar -xvzf #{tmp_dir}/litmus-0.13.tar.gz"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
CLEAN.include("litmus-0.13")
|
CLEAN.include('litmus-0.13')
|
||||||
|
|
||||||
desc "Configure litmus test suite"
|
desc 'Configure litmus test suite'
|
||||||
task :configure => :unarchive do
|
task configure: :unarchive do
|
||||||
unless File.exist? "litmus-0.13/configured"
|
unless File.exist? 'litmus-0.13/configured'
|
||||||
sh "cd litmus-0.13 && ./configure"
|
sh 'cd litmus-0.13 && ./configure'
|
||||||
sh "cd litmus-0.13 && touch configured"
|
sh 'cd litmus-0.13 && touch configured'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "'make clean' litmus test suite"
|
desc "'make clean' litmus test suite"
|
||||||
task :make_clean do
|
task :make_clean do
|
||||||
sh "cd litmus-0.13 && make clean"
|
sh 'cd litmus-0.13 && make clean'
|
||||||
sh "rm litmus-0.13/configured"
|
sh 'rm litmus-0.13/configured'
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run litmus test suite"
|
desc 'Run litmus test suite'
|
||||||
task :run => :configure do
|
task run: :configure do
|
||||||
sh "cd spec/dummy/ && rails server -d"
|
sh 'cd spec/dummy/ && rails server -d'
|
||||||
sleep 1
|
sleep 1
|
||||||
puma_pid = `cat spec/dummy/tmp/pids/server.pid`
|
puma_pid = `cat spec/dummy/tmp/pids/server.pid`
|
||||||
exit_code = 0
|
exit_code = 0
|
||||||
|
|
||||||
begin
|
begin
|
||||||
sh "cd litmus-0.13 && make URL=http://localhost:3000/webdav/ CREDS='jon_deaux changeme!' check"
|
sh 'cd litmus-0.13 &&'\
|
||||||
rescue
|
' make URL=http://localhost:3000/webdav/'\
|
||||||
|
' CREDS=\'jon_deaux changeme!\' check'
|
||||||
|
rescue StandardError
|
||||||
exit_code = 1
|
exit_code = 1
|
||||||
puts "!!!!! Failure encountered during litmus test suite !!!!!"
|
puts '!!!!! Failure encountered during litmus test suite !!!!!'
|
||||||
end
|
end
|
||||||
|
|
||||||
sh "kill #{puma_pid}"
|
sh "kill #{puma_pid}"
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
lib = File.expand_path('../lib', __FILE__)
|
lib = File.expand_path('../lib', __FILE__)
|
||||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||||
|
|
||||||
@@ -13,7 +15,7 @@ Gem::Specification.new do |s|
|
|||||||
s.homepage = 'http://www.github.com/eanlain/calligraphy'
|
s.homepage = 'http://www.github.com/eanlain/calligraphy'
|
||||||
s.license = 'MIT'
|
s.license = 'MIT'
|
||||||
|
|
||||||
s.required_ruby_version = ">= 2.3.0"
|
s.required_ruby_version = '>= 2.3.0'
|
||||||
|
|
||||||
s.files = Dir['lib/**/*', 'LICENSE', 'README.md']
|
s.files = Dir['lib/**/*', 'LICENSE', 'README.md']
|
||||||
s.test_files = Dir['spec/**/*']
|
s.test_files = Dir['spec/**/*']
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ module Calligraphy
|
|||||||
attr_reader :full_request_path, :mount_point, :request_body, :request_path,
|
attr_reader :full_request_path, :mount_point, :request_body, :request_path,
|
||||||
:root_dir
|
:root_dir
|
||||||
|
|
||||||
|
#:nodoc:
|
||||||
def initialize(resource: nil, req: nil, mount: nil, root_dir: nil)
|
def initialize(resource: nil, req: nil, mount: nil, root_dir: nil)
|
||||||
@full_request_path = req&.original_url
|
@full_request_path = req&.original_url
|
||||||
@mount_point = mount || req&.path&.tap { |s| s.slice! resource }
|
@mount_point = mount || req&.path&.tap { |s| s.slice! resource }
|
||||||
|
|||||||
@@ -1,44 +1,53 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Calligraphy
|
module Calligraphy
|
||||||
# Miscellaneous convenience methods.
|
# Miscellaneous general convenience methods.
|
||||||
module Utils
|
module Utils
|
||||||
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
|
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
|
||||||
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].freeze
|
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE'].freeze
|
||||||
|
|
||||||
|
# Determines if a value is truthy.
|
||||||
def true?(val)
|
def true?(val)
|
||||||
TRUE_VALUES.include? val
|
TRUE_VALUES.include? val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Determines if a value is falsy.
|
||||||
def false?(val)
|
def false?(val)
|
||||||
FALSE_VALUES.include? val
|
FALSE_VALUES.include? val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Joins paths.
|
||||||
def join_paths(*paths)
|
def join_paths(*paths)
|
||||||
paths.join '/'
|
paths.join '/'
|
||||||
end
|
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: '/')
|
def split_and_pop(path:, separator: '/')
|
||||||
path.split(separator)[0..-2]
|
path.split(separator)[0..-2]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Determines if object exists and if existing object is of a given type.
|
||||||
def obj_exists_and_is_not_type?(obj:, type:)
|
def obj_exists_and_is_not_type?(obj:, type:)
|
||||||
obj.nil? ? false : obj != type
|
obj.nil? ? false : obj != type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Given an array of hashes, returns an array of hash values.
|
||||||
def map_array_of_hashes(arr_hashes)
|
def map_array_of_hashes(arr_hashes)
|
||||||
[].tap do |output_array|
|
[].tap do |output_array|
|
||||||
arr_hashes.each do |hash|
|
arr_hashes.each do |hash|
|
||||||
output_array.push(hash.map { |_k, v| v })
|
output_array.push hash.values
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Extracts a lock token from an If headers.
|
||||||
def extract_lock_token(if_header)
|
def extract_lock_token(if_header)
|
||||||
token = if_header.scan(Calligraphy::LOCK_TOKEN_REGEX)
|
token = if_header.scan(Calligraphy::LOCK_TOKEN_REGEX)
|
||||||
token.flatten.first if token.is_a? Array
|
token.flatten.first if token.is_a? Array
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Hash used in describing a supportedlock.
|
||||||
def lockentry_hash(scope, type)
|
def lockentry_hash(scope, type)
|
||||||
{ lockentry: { lockscope: scope, locktype: type } }
|
{ lockentry: { lockscope: scope, locktype: type } }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ module Calligraphy
|
|||||||
attr_accessor :resource, :response
|
attr_accessor :resource, :response
|
||||||
attr_reader :headers, :request
|
attr_reader :headers, :request
|
||||||
|
|
||||||
|
#:nodoc:
|
||||||
def initialize(headers:, request:, response:, resource:)
|
def initialize(headers:, request:, response:, resource:)
|
||||||
@headers = headers
|
@headers = headers
|
||||||
@request = request
|
@request = request
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ module Calligraphy
|
|||||||
|
|
||||||
desc 'Creates a Calligraphy initializer for your application'
|
desc 'Creates a Calligraphy initializer for your application'
|
||||||
|
|
||||||
|
#:nodoc:
|
||||||
def copy_initializer
|
def copy_initializer
|
||||||
template 'calligraphy.rb', 'config/initializers/calligraphy.rb'
|
template 'calligraphy.rb', 'config/initializers/calligraphy.rb'
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user