Implement Bundler install_if#176
Implement Bundler install_if#176nickcharlton merged 2 commits intothoughtbot:masterfrom n-rodriguez:wip/install_if
Conversation
|
With real world example : |
|
The nice thing : it even merges gems with duplicated conditions : Here the yaml structure that generate gemfiles : https://github.com/jbox-web/ajax-datatables-rails/compare/wip/appraisal#diff-a7e1dc0d2145599ae30f5d8cdfa163e79e7708040d2f7cf36b36fab4559974a8R30 |
lib/appraisal/bundler_dsl.rb
Outdated
| end | ||
|
|
||
| [:gits, :paths, :platforms, :groups, :source_blocks]. | ||
| [:gits, :paths, :platforms, :groups, :source_blocks, :install_if]. |
There was a problem hiding this comment.
should I fix it?
lib/appraisal/bundler_dsl.rb
Outdated
|
|
||
| PARTS = %w(source ruby_version gits paths dependencies groups | ||
| platforms source_blocks gemspec) | ||
| platforms source_blocks install_if gemspec) |
There was a problem hiding this comment.
should I fix it?
|
@nickcharlton wdyt? |
|
Hi there! any news? |
|
Ping @nickcharlton |
|
Hi there! Any news? |
|
It would be nice to have some news... I hope I've not worked for nothing.... |
|
Ping @nickcharlton |
1 similar comment
|
Ping @nickcharlton |
|
Ping @nickcharlton |
nickcharlton
left a comment
There was a problem hiding this comment.
Thank you for keeping this alive, @n-rodriguez and sorry for the long wait.
Two points on some Hound issues, if you could take a look at those, I'll come back and get this merged!
lib/appraisal/bundler_dsl.rb
Outdated
|
|
||
| PARTS = %w(source ruby_version gits paths dependencies groups | ||
| platforms source_blocks gemspec) | ||
| platforms source_blocks install_if gemspec) |
lib/appraisal/bundler_dsl.rb
Outdated
| end | ||
|
|
||
| [:gits, :paths, :platforms, :groups, :source_blocks]. | ||
| [:gits, :paths, :platforms, :groups, :source_blocks, :install_if]. |
|
@nickcharlton ping |
|
Thanks for the ping! I'm going to merge this now. It'll go out in our next release, which will be once we fix #173. |
|
Can you open a new issue? Ideally with something we can try and replicate with! |
|
From your screenshot I see By the way be sure to use quotes in your See: #176 (comment) |
|
@nickcharlton maybe it's time to cut a new release? v2.4.1...master :) |
|
Thanks @n-rodriguez. I only checked to see if I'm on the latest version. The Will try now. |
|
There will be a new issue soon. I'm tracking a few issues/catching up with lots of bundler changes so I think it's important to test these well. |
```sh An error occurred while loading ./spec/draper/draper_spec.rb. Failure/Error: Bundler.require(*Rails.groups) SyntaxError: /Users/nicolas/.asdf/installs/ruby/3.3.3/lib/ruby/gems/3.3.0/gems/appraisal-2.5.0/lib/appraisal/gemfile.rb:52: syntax error, unexpected `end' ``` Instead of using a raw String as explained here (#176) it uses the interpreted version: ```sh --- |- source "https://rubygems.org" gem "appraisal" gem "capybara" gem "cuprite" gem "database_cleaner" gem "factory_bot" gem "faker" gem "guard-rspec" gem "puma" gem "rake" gem "rspec-rails" gem "rspec-retry" gem "rubocop" gem "rubocop-capybara" gem "rubocop-factory_bot" gem "rubocop-rake" gem "rubocop-rspec" gem "simplecov" gem "sqlite3", "~> 1.5.0" gem "rails", "6.1.7" install_if #<Proc:0x000000011f590cc0 /Users/nicolas/PROJECTS/CONCERTO/gems/draper/gemfiles/rails_6.1.7.gemfile:25 (lambda)> do gem "net-imap" gem "net-pop" gem "net-smtp" end install_if #<Proc:0x000000011f5909f0 /Users/nicolas/PROJECTS/CONCERTO/gems/draper/gemfiles/rails_6.1.7.gemfile:31 (lambda)> do gem "base64" gem "bigdecimal" gem "mutex_m" gem "drb" gem "logger" end gemspec path: "../" ```


This an attempt to fix: #131
The trick here is to store the conditional as plain string. As explained here #132 (comment) :
IMHO the easiest way is to write/store it as a string and render it directly in the generated file (verbatim).
So in
Appraisalfile :becomes
After generation it becomes (in
gemfiles/*.gemfile) :It should help to solve most use cases since you can put any valid Ruby code here :).
At first I tried https://github.com/banister/method_source but it immediately failed.
Because :
So I ended up with this easy solution that does the job.