Browse files

Initial commit.

  • Loading branch information...
0 parents commit 6987619a1b4c629f693e0ec751b438b8bd37fd17 @jbarnette committed May 22, 2008
Showing with 150 additions and 0 deletions.
  1. +6 −0 History.txt
  2. +8 −0 Manifest.txt
  3. +48 −0 README.txt
  4. +8 −0 Rakefile
  5. +76 −0 bin/backpack-journal
  6. +1 −0 lib/backpack-journal.rb
  7. +3 −0 lib/backpack-journal/version.rb
  8. 0 test/test_backpack-journal.rb
6 History.txt
@@ -0,0 +1,6 @@
+=== 1.0.0 / 2008-05-22
+
+* 1 major enhancement
+
+ * Birthday!
+
8 Manifest.txt
@@ -0,0 +1,8 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/backpack-journal
+lib/backpack-journal.rb
+lib/backpack-journal/version.rb
+test/test_backpack-journal.rb
48 README.txt
@@ -0,0 +1,48 @@
+= backpack-journal
+
+* FIX (url)
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2008 FIX
+
+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.
8 Rakefile
@@ -0,0 +1,8 @@
+require "rubygems"
+require "hoe"
+
+require "./lib/backpack-journal/version.rb"
+
+Hoe.new("backpack-journal", BackpackJournal::VERSION) do |p|
+ p.developer("John Barnette", "jbarnette@rubyforge.org")
+end
76 bin/backpack-journal
@@ -0,0 +1,76 @@
+#!/usr/bin/env ruby
+
+require "rubygems"
+require "pathname"
+require "thor"
+
+require "net/http"
+require "uri"
+
+module BackpackJournal
+ class CLI < Thor
+ IDENTITY = Pathname.new(File.expand_path("~/.backpack-journal"))
+
+ desc "setup USER_ID TOKEN", "set up your Backpack identity"
+ def setup(user_id, token)
+ save_identity(user_id, token)
+ end
+
+ desc "status MESSAGE", "set your current status"
+ def status(message)
+ user_id, token = load_identity
+
+ user_id, token = load_identity
+
+ url = URI.parse("http://adready.backpackit.com/users/#{user_id}/status.xml")
+
+ body =<<-END
+ <request>
+ <token>#{token}</token>
+ <status>
+ <message>#{message}</message>
+ </status>
+ </request>
+ END
+
+ request = Net::HTTP::Put.new(url.path)
+ request.body = body.strip
+ request.set_content_type("application/xml")
+ response = Net::HTTP.new(url.host, url.port).start { |h| h.request(request) }
+ end
+
+ desc "entry MESSAGE", "add a journal entry"
+ def entry(message)
+ user_id, token = load_identity
+
+ url = URI.parse("http://adready.backpackit.com/users/#{user_id}/journal_entries.xml")
+
+ body =<<-END
+ <request>
+ <token>#{token}</token>
+ <journal-entry>
+ <body>#{message}</body>
+ </journal-entry>
+ </request>
+ END
+
+ request = Net::HTTP::Post.new(url.path)
+ request.body = body.strip
+ request.set_content_type("application/xml")
+ response = Net::HTTP.new(url.host, url.port).start { |h| h.request(request) }
+ end
+
+ private
+
+ def save_identity(user_id, token)
+ IDENTITY.open("w") { |i| i.write("#{user_id},#{token}") }
+ end
+
+ def load_identity
+ abort("No identity: run backpack-journal setup") unless IDENTITY.exist?
+ IDENTITY.read.split(",")
+ end
+ end
+end
+
+BackpackJournal::CLI.start
1 lib/backpack-journal.rb
@@ -0,0 +1 @@
+require "backpack-journal/version"
3 lib/backpack-journal/version.rb
@@ -0,0 +1,3 @@
+module BackpackJournal
+ VERSION = "1.0.0".freeze
+end
0 test/test_backpack-journal.rb
No changes.

0 comments on commit 6987619

Please sign in to comment.