Module: Sneaql::Core
- Defined in:
- lib/sneaql_lib/base.rb,
lib/sneaql_lib/core.rb,
lib/sneaql_lib/parser.rb,
lib/sneaql_lib/recordset.rb,
lib/sneaql_lib/tokenizer.rb,
lib/sneaql_lib/expressions.rb
Overview
contains the base classes for the extendable parts of sneaql:
commands (the actual commands specified in sneaql tags)
repo_managers (used to pull the sql files from a remote or local source)
metadata managers (to get information about each step)
in addition to the base classes, the mapped class/class_map utilities are used to provide a dynamic class system this class system allows you to register a class under a type you can later look up the class by type and a text identifier then instantiate a new instance from there
Defined Under Namespace
Modules: Commands Classes: ExpressionHandler, RecordsetManager, RegisterMappedClass, RepoDownloadManager, SneaqlCommand, StepMetadataManager, StepParser, Tokenizer
Constant Summary collapse
- @@class_map =
global map of all classes
{}
- @@valid_tokenizer_states =
[ :outside_word, :in_word, :in_string_literal, :in_string_literal_escape ]
- @@tokenizer_state_map =
{ whitespace: { outside_word: [:no_action], in_word: [:outside_word], in_string_literal: [:concat], in_string_literal_escape: [:concat] }, escape: { outside_word: [:error], in_word: [:error], in_string_literal: [:in_string_literal_escape], in_string_literal_escape: [:concat, :in_string_literal] }, word: { outside_word: [:new_token, :concat, :in_word], in_word: [:concat], in_string_literal: [:concat], in_string_literal_escape: [:concat, :in_string_literal] }, colon: { outside_word: [:new_token, :concat, :in_word], in_word: [:concat], in_string_literal: [:concat], in_string_literal_escape: [:concat, :in_string_literal] }, singlequote: { outside_word: [:new_token, :concat, :in_string_literal], in_word: [:error], in_string_literal: [:concat, :outside_word], in_string_literal_escape: [:concat, :in_string_literal] }, openbrace: { outside_word: [:new_token, :concat, :in_word], in_word: [:error], in_string_literal: [:concat], in_string_literal_escape: [:concat, :in_string_literal] }, closebrace: { outside_word: [:error], in_word: [:concat], in_string_literal: [:concat], in_string_literal_escape: [:concat, :in_string_literal] }, operator: { outside_word: [:new_token, :concat, :in_word], in_word: [:concat], in_string_literal: [:concat], in_string_literal_escape: [:concat, :in_string_literal] }, nonword: { outside_word: [:new_token, :concat, :in_word], in_word: [:concat], in_string_literal: [:concat], in_string_literal_escape: [:concat, :in_string_literal] }, }
Class Method Summary collapse
-
.add_mapped_class(type, mapped_class_hash) ⇒ Object
adds a new class to the map.
-
.class_map ⇒ Object
allows external access to class_map for testing purposes.
-
.find_class(type, text) ⇒ Class
returns the class referenced by the type/text combination.
-
.insure_type_exists(type) ⇒ Object
makes sure that the type exists before appending the class information.
-
.tokenizer_state_map ⇒ Hash
state machine for use when iterating through the character classifications of a given command.
-
.valid_tokenizer_states ⇒ Array<Symbol>
these are the states that can be jumped between during tokenization.
Class Method Details
.add_mapped_class(type, mapped_class_hash) ⇒ Object
adds a new class to the map
28 29 30 31 |
# File 'lib/sneaql_lib/base.rb', line 28 def self.add_mapped_class(type, mapped_class_hash) @@class_map[type] == [] unless @@class_map.keys.include?(type) @@class_map[type] << mapped_class_hash end |
.class_map ⇒ Object
allows external access to class_map for testing purposes
21 22 23 |
# File 'lib/sneaql_lib/base.rb', line 21 def self.class_map @@class_map end |
.find_class(type, text) ⇒ Class
returns the class referenced by the type/text combination
43 44 45 46 47 |
# File 'lib/sneaql_lib/base.rb', line 43 def self.find_class(type, text) @@class_map[type].each do |t| return t[:mapped_class] if t[:text] == text end end |
.insure_type_exists(type) ⇒ Object
makes sure that the type exists before appending the class information
35 36 37 |
# File 'lib/sneaql_lib/base.rb', line 35 def self.insure_type_exists(type) @@class_map[type] = [] unless @@class_map.key?(type) end |
.tokenizer_state_map ⇒ Hash
state machine for use when iterating through the character classifications of a given command. pass in the character c classification and current state and you will receive an array of actions to execute in sequence. these actions include the ability to change state.
79 80 81 |
# File 'lib/sneaql_lib/tokenizer.rb', line 79 def self.tokenizer_state_map @@tokenizer_state_map end |
.valid_tokenizer_states ⇒ Array<Symbol>
these are the states that can be jumped between during tokenization.
12 13 14 |
# File 'lib/sneaql_lib/tokenizer.rb', line 12 def self.valid_tokenizer_states @@valid_tokenizer_states end |