Class: Appraisal::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/appraisal/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)



105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/appraisal/cli.rb', line 105

def method_missing(name, *args, &block)
  matching_appraisal = AppraisalFile.new.appraisals.detect do |appraisal|
    appraisal.name == name.to_s
  end

  if matching_appraisal
    Command.new(args, :gemfile => matching_appraisal.gemfile_path).run
  else
    AppraisalFile.each do |appraisal|
      Command.new(ARGV, :gemfile => appraisal.gemfile_path).run
    end
  end
end

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/appraisal/cli.rb', line 36

def self.exit_on_failure?
  true
end

.help(shell, subcommand = false) ⇒ Object

Override help command to print out usage



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/appraisal/cli.rb', line 11

def self.help(shell, subcommand = false)
  shell.say strip_heredoc(<<-help)
    Appraisal: Find out what your Ruby gems are worth.

    Usage:
      appraisal [APPRAISAL_NAME] EXTERNAL_COMMAND

      If APPRAISAL_NAME is given, only run that EXTERNAL_COMMAND against the given
      appraisal, otherwise it runs the EXTERNAL_COMMAND against all appraisals.
  help

  if File.exist?('Appraisals')
    shell.say
    shell.say 'Available Appraisal(s):'

    AppraisalFile.each do |appraisal|
      shell.say "  - #{appraisal.name}"
    end
  end

  shell.say

  super
end

Instance Method Details

#cleanObject



80
81
82
# File 'lib/appraisal/cli.rb', line 80

def clean
  FileUtils.rm_f Dir['gemfiles/*.{gemfile,gemfile.lock}']
end

#generateObject



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/appraisal/cli.rb', line 67

def generate
  AppraisalFile.each do |appraisal|
    appraisal.write_gemfile
  end

  if options[:travis]
    TravisCIHelper.display_instruction
  else
    TravisCIHelper.validate_configuration_file
  end
end

#installObject



56
57
58
59
60
61
62
63
# File 'lib/appraisal/cli.rb', line 56

def install
  invoke :generate, [], {}

  AppraisalFile.each do |appraisal|
    appraisal.install(options)
    appraisal.relativize
  end
end

#listObject



94
95
96
# File 'lib/appraisal/cli.rb', line 94

def list
  AppraisalFile.new.appraisals.each { |appraisal| puts appraisal.name }
end

#update(*gems) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/appraisal/cli.rb', line 85

def update(*gems)
  invoke :generate, []

  AppraisalFile.each do |appraisal|
    appraisal.update(gems)
  end
end

#versionObject



99
100
101
# File 'lib/appraisal/cli.rb', line 99

def version
  puts "Appraisal #{VERSION}"
end