class Maintainer::CocoapodRunner

Public Class Methods

add_pod(pod: nil) click to toggle source
# File lib/maintainer_core/cocoapodRunner.rb, line 25
def add_pod(pod: nil)
    puts "HELLO"
    self.install_cocoapods!() if !self.are_cocoapods_installed!
    self.create_podfile! if !File.file?("Podfile")
    self.adding_pod_message(pod: pod)

    file = File.open("Podfile", "a+")
    Writer.file_replace(file, /use_frameworks!.*/i) do |match| 
        "#{match}\n\tpod '#{pod}'"
    end

    file.close
    self.pod_update!
    MaintainerUpdater.new_pod(podname: pod)
end
adding_pod_message(pod: nil) click to toggle source
# File lib/maintainer_core/cocoapodRunner.rb, line 61
def adding_pod_message(pod: nil)
    Writer.newline!
    Writer.write(message: "Writing the pod #{pod} to Podfile")
end
are_cocoapods_installed!() click to toggle source
# File lib/maintainer_core/cocoapodRunner.rb, line 15
def are_cocoapods_installed!()
    version = CommandRunner.execute(command: Commands::Cocoapods::Version, error: nil)
    
    if  /^(\d+)(.\d+)?(.\d+)?$/ =~ version 
        return true
    end
    puts "VERSION: #{version}"
    return false
end
create_podfile!(path = nil) click to toggle source
# File lib/maintainer_core/cocoapodRunner.rb, line 41
def create_podfile!(path =  nil)
    Writer.newline!
    Writer.write(message: "Did not find podfile...Creating a new one for you")
    CommandRunner.execute(command: Commands::Cocoapods::Init, error: nil)

    if !File.file?("Podfile")
        error(
            message: "Error while trying to set up podfile",
            willExit: true
        ) 
    else
        success(message: "Podfile set up - Successful 🤘")
    end

end
error(message: nil, willExit: nil) click to toggle source
# File lib/maintainer_core/cocoapodRunner.rb, line 70
def error(message: nil, willExit: nil)
    Writer.show_error(message: message)
    exit(0) if willExit
end
install_cocoapods!() click to toggle source
# File lib/maintainer_core/cocoapodRunner.rb, line 9
def install_cocoapods!()
    Writer.write(message: "Seems like you don't have cocoapods installed on your machine. Would you like me to set that up for you?")
    Writer.write(message: "Awesome! This will require sudo access. Sudo access means .... but don't worry, you'll be entering it directly into your machine, I can't see what you type.")
    CommandRunner.execute(command: Commands::Cocoapods::Install, error: nil)
end
pod_update!() click to toggle source
# File lib/maintainer_core/cocoapodRunner.rb, line 57
def pod_update!()
    CommandRunner.execute(command: Commands::Cocoapods::Update, error: nil)
end
success(message: nil) click to toggle source
# File lib/maintainer_core/cocoapodRunner.rb, line 66
def success(message: nil)
    Writer.show_success(message: message)
end
uninstall_cocoapods!() click to toggle source
# File lib/maintainer_core/cocoapodRunner.rb, line 5
def uninstall_cocoapods!()
    CommandRunner.execute(command: Commands::Cocoapods::Uninstall, error: nil)
end