Module: YardGhurt::Util
Overview
Utility methods in a separate module/mixin, so that a programmer can require/load a sole task:
require 'yard_ghurt/gfm_fix_task'
Else, programmers would be required to always require/load the entire yard_ghurt module:
require 'yard_ghurt'
All internal code should use this module.
External code can either use this module or YardGhurt, which includes this module as a mixin.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- TRUE_BOOLS =
Returns the lower-case Strings that will equal to
true. %w[1 on t true y yes].freeze
- SEM_VER_REGEX =
Returns a very flexible (non-strict) Semantic Versioning regex, ignoring pre-release/build-metadata.
/(?<major>\d+)(?:\.(?<minor>\d+))?(?:\.(?<patch>\d+))?/.freeze
Class Method Summary collapse
-
.included(mod) ⇒ Object
If include Util is called, extend ClassMethods.
-
.parse_sem_ver(str) ⇒ Hash
extended
from ClassMethods
Parse
stras a non-strict Semantic Version: d+.d+.d+. -
.rm_exist(filename, output = true) ⇒ Object
extended
from ClassMethods
If
filenameexists, delete it, and ifoutputistrue, log it to stdout. -
.to_bool(str) ⇒ true, false
extended
from ClassMethods
Convert
strtotrueorfalse. -
.yard_sem_ver ⇒ Hash
extended
from ClassMethods
Returns YARD’s version as a
Hashof parts: { major: 0, minor: 0, patch: 0 }.
Class Method Details
.included(mod) ⇒ Object
If include Util is called, extend ClassMethods.
36 37 38 |
# File 'lib/yard_ghurt/util.rb', line 36 def self.included(mod) mod.extend ClassMethods end |
.parse_sem_ver(str) ⇒ Hash Originally defined in module ClassMethods
Parse str as a non-strict Semantic Version:
\d+.\d+.\d+
Unlike the specification, minor and patch are optional. Also, pre-release and build metadata are ignored. This is used for checking the YARD version internally, so needs to be very flexible.
.rm_exist(filename, output = true) ⇒ Object Originally defined in module ClassMethods
If filename exists, delete it, and if output is true, log it to stdout.
.to_bool(str) ⇒ true, false Originally defined in module ClassMethods
Convert str to true or false.
Even if str is not a String, to_s() will be called, so should be safe.
.yard_sem_ver ⇒ Hash Originally defined in module ClassMethods
Returns YARD’s version as a Hash of parts:
{ major: 0, minor: 0, patch: 0 }
If the version can not be parsed, it will return the exact same Hash as above with all values to 0.
On initial call, it will parse it and store it. On subsequent calls, it will return the stored value.