-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Bundler install_if #176
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
@@ -124,7 +131,7 @@ def dependencies_entry_for_dup | |||
@dependencies.for_dup | |||
end | |||
|
|||
[:gits, :paths, :platforms, :groups, :source_blocks]. | |||
[:gits, :paths, :platforms, :groups, :source_blocks, :install_if]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I fix it?
lib/appraisal/bundler_dsl.rb
Outdated
@@ -5,7 +5,7 @@ class BundlerDSL | |||
attr_reader :dependencies | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -5,7 +5,7 @@ class BundlerDSL | |||
attr_reader :dependencies | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please!
lib/appraisal/bundler_dsl.rb
Outdated
@@ -124,7 +131,7 @@ def dependencies_entry_for_dup | |||
@dependencies.for_dup | |||
end | |||
|
|||
[:gits, :paths, :platforms, :groups, :source_blocks]. | |||
[:gits, :paths, :platforms, :groups, :source_blocks, :install_if]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please!
@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. |
Failure/Error: Combustion.initialize! :active_record, :action_controller SyntaxError: /home/nicolas/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/appraisal-40956d3ae826/lib/appraisal/gemfile.rb:33: syntax error, unexpected `end', expecting end-of-input Instead of using a raw String as explained here (thoughtbot#176) it uses the interpreted version: <Proc:0x00007f7aab911770 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:8 (lambda)> <Proc:0x00007f7aab9177d8 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:12 (lambda)> <Proc:0x00007f7aab917490 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:16 (lambda)> "-> { ENV[\"DB_ADAPTER\"] == \"sqlite3\" }" "-> { ENV[\"DB_ADAPTER\"] == \"mysql2\" }" "-> { ENV[\"DB_ADAPTER\"] == \"oracle_enhanced\" }"
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. |
Failure/Error: Combustion.initialize! :active_record, :action_controller SyntaxError: /home/nicolas/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/appraisal-40956d3ae826/lib/appraisal/gemfile.rb:33: syntax error, unexpected `end', expecting end-of-input Instead of using a raw String as explained here (thoughtbot#176) it uses the interpreted version: <Proc:0x00007f7aab911770 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:8 (lambda)> <Proc:0x00007f7aab9177d8 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:12 (lambda)> <Proc:0x00007f7aab917490 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:16 (lambda)> "-> { ENV[\"DB_ADAPTER\"] == \"sqlite3\" }" "-> { ENV[\"DB_ADAPTER\"] == \"mysql2\" }" "-> { ENV[\"DB_ADAPTER\"] == \"oracle_enhanced\" }"
Failure/Error: Combustion.initialize! :active_record, :action_controller SyntaxError: /home/nicolas/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/appraisal-40956d3ae826/lib/appraisal/gemfile.rb:33: syntax error, unexpected `end', expecting end-of-input Instead of using a raw String as explained here (thoughtbot#176) it uses the interpreted version: <Proc:0x00007f7aab911770 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:8 (lambda)> <Proc:0x00007f7aab9177d8 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:12 (lambda)> <Proc:0x00007f7aab917490 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:16 (lambda)> "-> { ENV[\"DB_ADAPTER\"] == \"sqlite3\" }" "-> { ENV[\"DB_ADAPTER\"] == \"mysql2\" }" "-> { ENV[\"DB_ADAPTER\"] == \"oracle_enhanced\" }"
Failure/Error: Combustion.initialize! :active_record, :action_controller SyntaxError: /home/nicolas/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/appraisal-40956d3ae826/lib/appraisal/gemfile.rb:33: syntax error, unexpected `end', expecting end-of-input Instead of using a raw String as explained here (thoughtbot#176) it uses the interpreted version: <Proc:0x00007f7aab911770 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:8 (lambda)> <Proc:0x00007f7aab9177d8 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:12 (lambda)> <Proc:0x00007f7aab917490 /home/nicolas/PROJECTS/CONCERTO/gems/ajax-datatables-rails/gemfiles/rails_6.1.4.gemfile:16 (lambda)> "-> { ENV[\"DB_ADAPTER\"] == \"sqlite3\" }" "-> { ENV[\"DB_ADAPTER\"] == \"mysql2\" }" "-> { ENV[\"DB_ADAPTER\"] == \"oracle_enhanced\" }"
```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 (thoughtbot#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: "../" ```
```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 (thoughtbot#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: "../" ```
```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 (thoughtbot#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: "../" ```
```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
Appraisal
file :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.