Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 1.02 KB

README.md

File metadata and controls

27 lines (20 loc) · 1.02 KB

Lines of Code Hack

Objective

Your objective is to write a module which counts the significant lines of code in a given file or directory. The API is simple Loc.count_file/1 should output the lines of code for a single file while Loc.count_directory(path) should output the lines of code for all files in the directory (recursively).

  • Lines which are solely whitespace (spaces or tabs) should be ignored.
  • Lines which are only comments (starts with #) should be ignored.
  • Non-Elixir files should be ignored (anything without a .ex or .exs extension).
  • Assume that files and directories passed in exist and are fully readable.

Testing your solution

To test your solution manually, use the Loc module in iex like so:

$ iex -S mix
iex> Loc.count_file("foo.ex") # => 10
iex> Loc.count_directory("foo/bar") # => 100

To run the test suite and ensure your solution passes, use the following:

$ mix test