Skip to content

Commit

Permalink
Alright, I let myself do some ruby time wasting, probably can't write…
Browse files Browse the repository at this point in the history
… anymore today anytime OK
  • Loading branch information
orta committed Mar 30, 2016
1 parent f36d934 commit c64e44e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ Wanna contribute? [read this](CONTRIBUTING.md).
|[Wrap Up/Twitter Follows](chapters/en-UK/wrap_up/twitter_follows.md)|2016-03-31|Words: 0|
|[Wrap Up/Recommended Websites](chapters/en-UK/wrap_up/recommended_websites.md)|2016-03-31|Words: 51|

Over 300 words: %42.2
Over 200 words: %37.8

##### Generating the ebook

The latest epub copy can be generated by running `ruby generate.rb`
20 changes: 18 additions & 2 deletions generators/generate_toc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ def create
template = start_split + "\n\n| Topics | Last Updated | Length | \n| -------|----|-----|\n"

template = add_markdown_files_to template
template += "\nOver 300 words: %" + rough_completion_estimate[:covered]
template += "\nOver 200 words: %" + rough_completion_estimate[:solid] + "\n"

new_file = start + template + "\n" + end_split + finale
File.open("README.md", 'w') { |f| f.write new_file }

end

def add_markdown_files_to template
def add_markdown_files_to template
mdfiles = get_markdown_files

left_overs = MARKDOWN_FILES - mdfiles
Expand All @@ -41,8 +43,22 @@ def add_markdown_files_to template

template += "|[#{title}](#{mdfile})|#{last_updated}|Words: #{words}|\n"
end

template
end

def rough_completion_estimate
over_three_hundred = 0
over_two_hundred = 0

MARKDOWN_FILES.each do |mdfile|
words = `wc -w #{mdfile}`.split(" ").first
over_three_hundred += 1 if words.to_i > 300
over_two_hundred += 1 if words.to_i > 200
end

return {
:solid => ((over_three_hundred / MARKDOWN_FILES.count.to_f) * 100).round(1).to_s,
:covered => ((over_two_hundred / MARKDOWN_FILES.count.to_f) * 100).round(1).to_s
}
end
end
Binary file modified pragmatic_testing.epub
Binary file not shown.

0 comments on commit c64e44e

Please sign in to comment.