Class: EnvironmentInformation::Sinatra

Inherits:
Sinatra::Base
  • Object
show all
Includes:
Colours, Colours::E
Defined in:
lib/environment_information/www/sinatra_interface.rb

Constant Summary collapse

USE_THIS_PORT =
#

USE_THIS_PORT

#
'4567'

Instance Method Summary collapse

Constructor Details

#initializeSinatra

#

initialize

#


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/environment_information/www/sinatra_interface.rb', line 37

def initialize
  super()
  reset
  if ::EnvironmentInformation.is_on_roebe?
    require 'open'
    # ===================================================================== #
    # Tell us which port will be used:
    # ===================================================================== #
    target = "http://localhost:#{USE_THIS_PORT}/"
    e sfancy(target)
    Thread.new {
      sleep 1.0
      Open.in_browser(target)
    }
  end
end

Instance Method Details

#html_endObject

#

html_end

#


63
64
65
# File 'lib/environment_information/www/sinatra_interface.rb', line 63

def html_end
  '<idv></body></html>'
end

#resetObject

#

reset

#


57
58
# File 'lib/environment_information/www/sinatra_interface.rb', line 57

def reset
end

#return_html_startObject

#

return_html_start

This method will include all parts up to the first main <div> element of the webpage.

#


73
74
75
76
77
78
# File 'lib/environment_information/www/sinatra_interface.rb', line 73

def return_html_start
  "<html><head><title>\n"\
  "Sinatra-Interface of the EnvironmentInformation project\n"\
  "</title></head><body>"\
  "<div style=\"padding:2px; margin-left:0.5em\">"
end

#sinatra_paragraph_showing_this_component(i = :gcc) ⇒ Object

#

sinatra_paragraph_showing_this_component

This method was added primarily so that we can use a unified (and consistent) style for display.

#


163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/environment_information/www/sinatra_interface.rb', line 163

def sinatra_paragraph_showing_this_component(
    i = :gcc
  )
  content = "return_version_of_#{i}".to_s
  content = ::EnvironmentInformation.send(content)
  # ======================================================================== #
  # Next, we grab it from the main Hash.
  # ======================================================================== #
  case i
  when :awk,
       :bison,
       :boost,
       :coreutils,
       :binutils,
       :cmake,
       :diffutils,
       :findutils,
       :file,
       :flex,
       :gcc,
       :gettext,
       :glibc,
       :grep,
       :gnupg,
       :intltool,
       :ruby,
       :rubygems
    i = "#{i.to_s.capitalize} Version"
  when :linux_kernel
    i = 'Linux Kernel'
  end
  # ======================================================================== #
  # Finally return the proper <p> tag:
  # ======================================================================== #
  uniform_p_tag(i, content)
end

#uniform_p_tag(i, content) ⇒ Object

#

uniform_p_tag

#


141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/environment_information/www/sinatra_interface.rb', line 141

def uniform_p_tag(i, content)
  i = i.to_s
  unless i.end_with? ':'
    i = i.dup if i.frozen?
    i << ':'
  end
  p(
    "#{i}<br><b style=\"color: darkblue; margin-left:1.5em\">#{content}"\
    "</b>",
    css_style: 'margin-left: 2.5em;
                margin: 4px;
                padding: 5px;
                padding-top: 0.2em'
  )
end