Skip to content

Instantly share code, notes, and snippets.

@BukhariH
Created July 31, 2014 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BukhariH/08c748dd90ad12b03f6a to your computer and use it in GitHub Desktop.
Save BukhariH/08c748dd90ad12b03f6a to your computer and use it in GitHub Desktop.
require 'json'
require 'net/http'
require 'uri'
require 'rbconfig'
require 'io/console'
puts "Enter Username:"
@username = gets.chomp
puts "Enter Password (input will be hidden):"
@password = STDIN.noecho(&:gets).chomp
puts "\n"
puts "\n"
puts "\n"
BASE_URL = "http://elder.herokuapp.com/apps"
@os ||= (
host_os = RbConfig::CONFIG['host_os']
case host_os
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
:windows
when /darwin|mac os/
:macosx
when /linux/
:linux
when /solaris|bsd/
:unix
else
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
end
)
def send_data(apps_data, platform)
uri = URI.parse(BASE_URL)
response = Net::HTTP.post_form(uri, {"username" => @username,
"password" => @password,
"apps" => apps_data,
"platform" => platform,
})
if JSON.parse(response.body)[":success"] == true
puts "Sync Successful"
else
puts "Sync Failed"
end
end
if @os == :macosx
Dir.chdir "/Applications"
apps = []
Dir['*.app'].each do |fname|
apps.push(fname.chomp(File.extname(fname)))
end
send_data(URI.escape(apps.to_json), "Mac OSX")
else
puts "Platfrom not recognised."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment