1
0
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:
John Crepezzi
2011-11-19 01:19:26 -05:00
parent 4b6ccdfe5c
commit d8b998a994
3 changed files with 14 additions and 6 deletions

1
TODO
View File

@@ -1,2 +1 @@
tests
remove dependencies

View File

@@ -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'

View File

@@ -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