Sha256: 262df25c5cca35a95faaa73b2c2ec92a8e2c150bd7a459db93e275d44a47af4c

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

module Granify
  class Cfg
    def bootstrap!
      begin
        # configure Notifaction gem
        Notify.configure do |c|
          c.plugins = []
        end

        if Utils.has_internet_connection?
          # check for package updates
          status = Command::Exec.global("(cd #{Granify::INSTALLED_DIR} && git fetch origin && git diff master origin/master) 2>&1")

          if !status.empty?
            Notify.warning("You are running an outdated version of #{Granify::PACKAGE_NAME}, please run `rbtils update` to update")
          end
        else
          Notify.warning("Update check could not be performed because you are not connected to the internet")
        end

        # check for missing dependencies
        missing = []

        # test if we have all the required commands before sending anything to
        # handlers
        Granify::SHELL_COMMANDS[Utils.os].each do |command|
          Command::Exec.global("type \"#{command}\" > /dev/null 2>&1")

          if $?.exitstatus != 0
            missing.push("- "+ command)
          end
        end

        if !missing.empty?
          Notify.error("Required system commands and/or configuration variables are not installed:\n#{missing.join("\n")}")
        end

        if missing.size > 0
          # try to install the missing commands
          #Command::Exec.global("npm install --silent -g #{missing.join(' ')}")

          # commented out for now as it currently does nothing
          # if $?.exitstatus > 0
          #   # TODO: implement other auto-install commands such as apt-get
          # end
        end
      rescue => e
        Notify.error("#{e.to_s}\n#{e.backtrace.join("\n")}")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rbtils-0.0.2 lib/config.rb
rbtils-0.0.1 lib/config.rb