Class: Sweetie::Conversion
- Inherits:
-
Object
- Object
- Sweetie::Conversion
- Extended by:
- Helper
- Defined in:
- lib/sweetie/conversion.rb
Constant Summary collapse
- @@config =
"_config.yml"
- @@dir =
"_site"
Class Method Summary collapse
-
.build_time ⇒ String
Create the actual build time.
-
.conversion ⇒ Object
Opens the config file and search after the specified parameters.
-
.count_all_html_pages(dir) ⇒ Fixnum
Counts all html pages.
-
.count_all_images(dir) ⇒ Object
Counts all the images of all html pages.
-
.count_all_links(dir) ⇒ Object
Counts all the links of all html pages.
-
.count_images_of_one_page(page) ⇒ Object
Count the images of one html page.
-
.count_link_of_one_page(page) ⇒ Object
Counts the link of on html page.
Methods included from Helper
check_config_and_directory_file, harvest, output_count, perform_global_search, perform_search_for_single_page, traverse, write_config
Class Method Details
.build_time ⇒ String
Create the actual build time
78 79 80 81 |
# File 'lib/sweetie/conversion.rb', line 78 def build_time time = Time.now "#{time.month}-#{time.day}-#{time.year}" end |
.conversion ⇒ Object
Opens the config file and search after the specified parameters. It saves the gathered information about the build-date, the links, the images, and the number of html-pages in the jekyll project.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sweetie/conversion.rb', line 18 def conversion check_config_and_directory_file(@@config, @@dir) file = File.open(@@config) text = "" while line = file.gets if line.match(/build:/) text << "build: #{build_time}\n" elsif line.match(/htmlpages:/) text << "htmlpages: #{count_all_html_pages(@@dir)}\n" elsif line.match(/images:/) text << "images: #{count_all_images(@@dir)}\n" elsif line.match(/links:/) text << "links: #{count_all_links(@@dir)}\n" else text << line end end file.close write_config(file, text) end |
.count_all_html_pages(dir) ⇒ Fixnum
Counts all html pages
58 59 60 |
# File 'lib/sweetie/conversion.rb', line 58 def count_all_html_pages(dir) perform_global_search('//html', [], dir) end |
.count_all_images(dir) ⇒ Object
Counts all the images of all html pages
72 73 74 |
# File 'lib/sweetie/conversion.rb', line 72 def count_all_images(dir) perform_global_search('//img', [], dir) end |
.count_all_links(dir) ⇒ Object
Counts all the links of all html pages
65 66 67 |
# File 'lib/sweetie/conversion.rb', line 65 def count_all_links(dir) perform_global_search('//a', [], dir) end |
.count_images_of_one_page(page) ⇒ Object
Count the images of one html page
51 52 53 |
# File 'lib/sweetie/conversion.rb', line 51 def count_images_of_one_page(page) perform_search_for_single_page('//img', [], page) end |
.count_link_of_one_page(page) ⇒ Object
Counts the link of on html page
44 45 46 |
# File 'lib/sweetie/conversion.rb', line 44 def count_link_of_one_page(page) perform_search_for_single_page('//a', [], page) end |