Class: Publish::PublishReplication

Inherits:
Hobix::BasePublish show all
Defined in:
lib/hobix/publish/replicate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Hobix::BasePlugin

inherited, start

Constructor Details

#initialize(blog, hash_opt) ⇒ PublishReplication

Returns a new instance of PublishReplication.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/hobix/publish/replicate.rb', line 48

def initialize( blog, hash_opt )
  @weblog = blog
  hash_opt['items'] = nil
  hash_opt['source'] = weblog.output_path
  
  if ENV['HOBIX_ENV'] == "production"
    @production = true
    #
    # Change link if a production one is given
    #
    blog.link = hash_opt['production_link'] || blog.link
  else
    @production = false
  end

  if hash_opt['target'] =~ /^ftp:\/\/([^:]+):([^@]+)@([^\/]+)(\/.*)$/
    tgt = Target.new($4,$3,$1,$2)

    @replicator = ReplicateFtp::new(hash_opt, tgt)
  else
    #
    # File replication
    #
    tgt = Target.new(hash_opt['target'])
    @replicator = ReplicateFS.new(hash_opt, tgt)	  

  end
end

Instance Attribute Details

#productionObject (readonly)

Returns the value of attribute production.



46
47
48
# File 'lib/hobix/publish/replicate.rb', line 46

def production
  @production
end

#replicatorObject (readonly)

Returns the value of attribute replicator.



46
47
48
# File 'lib/hobix/publish/replicate.rb', line 46

def replicator
  @replicator
end

#weblogObject (readonly)

Returns the value of attribute weblog.



46
47
48
# File 'lib/hobix/publish/replicate.rb', line 46

def weblog
  @weblog
end

Instance Method Details

#publish(page_name) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/hobix/publish/replicate.rb', line 81

def publish( page_name )
  return unless production
  replicator.items = weblog.updated_pages.map { |o| o.link }
  replicator.copy do |nb,f,src,tgt|
    puts "## Replicating #{src}"
  end
end

#watchObject



77
78
79
# File 'lib/hobix/publish/replicate.rb', line 77

def watch
  ['index']
end