Class: LearnTest::Dependency

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Dependency

Returns a new instance of Dependency.



5
6
7
# File 'lib/learn_test/dependency.rb', line 5

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/learn_test/dependency.rb', line 3

def options
  @options
end

Instance Method Details

#die(message) ⇒ Object



20
21
# File 'lib/learn_test/dependency.rb', line 20

def die(message)
end

#executeObject



9
10
11
# File 'lib/learn_test/dependency.rb', line 9

def execute
  install if missing?
end

#installObject



17
18
# File 'lib/learn_test/dependency.rb', line 17

def install
end

#mac?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/learn_test/dependency.rb', line 23

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

#missing?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/learn_test/dependency.rb', line 13

def missing?
  false
end


31
32
33
# File 'lib/learn_test/dependency.rb', line 31

def print_installing(name)
  puts "Installing missing dependency #{name}...".green
end

#run_install(command) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/learn_test/dependency.rb', line 35

def run_install(command)
  Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
    while out = stdout.gets do
      puts out
    end

    while err = stderr.gets do
      puts err
    end

    if wait_thr.value.exitstatus != 0
      die("There was an error running #{command}")
    end
  end
end

#win?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/learn_test/dependency.rb', line 27

def win?
  !!RUBY_PLATFORM.match(/mswin|mingw|cygwin/)
end