Skip to content

(PDOC-3) Refactor prototype code to make it more readable#7

Merged
zaphod42 merged 9 commits intopuppetlabs:masterfrom
HAIL9000:PDOC-3_refactor-prototype-code
Sep 30, 2014
Merged

(PDOC-3) Refactor prototype code to make it more readable#7
zaphod42 merged 9 commits intopuppetlabs:masterfrom
HAIL9000:PDOC-3_refactor-prototype-code

Conversation

@HAIL9000
Copy link
Copy Markdown
Contributor

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.

@HAIL9000
Copy link
Copy Markdown
Contributor Author

The pull request seems to have pulled in all @zaphod42's comments form 4379177, but I think I addressed them all in 0d0eccb.

Comment thread lib/puppet/face/strings.rb Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@HAIL9000 HAIL9000 force-pushed the PDOC-3_refactor-prototype-code branch from 19316cd to 5159a7b Compare September 30, 2014 20:55
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
@zaphod42 zaphod42 merged commit 970b604 into puppetlabs:master Sep 30, 2014
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
@chelnak chelnak added the bugfix label Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants