Sha256: 09e8f8f8076b22e5e36998e65004534ce8bb62ab41128cf8631a42ff77d00496
Contents?: true
Size: 1.58 KB
Versions: 4
Compression:
Stored size: 1.58 KB
Contents
# frozen_string_literal: true module Meroku # Logic related to Consumer Apps class App extend Meroku::User extend Meroku::ResponseHandler def self.create(name) raise Meroku::Error, 'Not in a git repository' unless Dir.exist?('.git') data = { 'token' => saved_token, 'name' => name }.to_json result = RestClient.post 'https://www.meroku.com/apps.json', data, content_type: :json process_error(result) process_success(result) { add_git_remote(result) } end def self.delete_app(name) data = { 'name' => name, 'token' => saved_token } result = RestClient::Request.execute( method: :delete, url: 'https://www.meroku.com/apps.json', headers: { params: data } ) process_error(result) process_success(result) end def self.list_apps result = RestClient.get 'https://www.meroku.com/apps.json', params: { 'token' => saved_token }, content_type: :json process_error(result) process_success(result) do JSON.parse(result).dig('data', 'apps_names').each do |k| puts k end end end def self.add_git_remote(result) username = JSON.parse(result).dig('data', 'username') appname = JSON.parse(result).dig('data', 'name') remote_uri = "#{username}@www.meroku.com:#{appname}.git" Kernel.system('git remote remove meroku 2>/dev/null') puts Kernel.system("git remote add meroku #{remote_uri}") end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
meroku-2.0.31 | lib/meroku/app.rb |
meroku-2.0.30 | lib/meroku/app.rb |
meroku-2.0.29 | lib/meroku/app.rb |
meroku-2.0.28 | lib/meroku/app.rb |