Class: GerminateAtompub::AtompubPublisher
- Inherits:
-
Germinate::Publisher
- Object
- Germinate::Publisher
- GerminateAtompub::AtompubPublisher
- Defined in:
- lib/germinate-atompub/atompub_publisher.rb
Constant Summary collapse
- TEXT_PATH =
File.('../text.yml', File.dirname(__FILE__))
- Q_DEFAULTS =
lambda {|q| q.readline = true}
Instance Method Summary collapse
-
#initialize(name, librarian, options = {}) ⇒ AtompubPublisher
constructor
A new instance of AtompubPublisher.
- #publish!(output = $stdout, extra_options = {}) ⇒ Object
Constructor Details
#initialize(name, librarian, options = {}) ⇒ AtompubPublisher
Returns a new instance of AtompubPublisher.
81 82 83 |
# File 'lib/germinate-atompub/atompub_publisher.rb', line 81 def initialize(name, librarian, ={}) super end |
Instance Method Details
#publish!(output = $stdout, extra_options = {}) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/germinate-atompub/atompub_publisher.rb', line 85 def publish!(output=$stdout, = {}) entry.content = input.join entry.content['type'] = 'html' entry.updated! response = if entry.edit_url log.info "Updating entry at #{entry.edit_url}" collection.put!(entry) else log.info "Posting entry to #{collection.href}" response = collection.post!(entry) end log.debug "Response: #{response.inspect}" log.debug "Response body:\n #{response.read_body}" entry_url = entry.edit_url || response['Location'] log.info "Posted/updated article at #{entry_url}" librarian.variables['ATOMPUB_ENTRY_URL'] = entry_url librarian.variables['ATOMPUB_COLLECTION_URL'] = collection_url librarian.variables['ATOMPUB_LOGIN'] = login end |