Class: Pbind::Command

Inherits:
CLAide::Command
  • Object
show all
Defined in:
lib/pbind/command.rb,
lib/pbind/command/mock.rb,
lib/pbind/command/watch.rb

Direct Known Subclasses

Mock, Watch

Defined Under Namespace

Classes: Mock, Watch

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.



43
44
45
46
47
# File 'lib/pbind/command.rb', line 43

def initialize(argv)
  super

  @project_path = argv.option('project')
end

Class Method Details

.optionsObject



37
38
39
40
41
# File 'lib/pbind/command.rb', line 37

def self.options
  [
    ['--project=path/to/Project.xcodeproj', 'The path of the XcodeProject.']
  ].concat(super)
end

.report_error(exception) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pbind/command.rb', line 19

def self.report_error(exception)
  case exception
  when Interrupt
    puts ''
    puts '[!] Cancelled'.red
  when SystemExit
    raise
  else
    # if ENV['PBIND_ENV'] != 'development'
    #   puts UI::ErrorReport.report(exception)
    #   UI::ErrorReport.search_for_exceptions(exception)
    #   exit 1
    # else
      raise exception
    # end
  end
end

Instance Method Details

#runObject



49
50
51
52
53
# File 'lib/pbind/command.rb', line 49

def run
  if !@changed
    UI.notice 'All are UP-TO-DATE.'
  end
end

#verify_project_existsObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/pbind/command.rb', line 55

def verify_project_exists
  if @project_path == nil
    projects = Dir.glob("*.xcodeproj")
    num_project = projects.length

    help! 'No `*.xcodeproj\' found in the project directory.' if num_project == 0
    help! "Could not automatically select an Xcode project. Specify one in your arguments like so:\
    \n\n    --project=path/to/Project.xcodeproj" unless num_project == 1

    @project_path = projects[0]
  else
    help! 'The Xcode project should ends with `*.xcodeproj`.' unless @project_path.end_with?('.xcodeproj')
    absolute_path = File.absolute_path(@project_path)
    help! "Unable to find the Xcode project `#{absolute_path}`." unless File.exists?(absolute_path)
  end
end