class MyMedia::Publisher

Public Class Methods

new(opts={}) click to toggle source
# File lib/mymedia.rb, line 24
def initialize(opts={})
  @index_page = true
  @opts = opts
end

Protected Instance Methods

publish_dynarex(dynarex_filepath='', \ record={title: '',url: '', raw_url: ''}, options={}) click to toggle source
# File lib/mymedia.rb, line 31
def publish_dynarex(dynarex_filepath='', \
      record={title: '',url: '', raw_url: ''}, options={})
  
  opt = {id: nil, rss: false}.merge(options)

  dynarex = if File.exists? dynarex_filepath then
    Dynarex.new(dynarex_filepath)
  else
    Dynarex.new(@schema)
  end

  dynarex.create record, id: opt[:id]
  dynarex.save dynarex_filepath
  publish_html(dynarex_filepath)  if @index_page == true

  
  if opt[:rss] == true then

    dynarex.xslt_schema = dynarex.summary[:xslt_schema]
    rss_filepath = dynarex_filepath.sub(/\.xml$/,'_rss.xml')
    File.open(rss_filepath, 'w'){|f| f.write dynarex.to_rss }    
  end

end
publish_html(filepath) click to toggle source
# File lib/mymedia.rb, line 56
    def publish_html(filepath)

      path2 = File.dirname(filepath)  
      template_path = File.join path2, 'index-template.html'

      return unless @index_page == true 
      raise MyMediaPublisherException, \
          "template path: #{template_path} not found" unless \
                                                    File.exists?(template_path)
=begin jr 040916      
      dataisland = DataIsland.new(template_path, @opts)

      File.open(path2 + '/index.html','w'){|f| f.write dataisland.html_doc.xml pretty: true}
=end
    end
send_message(topic: @sps[:default_subscriber], msg: '') click to toggle source
# File lib/mymedia.rb, line 72
def send_message(topic: @sps[:default_subscriber], msg: '')

  fqm = "%s: %s" % [topic, msg]    

  SPSPub.notice fqm, address: @sps[:address]
  sleep 0.02
end