1
0
mirror of https://github.com/seejohnrun/haste-client.git synced 2026-02-10 09:31:33 +00:00

Initial work

This commit is contained in:
John Crepezzi
2011-11-18 20:26:35 -05:00
commit 6edc98fb82
7 changed files with 107 additions and 0 deletions

36
lib/haste.rb Normal file
View File

@@ -0,0 +1,36 @@
require 'restclient'
require 'json'
module Haste
DEFAULT_URL = 'http://localhost:7777'
class CLI
attr_reader :input
# Pull all of the data from STDIN
def initialize
@input = STDIN.readlines.join
@input.strip!
end
# 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']}"
end
private
def server
return @server if @server
@server = ENV['HASTE_SERVER'] || Haste::DEFAULT_URL
@server.chop! if server.end_with?('/')
@server
end
end
end

5
lib/haste/version.rb Normal file
View File

@@ -0,0 +1,5 @@
module Haste
VERSION = '0.0.1'
end