mirror of
https://github.com/seejohnrun/haste-client.git
synced 2026-01-03 08:59:14 +00:00
Remove dependencies
This commit is contained in:
@@ -5,7 +5,7 @@ spec = Gem::Specification.new do |s|
|
||||
s.name = 'haste'
|
||||
s.author = 'John Crepezzi'
|
||||
s.add_development_dependency('rspec')
|
||||
s.add_dependency('rest-client')
|
||||
s.add_dependency('json')
|
||||
s.description = 'CLI Haste Client'
|
||||
s.email = 'john.crepezzi@gmail.com'
|
||||
s.executables = 'haste'
|
||||
|
||||
17
lib/haste.rb
17
lib/haste.rb
@@ -1,4 +1,3 @@
|
||||
require 'restclient'
|
||||
require 'json'
|
||||
|
||||
module Haste
|
||||
@@ -17,9 +16,19 @@ module Haste
|
||||
|
||||
# Upload the and output the URL we get back
|
||||
def start
|
||||
json = RestClient.post "#{server}/documents", input
|
||||
data = JSON.parse(json)
|
||||
puts "#{server}/#{data['key']}"
|
||||
uri = URI.parse server
|
||||
http = Net::HTTP.new uri.host, uri.port
|
||||
response = http.post '/documents', input
|
||||
if response.is_a?(Net::HTTPOK)
|
||||
data = JSON.parse(response.body)
|
||||
STDOUT.puts "#{server}/#{data['key']}"
|
||||
else
|
||||
STDERR.puts "failure uploading: #{res.status}"
|
||||
end
|
||||
rescue RuntimeError, JSON::ParserError => e
|
||||
STDERR.puts "failure uploading: #{response.code}"
|
||||
rescue Errno::ECONNREFUSED => e
|
||||
STDERR.puts "failure connecting: #{e.message}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user