Closed samnissen closed 4 years ago
Would like to know if you think this is worth tackling, @sandeepnagra , or if you have other ideas about how we can ensure we can access our own lib directory.
Hi @samnissen, Apologies for the delayed response. I have been a little busy and just got some time today to look into it.
I have an alternate to load the path for html2canvas js files that works for me. I use this logic in several other gems to load files in gem but all my gems are used in non-rails projects. Here's what I did:
I replaced following:
path = File.join(WatirScreenshotStitch::Utilities.directory, "vendor/html2canvas.js")
with:
path = File.expand_path("../../vendor/html2canvas.js", __FILE__)
Tests are executing fine. I can raise a PR for this and also remove WatirScreenshotStitch::Utilities
as we don't need it anymore.
Try it in your local and let me know if it doesn't work.
No reason to apologize. And good work all around. Just did code review on the PR, and once fixed up, I think it's ready to merge. Then if you want to publish a 0.7.4 (right?) version, please feel free. Otherwise I can do it.
@samnissen - I published version 0.7.4
Per the bundler documentation, the gem path might be different from our accounted for location:
Unfortunately, the documentation also allows for many other options — including setting it on the fly during a
bundle install
.Because of this I am not sure we can account for all options. However, we should be able to search additional directories, including:
$PATH
directories as well as$GEM_HOME
and$GEM_PATH
Bundler's
--deployment
default of APP_ROOT/vendor/bundle might be discoverable as well, especially in Rails projects where we can callRails.root
. How to find this in non-Rails projects will require additional investigation.Also, we can setup some custom way of alerting us to the gem's path (i.e.
WATIR_SCREENSHOT_STITCH_GEM_DIRECTORY
).Since this is a destructive act, we can provide a backstop of employing
gem which watir-screenshot-stitch
. This could mean version mismatch (and thus unexpected results), and we might want to warn users of that if they reach such a code path.At a minimum, we must document this dependency for anyone using the
base64_canvas
function.