Class: PoiseRuby::Resources::BundleInstall::Provider

Inherits:
Chef::Provider
  • Object
show all
Includes:
Poise, PoiseRuby::RubyCommandMixin
Defined in:
lib/poise_ruby/resources/bundle_install.rb

Overview

The default provider for the bundle_install resource.

See Also:

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#action_installObject

Install bundler and the gems in the Gemfile.

Since:

  • 2.0.0



118
119
120
# File 'lib/poise_ruby/resources/bundle_install.rb', line 118

def action_install
  run_bundler('install')
end

#action_updateObject

Install bundler and update the gems in the Gemfile.

Since:

  • 2.0.0



123
124
125
# File 'lib/poise_ruby/resources/bundle_install.rb', line 123

def action_update
  run_bundler('update')
end

#bundler_binaryString

Return the absolute path to the correct bundle binary to run.

Returns:

  • (String)

Since:

  • 2.0.0



130
131
132
# File 'lib/poise_ruby/resources/bundle_install.rb', line 130

def bundler_binary
  @bundler_binary ||= ::File.join(poise_gem_bindir, 'bundle')
end

#gemfile_pathString

Find the absolute path to the Gemfile. This mirrors bundler's internal search logic by scanning up to parent folder as needed.

Returns:

  • (String)

Since:

  • 2.0.0



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/poise_ruby/resources/bundle_install.rb', line 138

def gemfile_path
  @gemfile_path ||= begin
    path = ::File.expand_path(new_resource.path)
    if ::File.file?(path)
      # We got a path to a real file, use that.
      path
    else
      # Walk back until path==dirname(path) meaning we are at the root
      while path != (next_path = ::File.dirname(path))
        possible_path = ::File.join(path, 'Gemfile')
        return possible_path if ::File.file?(possible_path)
        path = next_path
      end
    end
  end
end