Class: SiSU_Harvest::Source

Inherits:
Object
  • Object
show all
Includes:
SiSU_Env
Defined in:
lib/sisu/html_harvest.rb

Instance Method Summary collapse

Constructor Details

#initialize(opt) ⇒ Source

Returns a new instance of Source.



65
66
67
68
# File 'lib/sisu/html_harvest.rb', line 65

def initialize(opt)
  @opt=opt
  @env=SiSU_Env::InfoEnv.new
end

Instance Method Details

#cases(opt, env) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/sisu/html_harvest.rb', line 93

def cases(opt,env)
  case opt.selections.str.inspect
  when/--harvest/i
    css(opt) if @opt.act[:maintenance][:set]==:on
    SiSU_HarvestAuthors::Songsheet.new(opt,env).songsheet
    SiSU_HarvestTopics::Songsheet.new(opt,env).songsheet
    if @opt.act[:rsync][:set]==:on
      require_relative 'remote'                         # remote.rb
      SiSU_Remote::Put.new(opt).rsync_harvest
    end
  else
    help
  end
end

#css(opt) ⇒ Object



85
86
87
88
89
90
91
92
# File 'lib/sisu/html_harvest.rb', line 85

def css(opt)
  require_relative 'css'                                # css.rb
  css=SiSU_Style::CSS.new
  fn_css=SiSU_Env::CSS_Default.new
  style=File.new("#{@env.path.pwd}/#{fn_css.harvest}",'w')
  style << css.harvest
  style.close
end

#helpObject



79
80
81
82
83
84
# File 'lib/sisu/html_harvest.rb', line 79

def help
  puts <<WOK
  harvest --harvest   extracts document index metadata

WOK
end

#readObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/sisu/html_harvest.rb', line 69

def read
  begin
    harvest_pth=@env.path.webserv + '/' + @opt.base_stub
    FileUtils::mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth)
    cases(@opt,@env)
  rescue
  ensure
    SiSU_Env::CreateSite.new(@opt).cp_css
  end
end