(PDOC-3) Refactor prototype code to make it more readable#7
Merged
zaphod42 merged 9 commits intopuppetlabs:masterfrom Sep 30, 2014
Merged
Conversation
Contributor
Author
Contributor
There was a problem hiding this comment.
I think putting this here makes the yard check irrelevant since it will try to load yard before the check is ever performed. I haven't confirmed this yet.
Prior to this commit, several rspec tests were using `decribe "string"' instead of `describe constant`. Update the tests to use the constant instead. Additionally, rename the puppet function tests to reflect the renaming of the handlers.
Refactor the code in the strings face and extract much of the functionality into a separate library in order to make the code more readable and sustainable. Additionally, remove the `modules` action from the face since it does not have a clear use case currently. However since the `server` action depends on it, and it may be helpful to add other features in the future, extract the functionality previously contained in `modules` into a helper method.
Add some comments for the new methods that have been introduced to ensure that the code is readable and well documented.
Refactor the actions module so that it is a class. This is important because it allows us to keep `Puppet[]` calls out of the library and have them in the face itself. Additionally, move a few things around (like `check_required_features` since it makes require statements cleaner) and clean up some comments.
Prior to this commit, the puppet strings project was using require_relative to include other classes and modules. Due to some ambiguity and the fact that the strings project shares some naming conventions with YARD, the use of require_relative sometimes made it unclear what was being included and where it was coming from. Now require is being used and although this requires the full path, it makes it very clear where things are coming from.
Prior to this commit, many of the classes in this project were declared in two lines. The first line would put them in the context of the module they belonged to, and the second line would declare the class and deal with inheritance. In order to make the code more readable and to allow require statements to be moved to the top level, turn all class declarations into one line statements.
Prior to this commit, the requires for the puppetx portion of this project were dealt with in each individual file. In order to make the code more readable and the requires more clear, move them all into the strings file.
19316cd to
5159a7b
Compare
The specs were including YARD into the Kernel, which allowed shorter references to the Registry, but also obscured that the Registry is part of YARD.
The plugin.rb file really only did configuration of components that were already loaded. By relocating to the strings.rb file, it provides a central place for all of the loading and configuration of the strings components.
zaphod42
added a commit
that referenced
this pull request
Sep 30, 2014
(PDOC-3) Refactor prototype code to make it more readable
eputnam
added a commit
to eputnam/puppet-strings
that referenced
this pull request
Mar 19, 2018
# This is the 1st commit message: (PDOC-206) starting work for tasks # This is the commit message puppetlabs#2: (PDOC-206) parser, handler, statement, code_object Adds a parser for json, a task handler, a task statement and a task code_object. the parser uses JSON.parse instead of an AST and some finagling has to be done in the statement and the handler to get YARD to be ok with this. When YARD is registering the task code_object, it expects it to have things like a docstring and comments and so on, but it doesn't have any of those things so they are faked. # This is the commit message puppetlabs#3: (PDOC-206) refactor handler/parser/co interaction and json_spec passes to_hash does not need to behave like it does in other code objects. instead, just take the raw json and iterate over it. # This is the commit message puppetlabs#4: (PDOC-206) things work now # This is the commit message puppetlabs#5: (PDOC-206) small refactor/improvement of input section # This is the commit message puppetlabs#6: moved some things around, added some template logic # This is the commit message puppetlabs#7: (PDOC-206) adds more tests # This is the commit message puppetlabs#8: (PDOC-206) remodel to_hash and start markdown Revamped the to_hash method for task code objects to look more like other objects. The markdown engine cares a lot about this format. # This is the commit message puppetlabs#9: (PDOC-206) update json test, task template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since puppet strings began as an experiment, some of the code was due for a bit of refactoring in order to ensure that the codebase is both sustainable and readable. In addition to the renaming that was dealt with in pull request #4, rearrange some code and remove the modules action.