1
0
mirror of https://github.com/seejohnrun/haste-client.git synced 2025-12-12 23:05:56 +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

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.swp
*.swo
*.gem

37
README.md Normal file
View File

@@ -0,0 +1,37 @@
# Haste Client
haste-client is a simple client for uploading data to haste. Usage is very simple, all you do it pipe data in STDIN:
`cat file | haste`
And once the file makes it to the server, it will print the URL to STDOUT.
This can be really really cool in combination with `pbcopy`, like:
`cat file | haste | pbcopy`
after which the contents of `file` will be accessible at a URL which has been copied to your pasteboard.
## Changing the location of your haste server
By default, haste is expected to be running on `http://localhost:7777`, which I'm sure no one is doing. You can change this by setting the value of ENV['HASTE_SERVER'] to the URL of your haste server. You can use `alias` to make easy shortcuts if you commonly use a few hastes intermingled with each other. To do that, you'd put something like
alias work_haste="HASTE_SERVER=http://something.com haste"
After which you can use `work_haste` to send hastes there.
## Author
John Crepezzi <john.crepezzi@gmail.com>
## License
(The MIT License)
Copyright © 2011 John Crepezzi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

2
TODO Normal file
View File

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

6
bin/haste Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../lib/haste'
cli = Haste::CLI.new
cli.start

18
haste.gemspec Normal file
View File

@@ -0,0 +1,18 @@
require 'rubygems'
require File.dirname(__FILE__) + '/lib/haste/version'
spec = Gem::Specification.new do |s|
s.name = 'haste'
s.author = 'John Crepezzi'
s.add_development_dependency('rspec')
s.add_dependency('restclient')
s.description = 'CLI Haste Client'
s.email = 'john.crepezzi@gmail.com'
s.executables = 'haste'
s.files = Dir['lib/**/*.rb', 'haste']
s.platform = Gem::Platform::RUBY
s.require_paths = ['lib']
s.summary = 'Haste Client'
s.test_files = Dir.glob('spec/*.rb')
s.version = Haste::VERSION
end

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