Class: LearnTest::Jasmine::PhantomChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_test/jasmine/phantom_checker.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.check_installationObject



4
5
6
# File 'lib/learn_test/jasmine/phantom_checker.rb', line 4

def self.check_installation
  new.check_installation
end

Instance Method Details

#brew_installed?Boolean



25
26
27
# File 'lib/learn_test/jasmine/phantom_checker.rb', line 25

def brew_installed?
  !`which brew`.empty?
end

#check_installationObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/learn_test/jasmine/phantom_checker.rb', line 8

def check_installation
  if running_on_mac?
    if !brew_installed?
      puts "You must have Homebrew installed."
      exit
    else
      if !phantom_installed_on_mac?
        install_phantomjs
      end
    end
  else
    if !phantom_installed_on_linux?
      puts "You must have PhantomJS installed: http://phantomjs.org/download.html"
    end
  end
end

#install_phantomjsObject



45
46
47
# File 'lib/learn_test/jasmine/phantom_checker.rb', line 45

def install_phantomjs
  `brew install phantomjs`
end

#phantom_installed?Boolean



41
42
43
# File 'lib/learn_test/jasmine/phantom_checker.rb', line 41

def phantom_installed?
  !`which phantomjs`.empty?
end

#phantom_installed_by_brew?Boolean



37
38
39
# File 'lib/learn_test/jasmine/phantom_checker.rb', line 37

def phantom_installed_by_brew?
  !`brew ls --versions phantomjs`.empty?
end

#phantom_installed_on_linux?Boolean



33
34
35
# File 'lib/learn_test/jasmine/phantom_checker.rb', line 33

def phantom_installed_on_linux?
  phantom_installed?
end

#phantom_installed_on_mac?Boolean



29
30
31
# File 'lib/learn_test/jasmine/phantom_checker.rb', line 29

def phantom_installed_on_mac?
  phantom_installed_by_brew? || phantom_installed?
end

#running_on_mac?Boolean



49
50
51
# File 'lib/learn_test/jasmine/phantom_checker.rb', line 49

def running_on_mac?
  !!RUBY_PLATFORM.match(/darwin/)
end