Module: CommentStrip

Extended by:
CommentStrip
Includes:
Xqsr3::Quality::ParameterChecking
Included in:
CommentStrip
Defined in:
lib/comment_strip.rb,
lib/comment_strip/strip.rb,
lib/comment_strip/version.rb,
lib/comment_strip/language_families/c.rb,
lib/comment_strip/language_families/hash_line.rb

Overview

Main module for comment_strip.r library

Defined Under Namespace

Modules: LanguageFamilies

Constant Summary collapse

VERSION =

Current version of the comment_strip.r library

'0.2.1'
VERSION_MAJOR =

Major version of the comment_strip.r library

VERSION_PARTS_[0]
VERSION_MINOR =

Minor version of the comment_strip.r library

VERSION_PARTS_[1]
VERSION_REVISION =

Revision version of the comment_strip.r library

VERSION_PARTS_[2]

Instance Method Summary collapse

Instance Method Details

#strip(input, lf, **options) ⇒ Object

Strips comments from an input string, according to the rules and conventions of a given language-family.

Signature

  • Parameters:

    • input (+String+, nil) the input source code;
    • lf (+String+) the name of the language family, which must be one of the following listed in the section below;
    • options (+Hash+) options that moderate the behaviour;
  • Options: None currently defined.

Return

(+String+) The stripped for of the input.

Supported language families

Currently supported language families:

- +'C'+ - including C, C++, C#, Go, Java, Rust;
- +'Hash_Line'+ - include Ruby, Python, Ruby, shell;


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/comment_strip/strip.rb', line 80

def strip input, lf, **options

    check_parameter input, 'input', responds_to: [ :each_char, :empty?, :nil?, ], nil: true
    check_parameter lf, 'lf', types: [ ::String, ::Symbol ]

    case lf.to_s.upcase
    when 'C'

        LanguageFamilies::C.strip input, lf, **options
    when 'HASH_LINE'

        LanguageFamilies::HashLine.strip input, lf, **options
    else

        raise "language family '#{lf}' unrecognised or not supported"
    end
end