Class: Pod::MessageBank

Inherits:
Object
  • Object
show all
Defined in:
lib/yk_command/project/setup/MessageBank.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ MessageBank

Returns a new instance of MessageBank.



5
6
7
# File 'lib/yk_command/project/setup/MessageBank.rb', line 5

def initialize(config)
  @configurator = config
end

Instance Attribute Details

#configuratorObject (readonly)

Returns the value of attribute configurator.



3
4
5
# File 'lib/yk_command/project/setup/MessageBank.rb', line 3

def configurator
  @configurator
end

Instance Method Details

#farewell_messageObject



61
62
63
64
65
66
67
68
# File 'lib/yk_command/project/setup/MessageBank.rb', line 61

def farewell_message
  puts ""

  puts " Ace! you're ready to go!"
  puts " We will start you off by opening your project in Xcode"
  pod_name = @configurator.pod_name
  run_command "open '#{$current_dir}/Example/#{pod_name}.xcworkspace'", "open '#{$current_dir}/Example/#{pod_name}.xcworkspace'"
end

#green_bangObject



17
18
19
# File 'lib/yk_command/project/setup/MessageBank.rb', line 17

def green_bang
  "! ".green
end

#red_bangObject



21
22
23
# File 'lib/yk_command/project/setup/MessageBank.rb', line 21

def red_bang
  "! ".red
end

#run_command(command, output_command = nil) ⇒ Object



25
26
27
28
29
30
# File 'lib/yk_command/project/setup/MessageBank.rb', line 25

def run_command command, output_command=nil
  output_command ||= command

  puts "  " + output_command.magenta
  system command
end

#run_setup_questionsObject



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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/yk_command/project/setup/MessageBank.rb', line 71

def run_setup_questions

  puts yellow_bang + "Before you can create a new library we need to setup your git credentials."

  unless @configurator.user_name.length > 0
    puts "\n What is your name? "
    answer = ""

    loop do
      show_prompt

      answer = gets.chomp
      break if answer.length > 0

      puts red_bang + "Please enter a name."
    end

    puts ""
    puts green_bang + "Setting your name in git to " + answer
    run_command('git config user.name "' + answer + '"')
  end

  unless @configurator.user_email.length > 0
    puts "\n What is your email?"
    answer = ""

    loop do
      show_prompt
      answer = gets.downcase.chomp
      break if answer.length > 0

      puts red_bang + "Please enter a email."
    end

    puts ""
    puts green_bang + "Setting your email in git to " + answer
    run_command('git config user.email "' + answer + '"')
  end

end

#show_promptObject



9
10
11
# File 'lib/yk_command/project/setup/MessageBank.rb', line 9

def show_prompt
  print " > ".green
end

#welcome_messageObject



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/yk_command/project/setup/MessageBank.rb', line 32

def welcome_message
  unless @configurator.validate_user_details
    run_setup_questions
  end

  puts "\n------------------------------"
  puts ""
  puts "To get you started we need to ask a few questions, this should only take a minute."
  puts ""

  has_run_before = `defaults read org.cocoapods.pod-template HasRunBefore`.chomp == "1"

  puts "If this is your first time we recommend running through with the guide: "
  puts " - "  + "https://guides.cocoapods.org/making/using-pod-lib-create.html".blue.underlined

  if ENV["TERM_PROGRAM"] == "iTerm.app"
    puts " ( hold cmd and click links to open in a browser. )".magenta
  else
    puts " ( hold cmd and double click links to open in a browser. )".magenta
  end

  unless has_run_before
    puts "\n Press return to continue."
    `defaults write org.cocoapods.pod-template HasRunBefore -bool true`
  end

  puts ""
end

#yellow_bangObject



13
14
15
# File 'lib/yk_command/project/setup/MessageBank.rb', line 13

def yellow_bang
  "! ".yellow
end