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)


98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/appraisal/cli.rb', line 98

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


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("Appraisal: Find out what your Ruby gems are worth.\n\nUsage:\nappraisal [APPRAISAL_NAME] EXTERNAL_COMMAND\n\nIf APPRAISAL_NAME is given, only run that EXTERNAL_COMMAND against the given\nappraisal, otherwise it runs the EXTERNAL_COMMAND against all appraisals.\n")

  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


73
74
75
# File 'lib/appraisal/cli.rb', line 73

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

#generateObject


60
61
62
63
64
65
66
67
68
69
70
# File 'lib/appraisal/cli.rb', line 60

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

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

#installObject


49
50
51
52
53
54
55
56
# File 'lib/appraisal/cli.rb', line 49

def install
  invoke :generate, [], {}

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

#listObject


87
88
89
# File 'lib/appraisal/cli.rb', line 87

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

#update(*gems) ⇒ Object


78
79
80
81
82
83
84
# File 'lib/appraisal/cli.rb', line 78

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

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

#versionObject


92
93
94
# File 'lib/appraisal/cli.rb', line 92

def version
  puts "Appraisal #{VERSION}"
end