ManageIQ / polisher

Polisher is a Ruby module and set of utilities aimed to assisting the post-publishing packaging process for Ruby gems and applications.
MIT License
14 stars 14 forks source link

Handle missing gems for namespaced classes #101

Closed jrafanie closed 10 years ago

jrafanie commented 10 years ago

From the first commit:

Add support for missing components/gems in namespaced classes. … Relaxed dependencies via delayed exceptions was introduced in #72.

As introduced in #72, if Polisher::Fedora needed "curb", "pkgwat", and "nokogiri", it was supported via: Component.verify("Fedora", "curb", "pkgwat", "nokogiri") {}

If we specify required components for a namespaced class, such as Polisher::RPM::Requirement via: Component.verify("RPM::Requirement", 'gem2rpm', 'versionomy', 'active_support/core_ext') {}

it fails with 'uninitialized constant Polisher::RPM' because we're trying to inject a Requirement constant into a class that doesn't exist: Polisher::RPM. We have to create this RPM class in the Polisher namespace before trying to inject the Requirement == Missing component class.

This commit fixes this and also changes the output to warn the user about the exact missing dependencies on load but delays raising the RuntimeError until you try to instantiate the class.

For example:

$ bundle console
Resolving dependencies...
Failed to require gem2rpm.  Added runtime exception in Polisher::RPM::Requirement
Failed to require gem2rpm.  Added runtime exception in Polisher::RPM::Spec
Failed to require pkgwat.  Added runtime exception in Polisher::Fedora
irb(main):001:0> Polisher::RPM.new
RuntimeError: polisher is missing a dependency - cannot instantiate
...
irb(main):002:0> Polisher::RPM::Requirement.new
RuntimeError: polisher is missing a dependency - cannot instantiate
...
coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.15%) when pulling 20678594eab4d1c82c5f1551812df43e53a6da44 on jrafanie:handle_missing_gems_for_namespaced_classes into 19b894b90f6277d8c6f2e50b1758aac86685378b on ManageIQ:master.

coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.15%) when pulling 3abbc136159258416c65fc0f969e012a7dbef184 on jrafanie:handle_missing_gems_for_namespaced_classes into 19b894b90f6277d8c6f2e50b1758aac86685378b on ManageIQ:master.

jrafanie commented 10 years ago

@movitto @Fryguy @brandondunne Please review.

jrafanie commented 10 years ago

There's some strange autoloading errors that are occurring on ruby 2.0/2.1. I'll have to take a look. Any ideas?

movitto commented 10 years ago

Ah that err is caused by

https://github.com/ManageIQ/polisher/commit/c899d500502a57582a906dfa20cc6cf343c09265

Must've missed an instance :-)

movitto commented 10 years ago

@jrafanie Looks good, tried it out locally and works.

Mind merging #98 in & adding the activesupport requirement. Can merge after that.

jrafanie commented 10 years ago

Sorry, @movitto commented on #98 when I meant to comment here... I'm trying to get our builder app running off of polisher's master branch and ran into #101 and #102 right out of the gate. I'd rather stabilize master, get a version pushed to rubygems.org before adding another 1000+ net line changes from #98. Thoughts?

coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.15%) when pulling 938bacc9e7e28b561da72410c969b2749def8227 on jrafanie:handle_missing_gems_for_namespaced_classes into 19b894b90f6277d8c6f2e50b1758aac86685378b on ManageIQ:master.

miq-bot commented 10 years ago

Checked commits https://github.com/jrafanie/polisher/commit/d4f4a5ef0ed58f74d07a1ff6867a2c45e05eb8d4 .. https://github.com/jrafanie/polisher/commit/938bacc9e7e28b561da72410c969b2749def8227 with rubocop 0.21.0 2 files checked, 1 offense detected

spec/component_spec.rb

coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.15%) when pulling 938bacc9e7e28b561da72410c969b2749def8227 on jrafanie:handle_missing_gems_for_namespaced_classes into 19b894b90f6277d8c6f2e50b1758aac86685378b on ManageIQ:master.

bdunne commented 10 years ago

@jrafanie Looks good. :+1:

Completely agree with your comment above.

movitto commented 10 years ago

@jrafanie Yeh thats fine, lets get these in, tag, push to rubygems, and then get #98 in