Class: SiSU_Env_Call::EnvCall

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/se_envcall.rb

Direct Known Subclasses

SiSU_Env::EnvCall, SiSU_Info_Env::InfoEnv

Constant Summary collapse

@@ad =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fns = '') ⇒ EnvCall

Returns a new instance of EnvCall.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/sisu/se_envcall.rb', line 66

def initialize(fns='')
  @fns=fns
  @sys=SiSU_Info_Sys::InfoSystem.instance
  get_init=SiSU_Env::GetInit.new
  @rc=get_init.sisu_yaml.rc
  @ad=get_init.ads
  if @fns \
  and @fns != '' \
  and @fns !=@@fns
    @@fns,@@fnn,@@fnb,@@fnt,@@flv,@@fnz=@fns,nil,nil,nil,nil,nil
  end
  if @fns \
  and @fns != '' #watch
    m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/
    @@fnn ||=@fns[m,1]
    @@fnb ||=@fns[m,2]
    @@fnt ||=@fns[m,3]
    @@flv ||=document_language_versions_found[:f]
    unless @@fns =~/\S+?\.txz/
      @@fnz ||=if @@fns =~/(?:\~\S{2,3})?\.(?:ssm\.sst|ssm)$/; @@fnb + '.ssm.txz'
      elsif @@fnb; @@fnb + '.sst.txz'
      else '' # e.g. termsheet
      end
    end
  end
  @fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz
end

Instance Attribute Details

#adObject

Returns the value of attribute ad.



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

def ad
  @ad
end

#fnbObject

Returns the value of attribute fnb.



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

def fnb
  @fnb
end

#fnnObject

Returns the value of attribute fnn.



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

def fnn
  @fnn
end

#fntObject

Returns the value of attribute fnt.



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

def fnt
  @fnt
end

#fnvObject

Returns the value of attribute fnv.



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

def fnv
  @fnv
end

#fnzObject

Returns the value of attribute fnz.



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

def fnz
  @fnz
end

#rcObject

Returns the value of attribute rc.



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

def rc
  @rc
end

Instance Method Details

#by?Boolean

Returns:

  • (Boolean)


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
151
152
# File 'lib/sisu/se_envcall.rb', line 122

def by?
  output_structure=:filename #set default output structure
  if @rc \
  && defined? @rc['output_dir_structure_by']
    output_structure=if (@rc['output_dir_structure_by'] =~/dump/) \
    or ((defined? @rc['output_structure']['dump']) \
    && @rc['output_structure']['dump'] ==true)
      :dump
    elsif (@rc['output_dir_structure_by'] =~/redirect/) \
    or ((defined? @rc['output_structure']['redirect']) \
    && @rc['output_structure']['redirect'] ==true)
      :redirect
    elsif (@rc['output_dir_structure_by'] =~/language/) \
    or ((defined? @rc['output_structure']['by_language']) \
    && @rc['output_structure']['by_language'] ==true)
      :language
    elsif (@rc['output_dir_structure_by'] =~/filetype/) \
    or ((defined? @rc['output_structure']['by_filetype']) \
    && @rc['output_structure']['by_filetype'] ==true)
      :filetype
    elsif (@rc['output_dir_structure_by'] =~/filename/) \
    or ((defined? @rc['output_structure']['by_filename']) \
    && @rc['output_structure']['by_filename'] ==true)
      :filename
    else #set default
      :language
    end
  else #set default
    :language
  end
end

#by_filename?Boolean

Returns:

  • (Boolean)


173
174
175
176
177
# File 'lib/sisu/se_envcall.rb', line 173

def by_filename?
  ((by?) ==:filename) \
  ? true
  : false
end

#by_filetype?Boolean

Returns:

  • (Boolean)


168
169
170
171
172
# File 'lib/sisu/se_envcall.rb', line 168

def by_filetype?
  ((by?) ==:filetype) \
  ? true
  : false
end

#by_language_code?Boolean

Returns:

  • (Boolean)


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

def by_language_code?
  ((by?) ==:language) \
  ? true
  : false
end

#default_language?Boolean

Returns:

  • (Boolean)


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

def default_language?
  if @rc \
  && defined? @rc['language_default']
    if (@rc['language_default'].is_a?(String)) \
    && (@rc['language_default'] =~/#{Px[:lng_lst_rgx]}/)
      @rc['language_default']
    else 'en'
    end
  else 'en'
  end
end

#document_language_versions_foundObject

REVISIT



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/sisu/se_envcall.rb', line 183

def document_language_versions_found #REVISIT
  @fn={}
  filename=(@fns =~/\.ssm\.sst$/) \
  ? @fns.gsub(/\.ssm\.sst$/,'.ssm')
  : @fns
  if filename.is_a?(String) \
  and not filename.empty?
    if output_dir_structure.by_language_code?
      m=/((.+?)(?:\~\w{2,3})?)\.(sst|ssm)$/
      @fn[:b],@fn[:m],@fn[:t]=filename[m,1],filename[m,2],filename[m,3]
    else m=/(.+?)\.(sst|ssm)$/
      @fn[:b]=@fn[:m]=filename[m,1]
      @fn[:t]=filename[m,2]
    end
  end
  lng_base=SiSU_Env::InfoEnv.new.language_default_set
  lang=SiSU_Env::StandardiseLanguage.new
  langs=lang.codes
  x=[]
  if FileTest.file?("#{@fn[:m]}.#{@fn[:t]}")
    n=@fn[:m].gsub(/^.+?\//,'')
    n =n + '.' + @fn[:t]
    x << { f: "#{@fn[:m]}.#{@fn[:t]}", l: lng_base, n: n }
  end
  langs.each do |l|
    lng=SiSU_Env::StandardiseLanguage.new(l)
    if FileTest.file?("#{@fn[:m]}~#{lng.code}.#{@fn[:t]}")
      x << { f: "#{@fn[:m]}~#{lng.code}.#{@fn[:t]}", l: lng.code }
    elsif FileTest.file?("#{@fn[:m]}~#{lng.name}.#{@fn[:t]}")
      x << { f: "#{@fn[:m]}~#{lng.name}.#{@fn[:t]}", l: lng.code }
    end
    if FileTest.file?("#{lng.code}/#{@fn[:m]}~#{lng.code}.#{@fn[:t]}")
      if FileTest.file?("#{lng.code}/#{@fn[:m]}~#{lng.code}.#{@fn[:t]}")
        x << { f: "#{lng.code}/#{@fn[:m]}~#{lng.code}.#{@fn[:t]}", l: lng.code }
      elsif FileTest.file?("#{lng.code}/#{@fn[:m]}~#{lng.name}.#{@fn[:t]}")
        x << { f: "#{lng.code}/#{@fn[:m]}~#{lng.name}.#{@fn[:t]}", l: lng.code }
      end
    end
    if FileTest.file?("#{lng.code}/#{@fn[:m]}.#{@fn[:t]}")
      if FileTest.file?("#{lng.code}/#{@fn[:m]}.#{@fn[:t]}")
        x << { f: "#{lng.code}/#{@fn[:m]}.#{@fn[:t]}", l: lng.code }
      elsif FileTest.file?("#{lng.code}/#{@fn[:m]}.#{@fn[:t]}")
        x << { f: "#{lng.code}/#{@fn[:m]}.#{@fn[:t]}", l: lng.code }
      end
    end
  end
  @fn[:f]=x
  @fn
end

#dump?Boolean

Returns:

  • (Boolean)


153
154
155
156
157
# File 'lib/sisu/se_envcall.rb', line 153

def dump?
  ((by?) ==:dump) \
  ? true
  : false
end

#filename(code, name, suffix) ⇒ Object



272
273
274
# File 'lib/sisu/se_envcall.rb', line 272

def filename(code,name,suffix)
  "#{name}#{suffix}"
end

#lang(code) ⇒ Object



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/sisu/se_envcall.rb', line 275

def lang(code)
  {
    html:            filename(code,'','.html'),
    book_index:      filename(code,'book_index','.html'),
    concordance:     filename(code,'concordance','.html'),
    sax:             filename(code,'sax','.xml'),
    dom:             filename(code,'dom','.xml'),
    docbook:         filename(code,'docbook','.xml'),
    xhtml:           filename(code,'scroll','.xhtml'),
    pdf_l:           filename(code,'','.pdf'),
    pdf_p:           filename(code,'','.pdf'),
    pdf_l_a4:        filename(code,"a4",'.pdf'),
    pdf_p_a4:        filename(code,"a4",'.pdf'),
    pdf_l_a5:        filename(code,"a5",'.pdf'),
    pdf_p_a5:        filename(code,"a5",'.pdf'),
    pdf_l_b5:        filename(code,"b5",'.pdf'),
    pdf_p_b5:        filename(code,"b5",'.pdf'),
    pdf_l_letter:    filename(code,"letter",'.pdf'),
    pdf_p_letter:    filename(code,"letter",'.pdf'),
    pdf_l_legal:     filename(code,"legal",'.pdf'),
    pdf_p_legal:     filename(code,"legal",'.pdf'),
    toc:             filename(code,'toc','.html'),
    doc:             filename(code,fnb,'.html'),
    index:           filename(code,'index','.html'),
    po:              filename(code,@fns,'.po'),
    pot:             filename(code,@fns,'.pot'),
    odf:             filename(code,'','.odt'),
    epub:            filename(code,'','.epub'),
    plain:           filename(code,'','.txt'),
    qrcode:          filename(code,'','.jpg'),
    manpage:         filename(code,'','.1'),          #fix, section number
    wiki:            filename(code,'wiki','.txt'),
    digest:          filename(code,'digest','.txt'),
    metadata:        filename(code,'metadata','.html'), #chk
    manifest:        filename(code,'manifest','.html'),
    oai_pmh:         filename(code,'oai_pmh','.xml'),
    sitemap:         filename(code,'sitemap','.xml'),
    sitemap_touch:   filename(code,"sitemap_#{fnb}",'.xml'),
    sxs:             filename(code,fnb,'.sxs.xml'),
    sxd:             filename(code,fnb,'.sxd.xml'),
    sxn:             filename(code,fnb,'.sxn.xml'),
    sisupod:         filename(nil,@fnz,''),
    book_idx_html:   filename(code,'book_index','.html'),
    book_idx_epub:   filename(code,'book_index','.xhtml'),
    epub_concord:    filename(code,'concordance','.xhtml'),
  }
end

#mono_multi_lingual?Boolean

Returns:

  • (Boolean)


104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/sisu/se_envcall.rb', line 104

def mono_multi_lingual?
  if @rc \
  && defined? @rc['output_dir_structure_by']
    if @rc['output_dir_structure_by'] \
    =~/dump/
      :mono
    elsif @rc['output_dir_structure_by'] \
    =~/language|redirect/
      :multi
    elsif @rc['output_dir_structure_by'] \
    =~/monolingual|filetype_mono|filenaneme_mono/
      :mono
    else :multi
    end
  else :multi
  end
end

#multilingual?Boolean

Returns:

  • (Boolean)


178
179
180
# File 'lib/sisu/se_envcall.rb', line 178

def multilingual?
  by_language_code?
end

#output_dir_structureObject



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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/sisu/se_envcall.rb', line 121

def output_dir_structure
  def by?
    output_structure=:filename #set default output structure
    if @rc \
    && defined? @rc['output_dir_structure_by']
      output_structure=if (@rc['output_dir_structure_by'] =~/dump/) \
      or ((defined? @rc['output_structure']['dump']) \
      && @rc['output_structure']['dump'] ==true)
        :dump
      elsif (@rc['output_dir_structure_by'] =~/redirect/) \
      or ((defined? @rc['output_structure']['redirect']) \
      && @rc['output_structure']['redirect'] ==true)
        :redirect
      elsif (@rc['output_dir_structure_by'] =~/language/) \
      or ((defined? @rc['output_structure']['by_language']) \
      && @rc['output_structure']['by_language'] ==true)
        :language
      elsif (@rc['output_dir_structure_by'] =~/filetype/) \
      or ((defined? @rc['output_structure']['by_filetype']) \
      && @rc['output_structure']['by_filetype'] ==true)
        :filetype
      elsif (@rc['output_dir_structure_by'] =~/filename/) \
      or ((defined? @rc['output_structure']['by_filename']) \
      && @rc['output_structure']['by_filename'] ==true)
        :filename
      else #set default
        :language
      end
    else #set default
      :language
    end
  end
  def dump?
    ((by?) ==:dump) \
    ? true
    : false
  end
  def redirect?
    ((by?) ==:redirect) \
    ? true
    : false
  end
  def by_language_code?
    ((by?) ==:language) \
    ? true
    : false
  end
  def by_filetype?
    ((by?) ==:filetype) \
    ? true
    : false
  end
  def by_filename?
    ((by?) ==:filename) \
    ? true
    : false
  end
  def multilingual?
    by_language_code?
  end
  self
end

#published_manifests?(output_base) ⇒ Boolean

Returns:

  • (Boolean)


232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/sisu/se_envcall.rb', line 232

def published_manifests?(output_base)
  @fn={}
  @m=[]
  unless (@fns.nil? \
  or @fns.empty?)
    if output_dir_structure.by_language_code?
      m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst$)/
      @fn[:b],@fn[:m],@fn[:t]=@fns[m,1],@fns[m,2],@fns[m,3]
    else m=/(.+?)\.((?:-|ssm\.)?sst$)/
      @fn[:b]=@fn[:m]=@fns[m,1]
      @fn[:t]=@fns[m,2]
    end
  end
  lang=SiSU_Env::StandardiseLanguage.new
  langs=lang.codes
  x=[]
  if FileTest.file?("#{@fn[:m]}.#{@fn[:t]}"); x << "#{@fn[:m]}.#{@fn[:t]}"
  end
  dir=SiSU_Env::InfoEnv.new(@fns)
  @m << { m: 'sisu_manifest.html', l: 'English' } #fix later, default language
  langs.each do |l|
    lng=SiSU_Env::StandardiseLanguage.new(l)
    fns_c="#{@fn[:m]}~#{lng.code}.#{@fn[:t]}"
    fns_l="#{@fn[:m]}~#{lng.name}.#{@fn[:t]}"
    if FileTest.file?(fns_c)
      fn_set_lang=SiSU_Env::StandardiseLanguage.new.
        file_to_language(fns_c) #reconsider file_to_language
      lng=fn_set_lang[:n]
      fn=SiSU_Env::EnvCall.new(fns_c).lang(fn_set_lang[:c])
      @m << { m: fn[:manifest], l: lng }
    elsif FileTest.file?(fns_l)
      fn_set_lang=SiSU_Env::StandardiseLanguage.new.
        file_to_language(fns_l) #reconsider file_to_language
      @fnl=dir.i18n.lang_filename(fn_set_lang[:c])
      fn=SiSU_Env::EnvCall.new(fns_l).lang(fn_set_lang[:c])
      @m << { m: fn[:manifest], l: lng }
    end
  end
  @m=@m.uniq
end

#redirect?Boolean

Returns:

  • (Boolean)


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

def redirect?
  ((by?) ==:redirect) \
  ? true
  : false
end