Class: Cyberweb::CreateColouredTags

Inherits:
Base
  • Object
show all
Defined in:
lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb

Overview

Cyberweb::CreateColouredTags

Constant Summary collapse

STORE_WHERE =
#

STORE_WHERE

Designate where to store the coloured_tags.rb file.

#
ConvertGlobalEnv.convert(
  '$CYBERWEB/coloured_tags/coloured_tags.rb' # hardcoded path.
).to_s

Constants inherited from Base

Base::HOME_DIRECTORY_OF_THE_USER_X, Base::NAMESPACE

Instance Method Summary collapse

Methods inherited from Base

#be_verbose, #be_verbose?, #cascading_style_sheets_directory?, #cd, #commandline_mode?, #copyright?, #css_comment, #delete_directory, #do_toggle, #e, #echo_raw, #filename?, #full_path_to_image_directory?, #html_colours?, #html_image, #htmlentities, #img_dir?, #infer_the_namespace, #initialize_the_configuration, #is_a_file?, #is_a_video_file?, #is_an_image_file?, #is_on_roebe?, #last_tag_used?, #last_tag_used_first_element?, #last_tag_used_id?, #mkdir, #mode?, #namespace?, #open_in_browser, #opne, #opnn, #remove_comments_from_this_string_but_preserve_CSS_rules, #remove_html, #return_all_directories, #return_date, #return_program_name, #return_pwd, #ruby_header?, #server_base_directory?, #set_commandline_mode, #set_last_tag_used, #update_the_image_directory, #use_this_relative_directory_for_custom_images?, #www_mode?

Methods included from BaseModule::FileRelatedFunctionality

#copy_this_file, #cpr, #delete_file, #filename_without_extension?, #read_file_via_utf8_encoding

Methods included from BaseModule

#attach_these_constants, #base_dir?, #beautiful_url, #cd, #create_the_internal_hash, #doctype?, #ee, #ensure_main_encoding, #esystem, #html_templates, #initialize_the_config_if_the_config_hash_is_empty, #internal_hash?, #log_dir?, #no_http, #random_alphabet_characters, #rarrow?, #rds, #remove_comments_from_this_string, #remove_numbers, #require_the_html_templates, #require_these, #return_file_size_in_kb_of, #return_html_comment, #ruby_sitelib_dir?, #sanitize_this_id, #server_base_directory?, #string_remote_image, #today?, #try_to_require_rack, #try_to_require_the_open_gem, #write_what_into

Methods included from BaseModule::ContentType

#content_type_is_html, #content_type_is_jpeg, #content_type_is_json, #content_type_is_plain_text

Methods included from BaseModule::CommandlineArguments

#append_to_the_commandline_arguments, #commandline_arguments?, #first_argument?, #parse_these_commandline_arguments, #second_argument?, #set_commandline_arguments

Methods included from BaseModule::Colours

#all_html_colours, #lightgreen, #rev, #sdir, #sfancy, #sfile, #simp, #steelblue, #tomato

Constructor Details

#initialize(run_already = true) ⇒ CreateColouredTags

#

initialize

#


34
35
36
37
38
39
# File 'lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb', line 34

def initialize(
    run_already = true
  )
  reset
  run if run_already
end

Instance Method Details

#_(i) ⇒ Object

#

_

#


75
76
77
# File 'lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb', line 75

def _(i)
  @_ << i
end

#consider_removing_main_fileObject

#

consider_removing_main_file

#


61
62
63
# File 'lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb', line 61

def consider_removing_main_file
  remove_file(store_where?)
end

#populate_main_string_with_dataObject

#

populate_main_string_with_data

This is the method that will generate the code.

#


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb', line 84

def populate_main_string_with_data
  _ '#!/usr/bin/ruby -w'+N
  _ '# Encoding: UTF-8'+N
  _ '# frozen_string_literal: true'+N
  _  return_header
  _ '# Automatically generated at '+return_date+' from the file'+N
  _ '# create_coloured_tags.rb'+N
  _  return_header # This will already append a newline, hence we don't add another one.
  _ "# require 'cyberweb/coloured_tags/coloured_tags.rb'"+N
  _  return_header
  _ 'module Cyberweb'+N+N
  all_html_colours.each { |colour|
    _ return_header
    _ '# === Cyberweb.'+colour+N
    _ return_header
    _ "def self.return_"+colour+"(text = '', css_class = '', the_id = '', css_style = '')"+N
    _ "  ::Cyberweb.string_s(text, 'span', css_class+' "+colour+"', the_id, css_style)"+N
    _ 'end'+N+N
    _ return_header
    _ '# === Cyberweb.'+colour+N
    _ return_header
    _ "def self."+colour+"(text = '', css_class = '', the_id = '', css_style = '')"+N
    _ "  e(text, css_class+' "+colour+"', the_id, css_style)"+N
    _ 'end'+N+N
    _ return_header
    _ '# === '+colour+N
    _ return_header
    _ "def "+colour+"(text = '', css_class = '', the_id = '', css_style = '')"+N
    _ "  ::Cyberweb."+colour+"(text, css_class, the_id, css_style)"+N
    _ 'end'
    # ===================================================================== #
    # Next, we could create an alias for this colour, but only
    # when we have not already defined such an alias before.
    # ===================================================================== #
    the_alias = colour[0,4]
    unless @array_aliases_for_colours.include? the_alias
      unless colour == the_alias
        _ "; alias #{the_alias} #{colour}" if colour.size > 3 # Add an alias here.
      end
    end
    @array_aliases_for_colours << the_alias
    _ N+N
  }
  _ 'end'
end

#resetObject

#

reset

#


44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb', line 44

def reset
  super()
  infer_the_namespace
  set_commandline_mode
  # First, determine where we shall store the file coloured_tags.rb actually.
  if ENV['CYBERWEB']
    @store_where = ENV['CYBERWEB'].to_s+'/coloured_tags/coloured_tags.rb'
  else
    @store_where = STORE_WHERE
  end
  @array_aliases_for_colours = []
  @_ = ''.dup # This is the main string that will be generated.
end

#return_headerObject

#

return_header

#


144
145
146
# File 'lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb', line 144

def return_header
  "# =========================================================================== ##{N}"
end

#runObject

#

run

#


151
152
153
154
155
# File 'lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb', line 151

def run
  consider_removing_main_file
  populate_main_string_with_data
  store_data
end

#store_dataObject

#

store_data

#


133
134
135
136
137
138
139
# File 'lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb', line 133

def store_data
  opnn; e 'Storing into'
  e
  e "  #{sfile(store_where?)}"
  e
  write_what_into(@_, store_where?)
end

#store_where?Boolean

#

store_where?

#

Returns:

  • (Boolean)


68
69
70
# File 'lib/cyberweb/utility_scripts/create_coloured_tags/create_coloured_tags.rb', line 68

def store_where?
  @store_where
end