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.
As my submission to this coding challenge, I wrote a
FantasicParser
class that can be used to extract the relevant images from both a file and from a URL. Just how fantastic it is, is of course a highly subjective value judgement.Since using
open-uri
to directly download a page didn’t yield the same html structure as the provided file, I use selenium to fetch URLs to see if my parser works with different pages. I added this capability to the parser. As it is outside the scope of the exercise prompt, I also wrote the retrieved html to files, and 2 separate tests are provided, one with Selenium and one without. This way my parser can be evaluated without having to install firefox on the underlying system.I’m curious as to feedback on the code structure, method naming conventions, etc. - these days I mostly write in the functional style (in Node), so this exercise also served as an re-exploration of how I would personally structure an object-oriented program in ruby.
Install with
bundler install
To use the webdriver, make sure firefox is installed in the default system location
To get the desired JSON output, run
ruby index.rb
To test just using files only:
bundler exec rspec --color parser_files_only_spec.rb
To test using the webdriver:
bundler exec rspec --color parser_webdriver_spec.rb
Happy holidays, y’all.