Made Lexicon.parser public again Add vars argument to Parser.parse, Parser.new and Template.new Add functional tests for all command outputs, specifically [unless]...[/unless] Test [one.two.three] when [one.two] returns nil Test inner subs, within quotes and without Raise error in handle_quoted_arg if char before quote is not whitespace handle_command if left bracket reached during gather_command_name_and_args handle_quoted_arg doesn't need an argument In handle_quoted_arg, add dummy command to stack, not last item on stack
Only load command classes once Removed BlockCommand#closed_by? Simplified Context.construct_from, assumes hash is always just a Hash Simplified Filter.filter (don't run text through 'unescaped' filter, just return text) Renamed Parser.cached_path to .cached_file Renamed Papyrus.source_template_dirs to .source_template_paths Uncommented private keyword in Parser metaclass
… test finally works! Switched order of resolving variables/commands in Parser#lookup_var_or_command (treat commands as unoverridable keywords) When treating bracketed construct as variable, defer evaluation of variable until runtime by adding instance of Variable to stack instead of just a Text node Redefine BlockCommand#get to return active_block.get Added ContextItem#parent_get to use parent._get if BlockCommand, or parent.get otherwise (to prevent an infinite loop); modified #get_primary_part to call #parent_get instead Modified Variable to receive raw command so it can return that in #output if the variable doesn't exist Renamed TokenList @cmd_info to @stash
Removed call to modify_close_cmd in Parser#handle_command, and removed modify_close_cmd test in parser_test.rb Load command classes on Parser.new instead of Papyrus.new Added guarded lexicon reader in Papyrus Fixed Parser#modify_active_cmd to accept command name and args, not full command Parser#populate_template: only add command from handle_command if not nil (as handle_command_close will return nil) Changed BlockCommand#initialize and #add to return NotImplementedError Added BlockCommand#active_block to raise NotImplementedError Implemented active_block for BlockCommand subclasses Added BlockCommand#add, remove BlockCommand subclass #add's ContextItem#get should return key if key starts with a number Added Papyrus.cache_templates writer and .cache_templates? reader, modified Parser to only cache the template if this option is true Renamed 'recording' methods in TokenList to 'stashing', added #stash_curr to append the current token to the stash
A NodeList is a ContextItem Move parent attribute from ContextItem to Node (Text and Variable are only two classes that do not receive parent) Rename ContextItem#reset_vars to #reset_context, and have it set @object to nil too Remove Template#output (NodeList already provides that) Template is no longer a ContextItem (NodeList is one already) Added NodeTest, seems to have been missing When we look for a variable in Parser#lookup_var_or_command, if stack.last is a BlockCommand, look up within its active block, not the whole command
…d Filter.filter so it doesn't require a context, class name, or block Updated Commands::Filter to use Papyrus::Filter, renamed @text to @nodes, added test Updated Variable to use Papyrus::Filter, renamed 'processor' to 'filter' Removed tests for Compiler, DefaultPreprocessor, FileSource, Lexicon, Source, StringSource
Added Papyrus.source_template_dirs, .cached_template_dir Renamed ContextItem#values to #vars Added ContextItem#vars=, so now you can mass assign vars Renamed ContextItem#clear to #reset_vars (and removed #clear_cache) Commented out FileSource, StringSource, Compiler, Lexicon from being require'd Modified Parser to save content in instance variable Removed unnecessary methods in ruby_ext.rb and added some more Ensured that all tests work
…PoLC) Rename Parser#commandify to #make_template and split into #populate_template and #close_open_block_commands
…n parent to last item on stack Parser is no longer a ContextItem; remove Parser.recent_parser and initialize options; set @template to Template Fix ContextItem#parser when self is a Template Reorder require's in papyrus.rb Fix Parser, Compiler, BlockCommand tests
…e in the current context before interpreting as a command ContextItem#get should not catch exceptions that may occur; removed clean_rescue option Fix Template so parent is set to parser in constructor instead of when output is called
…ume a dot separates methods Split off Token and TokenList from Parser into separate files Modified Parser#close_active_cmd to not use Command#closed_by? but check end of command manually Cleaned up storing of raw and full commands Renamed TokenList#next to #advance, #next is #peek
… at runtime, and therefore which commands the parser can "see" Added Command.aka and @aliases to set alternate names for commands (such as If) Changed Command#modified_by? so it doesn't use Lexicon to check - it just goes on whether or not the method exists Fixed If, Include, and Loop so they're in the Commands module (not Command) Modified Parser#lookup_command so it goes by Papyrus.lexicon hash instead of Lexicon#lookup, and replaced references to Lexicon::CommandNotFoundError to just Parser::CommandNotFoundError Template is now a NodeList, not a BlockCommand
…re logical, but also since commands have to be in their own module/folder, so we can load specific ones at runtime. Tests are broken again.
…thod. Modifiers get stored in a @modifiers class instance variable. A modifier method receives an array of args passed to that modifier. Update Command subclasses to use .modifier instead of defining the method as usual Replace instances of raw_command with full_command ("raw" command includes the left and right brackets) Remove #end method from Command subclasses
…t, Define, Filter, If, Include, Loop, and Stackable) now accept just two arguments: command name and command args (an array). Removed modifier and closer class variables from all Command subclasses
…arse method, updated tests Modified Parser.new to just accept lexicon and parent context Removed commented out parsing code from Compiler
…iary-X/Codexed 'sub' syntax - quotes around args, nested subs, standardized sub invocation syntax. Lots of stuff likely broken, more renovation on the way.
- Changed how commands are stored -- they're now keyed by class name, not by symbol - Added ability to define local modifiers on a command. Moved :else, :elsif, and :when modifiers in DefaultLexicon to local modifiers to simplify things. - Global modifier ability revamped as global_modifier. - A closer is now defined separately from a modifier. So far, you can only define a closer globally, and there can only be one closer ('end' in the DefaultLexicon). - Changed default to store a class name instead of a symbol. This makes it so a NameError is thrown right away if the user refers to a nonexistent command. - Revamped modifies? as modifier_on, and added closer_on - Renamed @lexicon to @commands - Replaced command_open and command_close in Lexicon with bra and ket, resp. - Renamed define_global_var to just global_var Changes to Parser: - Reduced temporary variables during compilation to just stack. - Also, stack is no longer stored in an instance variable, but just passed around to other methods. - Renamed command_modifies_top_command? to modify_active_cmd, and changed it to call Command::Base#modified_by? instead of Lexicon.modifies? - Renamed command_closes_top_command? to close_active_cmd, and changed it to call Command::Base#closed_by? instead of Lexicon.modifies? Changes to Commands: - Added #modified_by? as complement to Lexicon#modifier_on - Added #closed_by? just for a closer - Added lexicon to the list of arguments passed to each Command instance, so you can access it from any method, not just output, and you don't have to go through context - Took out Unknown#lookup, instead we can just say @lexicon.lookup
- revamped define to look nicer and be more automatic about certain things - added adv_define for a more manual definition - added command_open and command_close, modified command_regex (now command_regexp) to use these instead - default now accepts a symbol that will get camelized - updated documentation Modified DefaultLexicon to use new define notation, and set command_open and command_close as opposed to command_regexp Fixed command.rb to correctly require files Command::Base and all subclasses now require first argument to be called_as, for consistency; updated tests to reflect this Verified that all tests work Updated TODO Updated expectations to 1.2.0
…e very latest changes.
Started to fix some of the documentation Changed remaining instances of 'namespace' with 'context' Changed PageTemplate to a module instead of a class, since we never create an instance of it and class methods work on modules Changed @@modifier and @@closer in Command::Base to metaclass instance variables, and added attr_accessors; modified subclasses to set self.modifier and self.closer instead Command::Block: - added #length, #size, #first, #last, #empty?, # to delegate to @command_block - changed #add to return self - added #<< as alias to #add Command::Case - modified #add to reverse statements, make compact, return self - modified #output so that context is not optional Command::Filter - moved #output code to .filter, .get_processing_components, and .get_context_and_parser (since the same sort of code is used with Command::Text), modified #output to use .filter instead Command::If - Bulked up main documentation to describe how @true_commands and @false_commands are used - Modified #add to reverse statements - Fixed typo in #elsif (Argumentrror) - Cleaned up #to_s Command::Include - Split #output up into #get_template_from_value, #get_compiled_or_uncompiled_template, #compile_template for testing Command::Loop - Renamed iterators to block_params for clarity - Renamed @else_command to @else_commands - Modified #add to reverse statements, make compact, return self - Bulked up documentation for #output - Split #output up into #create_subcontext, #set_block_params, #set_metavariables Command::Stackable - Modified #add to return self - Added #<< as alias to #add Command::Unknown - Added #lookup as shortcut for context.parser.lexicon.lookup, which is quite a mouthful - Modified #output to use #lookup, changed case to if/else - Renamed @command to @raw_command Command::Value - Changed #output to use Filter.filter instead of repeating code ContextItem - Modified #set to stringify key before setting value - Split off code in #get into #get_primary_part, #get_secondary_part, cleaned up #get - Added private accessors for @values, @parent, changed references to use method instead of variable - Compacted #parser - Changed #true? to reflect renaming of Parser#args to #options, keys as symbols DefaultLexicon - Renamed @sub_regex back to @command_regex - Renamed references to command to command_contents for clarity - Changed cmd in modifier's to modifiee for clarity FileSource - Renamed @args to @options, symbolize keys before setting @options - Cleaned up #initialize - #get, #cache: Renamed cmds to template - Cleaned up #cache Lexicon - Renamed sub_regex back to command_regex - Renamed command to raw_command - Cleaned up #lookup - Modified #modifies? to symbolize given modifier - Renamed rx to regexp - Modified #modifier to symbolize given sym - Added accessors to @lexicon and @modifiers, modified code to reference method instead of variable Parser - Removed #parser, changed #initialize to set @parser instead - Renamed args to options, changed option keys to symbols - Changed #initialize so options are symbolized, and deleted as they go along so the options passed to Source are just for the source - :method_separators option now gets converted to @method_separator_regexp - Moved most of code in #parse to #tokenize, split off code into #handle_command, #add_text_as_command_to_top, #command_modifies_top_command? #command_closed_top_command?, #add_command_to_stack - Added #new_template - Renamed clearCommands to clear_commands - stack, top, modifier, closer are now stored in instance variables during parsing, added private accessors Source - Renamed @args to @options StringSource - Renamed @args to @options - Changed options to be symbolized before being stored Template - Removed #parent, changed #initialize to set @parent instead, changed #output to set self.parent - Converted case in @output to if/then