Class: Atatus::Sql::Signature Private
- Inherits:
-
Object
- Object
- Atatus::Sql::Signature
- Includes:
- Tokens
- Defined in:
- lib/atatus/sql/signature.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Summarizer
Constant Summary
Constants included from Tokens
Tokens::AS, Tokens::CALL, Tokens::COMMA, Tokens::COMMENT, Tokens::DELETE, Tokens::FROM, Tokens::IDENT, Tokens::INSERT, Tokens::INTO, Tokens::KEYWORDS, Tokens::KEYWORD_MAX_LENGTH, Tokens::KEYWORD_MIN_LENGTH, Tokens::LPAREN, Tokens::NUMBER, Tokens::OR, Tokens::OTHER, Tokens::PERIOD, Tokens::REPLACE, Tokens::RPAREN, Tokens::SELECT, Tokens::SET, Tokens::STRING, Tokens::TABLE, Tokens::TRUNCATE, Tokens::UPDATE
Class Method Summary collapse
- .parse(sql) ⇒ Object private
Instance Method Summary collapse
-
#initialize(sql) ⇒ Signature
constructor
private
A new instance of Signature.
- #parse ⇒ Object private
Constructor Details
#initialize(sql) ⇒ Signature
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Signature.
38 39 40 41 |
# File 'lib/atatus/sql/signature.rb', line 38 def initialize(sql) @sql = sql.encode('utf-8', invalid: :replace, undef: :replace) @tokenizer = Tokenizer.new(@sql) end |
Class Method Details
.parse(sql) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 |
# File 'lib/atatus/sql/signature.rb', line 56 def self.parse(sql) new(sql).parse end |
Instance Method Details
#parse ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/atatus/sql/signature.rb', line 43 def parse @tokenizer.scan # until tokenizer.token != COMMENT parsed = parse_tokens return parsed if parsed # If all else fails, just return the first token of the query. parts = @sql.split return '' unless parts.any? parts.first.upcase end |