Class: SiSU_Info_File::InfoFile

Inherits:
SiSU_Info_Env::InfoEnv show all
Defined in:
lib/sisu/se_file_op.rb

Overview

se_info_env.rb

Direct Known Subclasses

SiSU_Env::InfoFile, SiSU_File_Op::FileOp

Instance Attribute Summary

Attributes inherited from SiSU_Info_Env::InfoEnv

#base_markup_dir_stub, #env, #etc, #filename, #flv, #fnb, #fnn, #fnt, #home, #hostname, #processing_git, #rc, #stub_pwd, #stub_src, #sys, #user, #webserv_host_cgi, #webserv_path, #webserv_port_cgi, #www, #yamlrc_dir

Attributes inherited from SiSU_Env_Call::EnvCall

#ad, #fnb, #fnn, #fnt, #fnv, #fnz, #rc

Instance Method Summary collapse

Methods inherited from SiSU_Info_Env::InfoEnv

#arch, #asciidoc_ocn?, #bin, #build, #cgi, #cgi_sample_search_form_name, #cjk, #cjk_ja, #cjk_ko, #cjk_zh, #composite_file, #concord_max, #console_web_browser, #console_www_browser, #current_document, #defaults, #digest, #digest_conf?, #dir_url, #docbook_viewer, #encoding, #epub, #epub_bld, #epub_cp_images, #epub_viewer, #feed, #feed_home, #fictionbook_viewer, #file_encoding, #font, #git, #host, #html, #html_minitoc?, #html_navigation?, #html_navigation_bar?, #html_quick_ref?, #html_right_pane?, #html_scroll_1, #html_scroll_2, #html_search_form?, #html_seg_1, #html_seg_2, #html_seg_title_banner?, #html_top_band?, #i18n, #image_external, #image_source, #image_source_include, #image_source_include_local, #image_source_include_remote, #image_source_sisu_includes, #images, #images_epub, #images_external, #images_local, #landscape, #lang_filename, #language, #language_default_set, #length, #links_to_manifest?, #listed?, #local, #locale, #localhost, #lout, #main, #make, #man, #manifest?, #manifest_minitoc?, #manpage, #manpage_generator, #manpage_viewer, #markdown_ocn?, #markup_emphasis, #metadata?, #minitoc?, #mono, #ocn?, #odf, #odf_pth, #odf_viewer, #odt, #odt_bld, #odt_ocn?, #omit_list, #orgmode_ocn?, #output, #output_tell, #papersize, #path, #path_rel_links, #paths, #pattern, #pdf, #pdf_viewer, #pdflatex, #php, #plaintext_ocn?, #plaintext_wrap, #po, #port, #portrait, #postgresql, #pot, #processing_base_tmp, #processing_path, #processing_sisupod, #program, #promo?, #pwd, #rbver, #read_source_file, #read_source_file_array, #read_source_file_string, #remote, #rexml, #rmagick, #root, #root_dir, #rst_ocn?, #sample_data, #sample_search_form_title, #sans, #scripts, #search?, #search_action, #search_fixed?, #search_form, #search_form?, #search_form_static, #segsubtoc?, #serif, #share, #sisupod_gen, #sisupod_gen_v2, #sisupod_gen_v3, #sisupod_v2, #sisupod_v3, #sisupod_v4, #sisurc_path, #sitearch, #size, #source_file_path, #source_file_processing_array, #source_file_with_path, #sql, #sqlite, #src_pod, #src_txt, #stub_dir, #stub_dir_orig, #stub_epub, #stub_md_harvest, #stub_pod, #style, #tex, #texi, #texinfo, #texpdf, #texpdf_hyperlinks, #text_editor, #textile_ocn?, #tidy, #tmp_root_dir, #toc?, #txt, #type, #url, #usr_dir?, #wc, #web_browser, #webrick, #webrick_port, #webserv, #webserv_base, #webserv_base_cgi, #webserv_cgi, #webserv_dir, #webserv_files_from_db, #webserv_host_base, #webserv_image, #webserv_map_pwd, #webserv_stub_ensure, #widget, #widget_static, #www_browser, #xml_docbook_ocn?, #xml_editor, #xml_fictionbook_ocn?, #xml_scaffold_ocn?, #xml_viewer, #yamlrc

Methods inherited from SiSU_Env_Call::EnvCall

#by?, #by_filename?, #by_filetype?, #by_language_code?, #default_language?, #document_language_versions_found, #dump?, #filename, #lang, #mono_multi_lingual?, #multilingual?, #output_dir_structure, #published_manifests?, #redirect?

Constructor Details

#initialize(fns) ⇒ InfoFile

todo unify with FileOp



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/sisu/se_file_op.rb', line 69

def initialize(fns)
  begin
    super(fns)
    @fns=fns
    @env=SiSU_Env::InfoEnv.new(@fns)
    m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm)$/
    @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3]
  rescue
    SiSU_Screen::Ansi.new('',$!,$@).rescue do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
  end
end

Instance Method Details

#aoObject



159
160
161
162
# File 'lib/sisu/se_file_op.rb', line 159

def ao
  FileUtils::mkdir_p(@env.processing_path.ao) \
    unless FileTest.directory?(@env.processing_path.ao)
end

#ao_contentObject



109
110
111
112
# File 'lib/sisu/se_file_op.rb', line 109

def ao_content
  @env.processing_path.ao + '/' \
    + @fns + '.content.rbm'
end

#ao_idx_htmlObject



121
122
123
124
# File 'lib/sisu/se_file_op.rb', line 121

def ao_idx_html
  @env.processing_path.ao + '/' \
    + @fns + '.idx_html.rbm'
end

#ao_idx_sst_relObject

used by tex & odf



117
118
119
120
# File 'lib/sisu/se_file_op.rb', line 117

def ao_idx_sst_rel #used by tex & odf
  @env.processing_path.ao + '/' \
    + @fns + '.idx_raw.rbm'
end

#ao_idx_sst_rel_html_segObject



113
114
115
116
# File 'lib/sisu/se_file_op.rb', line 113

def ao_idx_sst_rel_html_seg
  @env.processing_path.ao + '/' \
    + @fns + '.idx_sst.rbm'
end

#ao_idx_xhtmlObject



125
126
127
128
# File 'lib/sisu/se_file_op.rb', line 125

def ao_idx_xhtml
  @env.processing_path.ao + '/' \
    + @fns + '.idx_xhtml.rbm'
end

#ao_map_nametagsObject



133
134
135
136
# File 'lib/sisu/se_file_op.rb', line 133

def ao_map_nametags
  @env.processing_path.ao + '/' \
    + @fns + '.map_name_tags.rbm'
end

#ao_map_ocn_htmlsegObject



137
138
139
140
# File 'lib/sisu/se_file_op.rb', line 137

def ao_map_ocn_htmlseg
  @env.processing_path.ao + '/' \
    + @fns + '.map_ocn_htmlseg.rbm'
end

#ao_metadataObject



129
130
131
132
# File 'lib/sisu/se_file_op.rb', line 129

def 
  @env.processing_path.ao + '/' \
    + @fns + '.metadata.rbm'
end

#basefilenameObject

Remove if possible



83
84
85
86
# File 'lib/sisu/se_file_op.rb', line 83

def basefilename #Remove if possible
  m=/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/m
  @fns[m,1]
end

#html_tuneObject



141
142
143
144
# File 'lib/sisu/se_file_op.rb', line 141

def html_tune
  @env.processing_path.tune + '/' \
    + @fns + '.marshal_tune'
end

#make_file(path, filename) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/sisu/se_file_op.rb', line 87

def make_file(path,filename)
  (File.writable?("#{path}/.")) \
  ? File.new("#{path}/#{filename}",'w+')
  : (SiSU_Screen::Ansi.new(
      '',
      "*WARN* is the file or directory writable?, could not create #{filename}"
    ).warn)
end

#make_path(path) ⇒ Object



105
106
107
# File 'lib/sisu/se_file_op.rb', line 105

def make_path(path)
  FileUtils::mkdir_p(path) unless FileTest.directory?(path)
end

#marshalObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/sisu/se_file_op.rb', line 108

def marshal
  def ao_content
    @env.processing_path.ao + '/' \
      + @fns + '.content.rbm'
  end
  def ao_idx_sst_rel_html_seg
    @env.processing_path.ao + '/' \
      + @fns + '.idx_sst.rbm'
  end
  def ao_idx_sst_rel #used by tex & odf
    @env.processing_path.ao + '/' \
      + @fns + '.idx_raw.rbm'
  end
  def ao_idx_html
    @env.processing_path.ao + '/' \
      + @fns + '.idx_html.rbm'
  end
  def ao_idx_xhtml
    @env.processing_path.ao + '/' \
      + @fns + '.idx_xhtml.rbm'
  end
  def 
    @env.processing_path.ao + '/' \
      + @fns + '.metadata.rbm'
  end
  def ao_map_nametags
    @env.processing_path.ao + '/' \
      + @fns + '.map_name_tags.rbm'
  end
  def ao_map_ocn_htmlseg
    @env.processing_path.ao + '/' \
      + @fns + '.map_ocn_htmlseg.rbm'
  end
  def html_tune
    @env.processing_path.tune + '/' \
      + @fns + '.marshal_tune'
  end
  def xhtml_tune
    @env.processing_path.tune + '/' \
      + @fns + '.marshal_tune'
  end
  self
end

#mkdirObject

check moved from FileOp, existing mkdir



157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/sisu/se_file_op.rb', line 157

def mkdir #check moved from FileOp, existing mkdir
  def processing
    def ao
      FileUtils::mkdir_p(@env.processing_path.ao) \
        unless FileTest.directory?(@env.processing_path.ao)
    end
    def tune
      FileUtils::mkdir_p(@env.processing_path.tune) \
        unless FileTest.directory?(@env.processing_path.tune)
    end
    self
  end
end

#processingObject



158
159
160
161
162
163
164
165
166
167
168
# File 'lib/sisu/se_file_op.rb', line 158

def processing
  def ao
    FileUtils::mkdir_p(@env.processing_path.ao) \
      unless FileTest.directory?(@env.processing_path.ao)
  end
  def tune
    FileUtils::mkdir_p(@env.processing_path.tune) \
      unless FileTest.directory?(@env.processing_path.tune)
  end
  self
end

#touch_file(path, filename) ⇒ Object



95
96
97
98
99
100
101
102
103
104
# File 'lib/sisu/se_file_op.rb', line 95

def touch_file(path,filename)
  if File.writable?("#{path}/.");
    FileUtils::touch("#{path}/#{filename}")
  else
    SiSU_Screen::Ansi.new(
      '',
      "*WARN* is the file or directory writable?, could not create #{filename}"
    ).warn
  end
end

#tuneObject



163
164
165
166
# File 'lib/sisu/se_file_op.rb', line 163

def tune
  FileUtils::mkdir_p(@env.processing_path.tune) \
    unless FileTest.directory?(@env.processing_path.tune)
end

#write_file_processingObject



151
152
153
154
155
156
# File 'lib/sisu/se_file_op.rb', line 151

def write_file_processing
  def html_tune
    File.new("#{@env.processing_path.tune}/#{@fns}.tune",'w+')
  end
  self
end

#xhtml_tuneObject



145
146
147
148
# File 'lib/sisu/se_file_op.rb', line 145

def xhtml_tune
  @env.processing_path.tune + '/' \
    + @fns + '.marshal_tune'
end