Top Level Namespace

Defined Under Namespace

Modules: Geordi Classes: Gitpt, PngOptimizer

Instance Method Summary collapse

Instance Method Details

#_setup_vncObject



2
3
4
5
6
7
8
9
10
11
12
13
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
57
58
59
60
61
62
63
64
65
66
# File 'lib/geordi/commands/_setup_vnc.rb', line 2

def _setup_vnc
  `clear`

  note 'This script will help you install a VNC server and a VNC viewer.'
  puts
  puts strip_heredoc <<-TEXT
    With those you will be able to use our cucumber script without being
    disturbed by focus-stealing Selenium windows. Instead, they will open
    inside a VNC session.

    You can still inspect everything with:
  TEXT
  note_cmd 'geordi vnc'
  puts
  note 'Please open a second shell to execute instructions.'
  prompt 'Continue ...'

  announce 'Setup VNC server'

  vnc_server_installed = system('which vncserver > /dev/null 2>&1')
  if vnc_server_installed
    success 'It appears you already have a VNC server installed. Good job!'
  else
    puts 'Please run:'
    note_cmd 'sudo apt-get install vnc4server'
    prompt 'Continue ...'

    puts
    note 'We will now set a password for your VNC server.'
    puts strip_heredoc <<-TEXT
      When running our cucumber script, you will not actually need this
      password, and there is no security risk. However, if you start a vncserver
      without our cucumber script, a user with your password can connect to
      your machine.

    TEXT
    puts 'Please run:'
    note_cmd 'vncserver :20'
    warn 'Enter a secure password!'
    prompt 'Continue ...'

    puts 'Now stop the server again. Please run:'
    note_cmd 'vncserver -kill :20'
    prompt 'Continue ...'
  end

  announce 'Setup VNC viewer'

  vnc_viewer_installed = system('which vncviewer > /dev/null 2>&1')
  if vnc_viewer_installed
    success 'It appears you already have a VNC viewer installed. Good job!'
  else
    puts 'Please run:'
    note_cmd 'sudo apt-get install xtightvncviewer'
    prompt 'Continue ...'
  end

  puts
  puts strip_heredoc <<-TEXT
    All done. Our cucumber script will now automatically run Selenium features
    in VNC.
  TEXT

  success 'Happy cuking!'
end

#apache_site(*args) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/geordi/commands/apache_site.rb', line 2

def apache_site(*args)
  site = args.shift
  old_cwd = Dir.pwd
  Dir.chdir '/etc/apache2/sites-available/'

  # show available sites if no site was passed as argument
  unless site
    puts 'ERROR: Argument site is missing.'
    puts 'Please call: apache-site my-site'
    puts
    puts 'Available sites:'
    Dir.new(".").each do |file|
      puts "- #{file}" if file != '.' && file != '..'
    end
    exit
  end

  has_default = File.exists?('default')
  exec "sudo a2dissite \*; sudo a2ensite #{"default " if has_default}#{site} && sudo apache2ctl restart"
  Dir.chdir old_cwd
end

#bundle_installObject



2
3
4
5
6
7
# File 'lib/geordi/commands/bundle_install.rb', line 2

def bundle_install
  if File.exists?('Gemfile') and !system('bundle check > /dev/null 2>&1')
    announce 'Bundling'
    Util.system! 'bundle install'
  end
end

#capistrano(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/geordi/commands/capistrano.rb', line 6

def capistrano(*args)
  targets = Dir['config/deploy/*.rb'].map { |file| File.basename(file, '.rb') }.sort

  note 'Found the following deploy targets:'
  puts targets
  prompt('Continue?', 'n', /y|yes/) or fail 'Cancelled.'

  targets << nil if targets.empty? # default target
  targets.each do |stage|
    announce 'Target: ' + (stage || '(default)')

    command = "bundle exec cap #{stage} " + args.join(' ')
    note_cmd command

    Util.system!(command, :fail_message => 'Capistrano failed. Have a look!')
  end

end

#cleanObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/geordi/commands/clean.rb', line 2

def clean

  announce 'Removing tempfiles'
  for pattern in %w[ webrat-* capybara-* tmp/webrat-* tmp/capybara-* tmp/rtex/* log/*.log ]
    note pattern
    puts `rm -vfR #{pattern}`
  end

  announce 'Finding recursively and removing backup files'
  for pattern in %w[ *~ ]
    note pattern
    `find . -name #{pattern} -exec rm {} ';'`
  end

end

#commitObject



10
11
12
13
14
15
16
17
18
# File 'lib/geordi/commands/commit.rb', line 10

def commit
  raise <<-TEXT if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1')
Unsupported Ruby Version #{RUBY_VERSION}. `geordi commit` does not work with a Ruby version < 2.1.
  TEXT

  require 'geordi/gitpt'

  Gitpt.new.run
end

#console(target = 'development', *args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/geordi/commands/console.rb', line 11

def console(target = 'development', *args)
  require 'geordi/remote'

  if target == 'development'
    announce 'Opening a local Rails console'

    Util.system! Util.console_command(target)

  else
    announce 'Opening a Rails console on ' + target

    Geordi::Remote.new(target).console(options)
  end
end

#create_database_ymlObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/geordi/commands/create_database_yml.rb', line 2

def create_database_yml
  real_yml = 'config/database.yml'
  sample_yml = 'config/database.sample.yml'

  if File.exists?(sample_yml) and not File.exists?(real_yml)
    announce 'Creating ' + real_yml

    print 'Please enter your DB password: '
    db_password = STDIN.gets.strip

    sample = File.read(sample_yml)
    real = sample.gsub(/password:.*$/, "password: #{db_password}")
    File.open(real_yml, 'w') { |f| f.write(real) }

    note "Created #{real_yml}."
  end
end

#create_databasesObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/geordi/commands/create_databases.rb', line 2

def create_databases
  invoke_cmd 'create_database_yml'
  invoke_cmd 'bundle_install'

  announce 'Creating databases'

  if File.exists?('config/database.yml')
    command = 'bundle exec rake db:create:all'
    command << ' parallel:create' if Util.file_containing?('Gemfile', /parallel_tests/)

    Util.system! command
  else
    puts 'config/database.yml does not exist. Nothing to do.'
  end
end

#cucumber(*args) ⇒ Object



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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/geordi/commands/cucumber.rb', line 31

def cucumber(*args)
  if args.empty?
    # This is not testable as there is no way to stub `git` :(
    if options.modified?
      modified_features = `git status --short`.split($/).map do |line|
        indicators = line.slice!(0..2) # Remove leading indicators
        line if line.include?('.feature') and not indicators.include?('D')
      end.compact
      args = modified_features
    end

    if options.containing
      matching_features = `grep -lri '#{options.containing}' --include=*.feature features/`.split($/)
      args = matching_features.uniq
    end
  end

  if File.directory?('features')
    require 'geordi/cucumber'

    invoke_cmd 'bundle_install'
    invoke_cmd 'yarn'

    cmd_opts, files = args.partition { |f| f.start_with? '-' }
    cmd_opts << '--format' << 'pretty' << '--backtrace' if options.debug

    announce 'Running features'

    # Serial run of @solo scenarios
    if files.any? { |f| f.include? ':' }
      note '@solo run skipped when called with line numbers' if options.verbose
    else
      solo_files = if files.empty?
        'features' # Proper grepping
      else
        files.join(' ')
      end

      solo_tag_usages = `grep -r '@solo' #{ solo_files }`.split("\n")

      if solo_tag_usages.any?
        solo_cmd_opts = cmd_opts.dup
        solo_cmd_opts << '--tags' << '@solo'

        announce 'Running @solo features'
        Geordi::Cucumber.new.run files, solo_cmd_opts, :verbose => options.verbose, :parallel => false
      end
    end

    # Normal run
    unless Geordi::Cucumber.new.run(files, cmd_opts, :verbose => options.verbose)
      cmd_opts << '--profile' << 'rerun'

      # Reruns
      (1 + options.rerun).times do |i|
        fail 'Features failed.' if (i == options.rerun) # All reruns done?

        announce "Rerun ##{ i + 1 } of #{ options.rerun }"
        break if Geordi::Cucumber.new.run(files, cmd_opts, :verbose => options.verbose, :parallel => false)
      end
    end

  else
    note 'Cucumber not employed.'
  end
end

#delete_dumps(dump_directory = nil) ⇒ Object



13
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
# File 'lib/geordi/commands/delete_dumps.rb', line 13

def delete_dumps(dump_directory = nil)
  deletable_dumps = []
  if dump_directory.nil?
    dump_directories = [
      File.join(Dir.home, 'dumps'),
      Dir.pwd
    ]
  else
    dump_directories = [dump_directory]
  end
  announce 'Looking for *.dump in ' << dump_directories.join(',')
  dump_directories.each do |d|
    d2 = File.expand_path(d)
    unless File.directory? File.realdirpath(d2)
      warn "Directory #{d2} does not exist"
      next
    end
    deletable_dumps.concat(Dir.glob("#{d2}/**/*.dump"))
  end
  if deletable_dumps.empty?
    success 'No dumps to delete' if deletable_dumps.empty?
    exit 0
  end
  deletable_dumps.uniq!.sort!
  note 'The following dumps can be deleted:'
  puts
  puts deletable_dumps
  prompt 'Delete those dumps', 'n', /y|yes/ or fail 'Cancelled.'
  deletable_dumps.each do |dump|
    File.delete dump unless File.directory? dump
  end
end

#deploy(target_stage = nil) ⇒ Object



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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/geordi/commands/deploy.rb', line 32

def deploy(target_stage = nil)
  # Set/Infer default values
  branch_stage_map = { 'master' => 'staging', 'production' => 'production'}
  if target_stage and not Util.deploy_targets.include? target_stage
    # Target stage autocompletion from available stages
    target_stage = Util.deploy_targets.find { |t| t.start_with? target_stage }
  end
  proposed_stage = target_stage || branch_stage_map.fetch(Util.current_branch, 'staging')

  # Ask for required information
  target_stage = prompt 'Deployment stage:', proposed_stage
  source_branch = prompt 'Source branch:', Util.current_branch
  target_branch = prompt 'Deploy branch:', branch_stage_map.invert.fetch(target_stage, 'master')

  merge_needed = (source_branch != target_branch)
  push_needed = merge_needed || `git cherry -v | wc -l`.strip.to_i > 0

  announce "Checking whether your #{source_branch} branch is ready"
  if `git status -s | wc -l`.strip != '0'
    warn "Your #{source_branch} branch holds uncommitted changes."
    prompt('Continue anyway?', 'n', /y|yes/) or fail 'Cancelled.'
  else
    note 'All good.'
  end

  if merge_needed
    announce "Checking what's in your #{target_branch} branch right now" #######
    Util.system! "git checkout #{target_branch} && git pull"
  end

  announce 'You are about to:' #################################################
  note "Merge branch #{source_branch} into #{target_branch}" if merge_needed
  if push_needed
    note 'Push these commits:' if push_needed
    Util.system! "git --no-pager log origin/#{target_branch}..#{source_branch} --oneline"
  end
  note "Deploy to #{target_stage}"

  if prompt('Go ahead with the deployment?', 'n', /y|yes/)
    capistrano_call = "cap #{target_stage} deploy"
    capistrano_call << ':migrations' unless Util.capistrano3? || options.no_migrations
    capistrano_call = "bundle exec #{capistrano_call}" if Util.file_containing?('Gemfile', /capistrano/)

    invoke_cmd 'bundle_install'
    invoke_cmd 'yarn'

    puts
    commands = []
    commands << "git merge #{source_branch}" if merge_needed
    commands << 'git push' if push_needed
    commands << capistrano_call
    Util.system! commands.join(' && '), :show_cmd => true

    success 'Deployment complete.'
  else
    fail 'Deployment cancelled.'
  end

end

#drop_databasesObject



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
57
58
59
# File 'lib/geordi/commands/drop_databases.rb', line 29

def drop_databases
  require 'geordi/db_cleaner'
  fail '-P and -M are mutually exclusive' if options.postgres_only and options.mysql_only
  mysql_flags = nil
  postgres_flags = nil

  unless options.mysql.nil?
    begin
      mysql_port = Integer(options.mysql)
      mysql_flags = "--port=#{mysql_port} --protocol=TCP"
    rescue AttributeError
      unless File.exist? options.mysql
        fail "Path #{options.mysql} is not a valid MySQL socket"
      end
      mysql_flags = "--socket=#{options.mysql}"
    end
  end

  unless options.postgres.nil?
    postgres_flags = "--port=#{options.postgres}"
  end

  extra_flags = {'mysql' => mysql_flags,
                 'postgres' => postgres_flags
  }
  cleaner = DBCleaner.new(extra_flags)
  cleaner.clean_mysql unless options.postgres_only
  cleaner.clean_postgres unless options.mysql_only

  success 'Done.'
end

#dump(target = nil, *args) ⇒ Object



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
57
58
59
60
61
62
63
# File 'lib/geordi/commands/dump.rb', line 26

def dump(target = nil, *args)
  require 'geordi/dump_loader'
  require 'geordi/remote'

  if target.nil?
    if options.load
      # validate load option
      fail 'Missing a dump file.' if options.load == 'load'
      File.exists?(options.load) or fail 'Could not find the given dump file: ' + options.load

      loader = DumpLoader.new(options.load)

      announce "Sourcing dump into the #{loader.config['database']} db"
      loader.load

      success "Your #{loader.config['database']} database has now the data of #{options.load}."

    else
      announce 'Dumping the development database'
      Util.system! 'dumple development'
      success 'Successfully dumped the development database.'
    end

  else
    announce 'Dumping the database of ' + target
    dump_path = Geordi::Remote.new(target).dump(options)

    if options.load
      loader = DumpLoader.new(dump_path)

      announce "Sourcing dump into the #{loader.config['database']} db"
      loader.load

      success "Your #{loader.config['database']} database has now the data of #{target}."
    end
  end

end

#eurestObject



2
3
4
# File 'lib/geordi/commands/eurest.rb', line 2

def eurest
  Util.system! %{file="Speiseplan_KW`date +%V`.pdf" && wget -O/tmp/$file http://www.eurest-extranet.de/eurest/export/sites/default/sigma-technopark/de/downloads/$file && xdg-open /tmp/$file}
end

#firefox(*command) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/geordi/commands/firefox.rb', line 16

def firefox(*command)
  if options.setup
    fail 'Firefox version required (e.g. --setup 24.0)' if options.setup == 'setup'

    require 'geordi/firefox_for_selenium'
    Geordi::FirefoxForSelenium.install(options.setup)

  else
    require 'geordi/cucumber'

    Cucumber.new.setup_vnc
    FirefoxForSelenium.setup_firefox

    puts
    note_cmd command.join(' ')
    system *command # Util.system! would reset the Firefox PATH
  end
end

#migrateObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/geordi/commands/migrate.rb', line 10

def migrate
  invoke_cmd 'bundle_install'
  invoke_cmd 'yarn'
  announce 'Migrating'

  if File.directory?('db/migrate')
    if Util.file_containing?('Gemfile', /parallel_tests/)
      note 'Development and parallel test databases'
      puts

      Util.system! 'bundle exec rake db:migrate parallel:prepare'
    else
      invoke_cmd 'rake', 'db:migrate'
    end
  else
    note 'No migrations directory found.'
  end
end

#png_optimize(path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/geordi/commands/png_optimize.rb', line 10

def png_optimize(path)
  require 'fileutils'

  announce 'Optimizing .png files'

  if `which pngcrush`.strip.empty?
    fail 'Please install pngcrush first (sudo apt-get install pngcrush)'
  end

  po = PngOptimizer.new
  if File.directory?(path)
    po.batch_optimize_inplace(path)
  elsif File.file?(path)
    po.optimize_inplace(path)
  else
    fail 'Neither directory nor file: ' + path
  end

  success 'PNG optimization completed.'
end

#rake(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/geordi/commands/rake.rb', line 12

def rake(*args)
  for env in %w(development test cucumber) # update long_desc when changing this
    if File.exists? "config/environments/#{env}.rb"
      call = %w[bundle exec rake] + args + ["RAILS_ENV=#{env}"]
      note_cmd call.join(' ')

      Util.system! *call
    end
  end
end

#remove_executable_flagsObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/geordi/commands/remove_executable_flags.rb', line 2

def remove_executable_flags
  announce 'Removing executable-flags'

  patterns = %w[
    *.rb *.html *.erb *.haml *.yml *.css *.sass *.rake *.png *.jpg
    *.gif *.pdf *.txt *.rdoc *.feature Rakefile VERSION README Capfile
  ]
  for pattern in patterns
    note pattern
    `find . -name "#{pattern}" -exec chmod -x {} ';'`
  end
  puts 'Done.'
end

#rspec(*files) ⇒ Object



9
10
11
12
13
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
# File 'lib/geordi/commands/rspec.rb', line 9

def rspec(*files)
  if File.exists?('spec/spec_helper.rb')
    invoke_cmd 'bundle_install'
    invoke_cmd 'yarn'

    announce 'Running specs'

    if Util.file_containing?('Gemfile', /parallel_tests/) and files.empty?
      note 'All specs at once (using parallel_tests)'
      Util.system! 'bundle exec rake parallel:spec', :fail_message => 'Specs failed.'

    else
      # tell which specs will be run
      if files.empty?
        files << 'spec/'
        note 'All specs in spec/'
      else
        note 'Only: ' + files.join(', ')
      end

      command = ['bundle exec']
      command << if File.exists?('script/spec')
        'spec -c' # RSpec 1
      elsif File.exists?('bin/rspec')
        'bin/rspec'
      else
        'rspec'
      end
      command << '-r rspec_spinner -f RspecSpinner::Bar' if Util.file_containing?('Gemfile', /rspec_spinner/)
      command << files.join(' ')

      puts
      Util.system! command.join(' '), :fail_message => 'Specs failed.'
    end
  else
    note 'RSpec not employed.'
  end
end

#security_update(step = 'prepare') ⇒ Object



11
12
13
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
# File 'lib/geordi/commands/security_update.rb', line 11

def security_update(step='prepare')
  case step
  when 'prepare'
    announce 'Preparing for security update'
    warn 'Please read https://makandracards.com/makandra/1587 before applying security updates!'
    note 'About to checkout production and pull'
    prompt('Continue?', 'y', /y|yes/) or fail 'Cancelled.'

    Util.system! 'git checkout production', :show_cmd => true
    Util.system! 'git pull', :show_cmd => true

    success 'Successfully prepared for security update'
    puts
    note 'Please apply the security update now and commit your changes.'
    note 'When you are done, run `geordi security-update finish`.'


  when 'f', 'finish'
    # ensure everything is committed
    `git status --porcelain`.empty? or fail('Please commit your changes before finishing the update.')

    announce 'Finishing security update'
    note 'Working directory clean.'
    prompt('Have you successfully run all tests?', 'n', /y|yes/) or fail 'Please run tests first.'

    note 'About to: push production, checkout & pull master, merge production, push master'
    prompt('Continue?', 'n', /y|yes/) or fail 'Cancelled.'

    Util.system! 'git push', :show_cmd => true
    Util.system! 'git checkout master', :show_cmd => true
    Util.system! 'git pull', :show_cmd => true
    Util.system! 'git merge production', :show_cmd => true
    Util.system! 'git push', :show_cmd => true

    announce 'Deploying all targets'
    deploy = Util.capistrano3? ? 'deploy' : 'deploy:migrations'
    invoke_cmd 'capistrano', deploy

    success 'Successfully pushed and deployed security update'
    puts
    note 'Now send an email to customer and project lead, informing them about the update.'
    note 'Do not forget to make a joblog on a security budget, if available.'
  end
end

#server(port = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/geordi/commands/server.rb', line 8

def server(port = nil)
  invoke_cmd 'bundle_install'
  invoke_cmd 'yarn'
  require 'geordi/util'

  announce 'Booting a development server'
  port ||= options.port
  note "URL: http://#{ File.basename(Dir.pwd) }.vcap.me:#{port}"
  puts

  command = Util.server_command
  command << ' -b 0.0.0.0' if options.public
  command << ' -p ' << port
  Util.system! command
end

#setupObject



25
26
27
28
29
30
31
32
33
# File 'lib/geordi/commands/setup.rb', line 25

def setup
  invoke_cmd 'create_databases'
  invoke_cmd 'migrate'

  success 'Successfully set up the project.'

  invoke_cmd 'dump', options.dump, :load => true if options.dump
  invoke_cmd 'tests' if options.test
end

#shelll(target, *args) ⇒ Object

This method has a triple ‘l’ because :shell is a Thor reserved word. However, it can still be called with ‘geordi shell` :)



14
15
16
17
18
19
# File 'lib/geordi/commands/shell.rb', line 14

def shelll(target, *args)
  require 'geordi/remote'

  announce 'Opening a shell on ' + target
  Geordi::Remote.new(target).shell(options)
end

#testsObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/geordi/commands/tests.rb', line 2

def tests
  rake_result = invoke_cmd 'with_rake'

  if rake_result == :did_not_perform
    # Since `rake` usually runs all tests, only run them here if `rake` did not
    # perform
    invoke_cmd 'unit'
    invoke_cmd 'rspec'
    invoke_cmd 'cucumber'
  end

  success 'Successfully ran tests.'
end

#unitObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/geordi/commands/unit.rb', line 2

def unit
  if File.exists?('test/test_helper.rb')
    invoke_cmd 'bundle_install'
    invoke_cmd 'yarn'

    announce 'Running Test::Unit'
    Util.system! 'bundle exec rake test'
  else
    note 'Test::Unit not employed.'
  end
end

#updateObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/geordi/commands/update.rb', line 23

def update
  announce 'Updating repository'
  Util.system! 'git pull', :show_cmd => true

  invoke_cmd 'migrate'

  success 'Successfully updated the project.'

  invoke_cmd 'dump', options.dump, :load => true if options.dump
  invoke_cmd 'tests' if options.test
end

#versionObject



2
3
4
5
# File 'lib/geordi/commands/version.rb', line 2

def version
  require 'geordi/version'
  puts 'Geordi ' + Geordi::VERSION
end

#vncObject



13
14
15
16
17
18
19
20
# File 'lib/geordi/commands/vnc.rb', line 13

def vnc
  if options.setup
    invoke_cmd :_setup_vnc
  else
    require 'geordi/cucumber'
    Geordi::Cucumber.new.launch_vnc_viewer
  end
end

#with_rakeObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/geordi/commands/with_rake.rb', line 2

def with_rake
  if Util.file_containing?('Rakefile', /^task.+default.+(spec|test|feature)/)
    invoke_cmd 'bundle_install'
    invoke_cmd 'yarn'

    announce 'Running tests with `rake`'
    Util.system! 'rake'
  else
    note '`rake` does not run tests.'
    :did_not_perform
  end
end

#yarnObject



3
4
5
6
7
# File 'lib/geordi/commands/yarn.rb', line 3

def yarn
  if File.exists?('package.json')
    Util.system! 'yarn'
  end
end