A small menubar app that allows you to switch between R versions quickly (if you have multiple versions of R framework installed). https://rud.is/rswitch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
920 B

//
// RStudioUtils.swift
// RSwitch
//
// Created by hrbrmstr on 9/6/19.
// Copyright © 2019 Bob Rudis. All rights reserved.
//
import Foundation
import Just
class RStudioUtils {
private static let dailyCleanerRegex = try!NSRegularExpression(
pattern: "https://s3.amazonaws.com/rstudio-ide-build/desktop/macos/RStudio-|.dmg",
options: NSRegularExpression.Options.caseInsensitive
)
public static func latestVersionURL() -> URL? {
let res = Just.head("https://www.rstudio.org/download/latest/daily/desktop/mac/RStudio-latest.dmg", timeout: 10)
return(res.url)
}
public static func latestVersionNumber(fromString : String? = nil) -> String {
let urlString = (fromString == nil) ? latestVersionURL()!.absoluteString : fromString!
return(dailyCleanerRegex.stringByReplacingMatches(in: urlString, options: [], range: NSMakeRange(0, urlString.count), withTemplate: ""))
}
}