bin/atom-client.rb in atom-tools-0.9.0 vs bin/atom-client.rb in atom-tools-0.9.1
- old
+ new
@@ -1,14 +1,14 @@
#!/usr/bin/ruby
# syntax: ./atom-client.rb <introspection-url> [username] [password]
-# a
+# a really simple YAML-and-$EDITOR based Publishing Protocol client
require "tempfile"
require "atom/yaml"
-require "atom/app"
+require "atom/service"
require "atom/http"
require "rubygems"
require "bluecloth"
@@ -42,11 +42,11 @@
class Atom::Entry
def prepare_for_output
filter_hook
- update!
+ updated!
end
def filter_hook
# so much for actual text content...
if @content and @content["type"] == "text"
@@ -56,21 +56,21 @@
end
def edit
yaml = YAML.load(self.to_yaml)
- # humans don't care about these things
+ # humans don't care about these things, we can replace it later
yaml.delete "id"
if yaml["links"]
yaml["links"].delete(yaml["links"].find { |l| l["rel"] == "edit" })
yaml["links"].delete(yaml["links"].find { |l| l["rel"] == "alternate" })
yaml.delete("links") if yaml["links"].empty?
end
entry = write_entry(yaml.to_yaml)
- # the id doesn't appear in YAML, it should remain the same
+
entry.id = self.id
entry
end
end
@@ -98,15 +98,18 @@
def choose_collection server
puts "which collection?"
collections = []
- # still lame
- server.collections.each_with_index do |coll, index|
- collections << coll
+ # flatten it out into one big workspace
+ server.workspaces.each do |ws|
+ puts ws.title.to_s + ":"
+ ws.collections.each_with_index do |coll, index|
+ collections << coll
- puts "#{index}: #{coll.title}"
+ puts "#{index}: #{coll.title}"
+ end
end
choose_from collections
end
@@ -179,10 +182,10 @@
http = Atom::HTTP.new
http.user = ARGV[1]
http.pass = ARGV[2]
-server = Atom::App.new(introspection_url, http)
+server = Atom::Service.new(introspection_url, http)
coll = choose_collection server
# XXX the server should *probably* replace this, but who knows yet?
CLIENT_ID = "http://necronomicorp.com/dev/null"