Module: Mines

Extended by:
Mines
Included in:
Mines
Defined in:
bin/mines,
lib/utilities.rb,
lib/utilities.rb,
lib/utilities.rb

Defined Under Namespace

Modules: Generator, Help, Utilities Classes: Cli

Instance Method Summary collapse

Instance Method Details

#gem_exists?(gem) ⇒ Boolean

Examines if a gem axists

Parameters:

  • gem (String)

    the gem’s name

Returns:

  • (Boolean)

    If gem exists or not



42
43
44
# File 'lib/utilities.rb', line 42

def gem_exists? gem
  ! Gem::Specification.find_all_by_name(gem).empty?
end

#in_app_root?Boolean

Check if mines is executed inside a mines application directory

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/utilities.rb', line 14

def in_app_root?
  # simply check if basic dirs exist
  %w{ miners lib log config config/application.rb}.each do |file|
    return false if not File.exists?(file)
  end
  return true
end

#mines_app_checkObject

Exit if mines is invokated outside application root



23
24
25
26
27
28
29
30
31
# File 'lib/utilities.rb', line 23

def mines_app_check
  if not in_app_root?
    print "It seems your current directory: "
    puts File.expand_path('.').yellow
    puts "does not contains a Mines application."
    puts "You can create one by invoking: " + "mines new APPNAME".blue.bold
    exit 0
  end
end