Class: InstrumentalComponents::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/instrumental-components.rb

Instance Method Summary collapse

Constructor Details

#initialize(license_key, email) ⇒ Installer

Returns a new instance of Installer.



9
10
11
12
# File 'lib/instrumental-components.rb', line 9

def initialize(license_key, email)
  @license_key = license_key
  @email = email
end

Instance Method Details

#installObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/instrumental-components.rb', line 14

def install
  if updating?
    puts "šŸ“„ Updating to the latest version of Instrumental Components..."
  else
    puts "šŸ“„ Downloading the latest version of Instrumental Components..."
  end

  begin
    # Load .env file if it exists (for local development only)
    if File.exist?('.env')
      Dotenv.load
    end

    # Download the latest version of the gem
    download_gem

    puts "šŸ“¦ Installing the gem on your system..."
    install_gem

    puts "šŸ“ Updating Gemfile..."
    update_gemfile

    puts ""
    puts "Running 'bundle install'..."
    run_bundle_install

    if updating?
      puts ""
      puts "šŸ”„ Updating Instrumental Components..."
      system("bundle update instrumental-components-library")
    else
      puts ""
      puts "šŸš€ Running the Instrumental Components installer..."
      run_installer
    end

    puts ""
  rescue => e
    # Display the error message sent by the logic in instrumental.dev's API
    puts "\nāŒ #{e.message}"
    exit(1)
  end
end