Skip to content
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

Use #is_a_path? conditionally on Bundler version #19

Merged
merged 21 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
79d8588
Use #is_a_path? conditionally on Bundler version
garettarrowood Aug 10, 2018
77439e8
Use Bundler::VERSION
garettarrowood Aug 10, 2018
8e22239
Update setting Bundler to frozen with #set_local
garettarrowood Aug 12, 2018
57136cf
Force travis to install with correct Bundler version
garettarrowood Aug 12, 2018
8bd8c5d
Resolve rubocop offenses
garettarrowood Aug 12, 2018
6990215
Verify bundler version is not greater than 1.14.0 in travis
garettarrowood Aug 12, 2018
6f82a4b
Print the version
garettarrowood Aug 12, 2018
c622ac2
Override install properly
garettarrowood Aug 12, 2018
93ea316
Overwrite script as well
garettarrowood Aug 12, 2018
bd421f2
Force uninstall of bundler as suggestion in link
garettarrowood Aug 12, 2018
85d9ce5
try moving it to before_install
garettarrowood Aug 12, 2018
b6caad9
Try another tactic found on this travis-ci issue
garettarrowood Aug 12, 2018
964e3df
Turn condition in Gemfile into Bundler version log
garettarrowood Aug 12, 2018
ccfd098
Create build matrix with multiple Ruby & Bundler versions
garettarrowood Aug 12, 2018
4b251ad
Remove logging that creates test failures
garettarrowood Aug 12, 2018
a612459
Fix wrong bundler version
garettarrowood Aug 12, 2018
03c5439
Add 2 more Bundler versions
garettarrowood Aug 12, 2018
0e65e41
Use matrix of 1 Ruby & 2 Bundler versions
garettarrowood Aug 13, 2018
d3a633b
Use Gem::Version to compare Bundler versions
garettarrowood Aug 13, 2018
909b498
Use #respond_to? instead of looking at Bundler
garettarrowood Aug 13, 2018
74bffba
Remove duplication from #path?
garettarrowood Aug 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
sudo: true
language: ruby
rvm:
- 2.3.1
before_install:
- gem install bundler -v 1.13.6
- "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does gem uninstall not work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not. I tried in the before_install and install phases. Travis returns:

$ gem uninstall bundler
ERROR:  While executing gem ... (Gem::InstallError)
    gem "bundler" cannot be uninstalled because it is a default gem

Related issue

- gem install bundler:"$BUNDLER_VERSION"
- sudo apt-get -qq install graphviz
rvm:
- 2.5.1
env:
- BUNDLER_VERSION=1.15.4
- BUNDLER_VERSION=1.16.3
10 changes: 7 additions & 3 deletions lib/cobra_commander/component_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ def initialize(root_path)
def dependencies
@deps ||= begin
return [] unless gem?
gems = bundler_definition.dependencies.select do |dep|
dep.source&.is_a_path? && dep.source.path.to_s != "."
end
gems = bundler_definition.dependencies.select { |dep| path?(dep.source) }
format(gems)
end
end

def path?(source)
return if source.nil?
source_has_path = source.respond_to?(:path?) ? source.path? : source.is_a_path?
source_has_path && source.path.to_s != "."
end

def format(deps)
deps.map do |dep|
path = File.join(dep.source.path, dep.name)
Expand Down
13 changes: 7 additions & 6 deletions spec/cobra_commander/component_tree_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@
end

describe "when bundle is frozen" do
# When the application bundle is locked, Bundler represents a components' self-dependency
# (triggered by `gemspec` in its Gemfile) as a Bundler::Source::Path, rather than a
# Bundler::Source::Gemspec. This can be confused with a dependency on another component.
# When the application bundle is locked, Bundler represents a components'
# self-dependency (triggered by `gemspec` in its Gemfile) as a
# Bundler::Source::Path, rather than a Bundler::Source::Gemspec.
# This can be confused with a dependency on another component.
before do
@original = Bundler.settings[:frozen]
Bundler.settings[:frozen] = true
@original = Bundler.settings.frozen?
Bundler.settings.set_local(:frozen, true)
end

it "#component_dependencies still accurately selects" do
expect(subject.to_h).to eql(AppHelper.tree)
end

after do
Bundler.settings[:frozen] = @original
Bundler.settings.set_local(:frozen, @original)
end
end
end
Expand Down