HTML-WebMake

 view release on metacpan or  search on metacpan

lib/HTML/WebMake/Main.pm  view on Meta::CPAN


  $self->{source_files} = [ ];

  $self->{outs}		= { };
  $self->{out_order}	= [ ];

  $self->{contents}	= { };
  $self->{content_order} = [ ];

  $self->{metadatas}	= { };
  $self->{this_metas_added} = [ ];

  $self->{locations}	= { };
  $self->{location_order} = [ ];

  # increase the size of these hashes in anticipation of big filesets
  keys %{$self->{outs}} = 300;
  keys %{$self->{locations}} = 300;
  keys %{$self->{metadatas}} = 500;
  keys %{$self->{contents}} = 500;

  $self->{imgsizes}	= { };
  $self->{options}	= { };

  $self->{failures}	= 0;

  $self->{cache}	= undef;
  $self->{cachefname}	= undef;
  $self->{tmpdir}	= undef;

  $self->{et_glossary}	= undef;

  $self->{perl_interp}	= undef;
  $self->{htmlcleaner}	= undef;
  $self->{mapper}	= undef;
  $self->{usertags}	= undef;
  $self->{util}		= new HTML::WebMake::Util();
  $self->{have_image_size_module} = undef;

  $self->{subst_stack} = [ ];
  $self->{current_subst} = undef;
  $self->{dep_datasources} = { };
  $self->{current_webmake_fname} = undef;

  bless ($self, $class);

  $DEBUG = $self->{debug};
  $VERBOSE = $self->{verbose};
  $HTML_LOGGING = $self->{html_logging};

  $self->{perl_lib_dir} = $self->find_perl_lib_dir();
  $self->init_for_making();

  $self;
}

sub init_for_making {
  my ($self) = @_;

  if ($^O !~ /(win|os2|mac)/i) {
    # which genius decided the mere sniff of getpwuid() should cause
    # a crash on win32? Cheers mate.
    eval ' $self->{current_user} = getpwuid ($>); ';
  } else {
    $self->{current_user} = "unknown";
  }

  $self->{format_conv} = new HTML::WebMake::FormatConvert ($self);
  $self->{metadata} = new HTML::WebMake::Metadata ($self);

  $self->{ignore_for_dependencies} =
  			new HTML::WebMake::File ($self, $SUBST_DEP_IGNORE);
  $self->{meta_ignore_for_dependencies} =
  			new HTML::WebMake::File ($self, $SUBST_META);

  # define some builtin magic content items now.
  $self->set_unmapped_content ("WebMake.GeneratorString",
  					"WebMake/$VERSION");
  $self->set_unmapped_content ("WebMake.Version", $VERSION);
  $self->set_unmapped_content ("WebMake.Who", $self->{current_user});
  # others in get_deferred_builtin_content() method below.
  # these are a little more computationally intensive.

  $self->{now} = time();
  $self->{current_tick} = 0;
}

# -------------------------------------------------------------------------

sub sed_fname {
  my ($self, $fname) = @_;

  # Interpolated variables:
  #    ~  = $HOME
  #    %f = .wmk file name, non-alphanums replaced with _
  #    %F = .wmk full path, non-alphanums replaced with _
  #    %l = perl lib dir for plugins
  #    %u = username
  #
  my $home = $ENV{'HOME'};
  $home ||= '/';

  $fname =~ s/\~/${home}/g;
  $fname =~ s/%u/$self->{current_user}/g;

  $fname =~ s{%f}{
    my $val = basename ($self->{current_webmake_fname});
    $val =~ s/\.wmk$//i; $val =~ s,[^A-Za-z0-9],_,g;
    $val;
  }ge;

  $fname =~ s{%F}{
    my $val = $self->{current_webmake_fname};
    if (!File::Spec->file_name_is_absolute ($val)) {
      $val = File::Spec->catfile (getcwd, $val);
    }
    $val =~ s/\.wmk$//i; $val =~ s,[^A-Za-z0-9],_,g; $val =~ s/^_+//;
    $val;
  }ge;

  $fname =~ s{%l}{$self->{perl_lib_dir}}g;

  if ($^O eq 'MacOS') {



( run in 1.249 second using v1.01-cache-2.11-cpan-5623c5533a1 )