Class: MyMediaBlogBase

Inherits:
MyMedia::Base
  • Object
show all
Defined in:
lib/mymedia-blogbase.rb

Instance Method Summary collapse

Constructor Details

#initialize(media_type: 'blog', public_type: 'blog', ext: 'txt', config: nil) ⇒ MyMediaBlogBase

Returns a new instance of MyMediaBlogBase.



12
13
14
15
16
17
18
19
# File 'lib/mymedia-blogbase.rb', line 12

def initialize(media_type: 'blog', public_type: 'blog', ext: 'txt', config: nil)
  
  super(media_type: media_type, public_type: public_type, ext: ext, config: config)
  @media_src = "%s/media/%s" % [@home, @public_type]
  @target_ext = '.html'
  @rss = true
  
end

Instance Method Details

#copy_publish(filename, raw_msg = '') ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mymedia-blogbase.rb', line 22

def copy_publish(filename, raw_msg='')    
 
  src_path = File.join(@media_src, filename)

  raise "tags missing or too many tags" if File.open(src_path,'r')\
        .readlines.last.split.length > 5
  
  file_publish(src_path) do |destination, raw_destination|
    
    raw_msg = ''

    File.open(destination,'w') do |f|

      txt_destination = destination.sub(/html$/,'txt')
      FileUtils.cp src_path, txt_destination
      
      doc = html(File.open(src_path, 'r').read, File.basename(txt_destination))
      raw_msg = microblog_title(doc)
      f.write doc.xml
    end

    FileUtils.cp destination, raw_destination
    
    raw_msg
  end

end