---
- name: "Ensure {{ app_name }} is installed"
  become: false
  community.general.homebrew:
    name: ruby
    state: "{{ app_state | default('present') }}"

- name: Ensure configured gems are installed (system)
  gem:
    name: "{{ item.name }}"
    state: present
    user_install: false
  loop: "{{ ruby_gems }}"
  ignore_errors: true
  environment:
    PATH: "/usr/local/opt/ruby/bin:{{ ansible_env.PATH }}"
    LDFLAGS: "-L/usr/local/opt/ruby/lib"
    CPPFLAGS: "-I/usr/local/opt/ruby/include"
    PKG_CONFIG_PATH: "/usr/local/opt/ruby/lib/pkgconfig"

- name: Ensure configured gems are installed (user)
  include_tasks: user-Linux.yml
  loop: "{{ user_configs }}"
  loop_control:
    label: "{{ user.username }}"
    loop_var: user
