- name: get installed rubies
  command: rbenv versions --bare
  register: rubies

- name: install ruby versions
  command: 'rbenv install --skip-existing {{ item }}'
  with_items: '{{ dotfiles.ruby.versions }}'
  when: item not in rubies.stdout

- name: set the default ruby version
  command: 'rbenv global {{ dotfiles.ruby.default }}'

- name: get installed gems
  command: rbenv exec gem list
  register: gems

- name: install default gems
  command: 'rbenv exec gem install --no-doc {{ item }}'
  with_items: '{{ dotfiles.ruby.gems }}'
  when: item not in gems.stdout

- name: get installed rubies
  command: rbenv versions --bare
  register: rubies

- name: update ruby versions
  command: 'brew upgrade ruby-build'
  with_items: '{{ dotfiles.ruby.versions }}'
  when: item not in rubies.stdout_lines

- name: install ruby versions
  command: 'rbenv install --skip-existing {{ item }}'
  with_items: '{{ dotfiles.ruby.versions }}'
  when: item not in rubies.stdout_lines

- name: set the default ruby version
  command: 'rbenv global {{ dotfiles.ruby.default }}'

- name: get installed gems
  command: rbenv exec gem list
  register: gems

- name: install default gems
  command: 'rbenv exec gem install --no-doc {{ item }}'
  with_items: '{{ dotfiles.ruby.gems }}'
  when: item not in gems.stdout

Upgrade ruby-build if ruby version is not available
Upgrade ruby-build if ruby version is not available
