Class: Fitting::Rep::HTML
- Inherits:
-
Object
- Object
- Fitting::Rep::HTML
- Defined in:
- lib/fitting/rep/html.rb
Class Method Summary collapse
- .bootstrap(folder, fitting_json, fitting_lock_json) ⇒ Object
- .copy_file(folder, name) ⇒ Object
- .copy_file_with_json(folder, name, fitting_json, fitting_lock_json) ⇒ Object
Class Method Details
.bootstrap(folder, fitting_json, fitting_lock_json) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/fitting/rep/html.rb', line 23 def self.bootstrap(folder, fitting_json, fitting_lock_json) copy_file_with_json(folder, 'fitting.html', fitting_json, fitting_lock_json) copy_file(folder, 'bootstrap-nightshade.min.css') copy_file(folder, 'darkmode.min.js') copy_file(folder, 'jquery-3.6.0.min.js') copy_file(folder, 'bootstrap.min.js') end |
.copy_file(folder, name) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/fitting/rep/html.rb', line 4 def self.copy_file(folder, name) File.open("#{folder}/#{name}", 'w') do |file| file.write( File.read("#{$LOAD_PATH.find { |i| i.include?('fitting') }}/templates/htmlcss/#{name}") ) end end |
.copy_file_with_json(folder, name, fitting_json, fitting_lock_json) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fitting/rep/html.rb', line 12 def self.copy_file_with_json(folder, name, fitting_json, fitting_lock_json) res = File.read("#{$LOAD_PATH.find { |i| i.include?('fitting') }}/templates/htmlcss/#{name}") File.open("#{folder}/#{name}", 'w') do |file| file.write( res .gsub("{'fitting json': []}", ::JSON.pretty_generate(fitting_json)) .gsub("{'fitting lock json': []}", ::JSON.pretty_generate(fitting_lock_json)) ) end end |