Skip to content
This repository has been archived by the owner on Feb 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #76 from exercism/static-readmes
Browse files Browse the repository at this point in the history
Use static exercise README if it is present
  • Loading branch information
Katrina Owen authored Jul 16, 2017
2 parents 0d6e66c + 755ff7f commit 58b942a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions fixtures/tracks/fake/exercises/two/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom readme for 'two'
7 changes: 6 additions & 1 deletion lib/trackler/implementation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def zip
end

def readme
@readme ||= assemble_readme
@readme ||= static_readme || assemble_readme
end

def git_url
Expand Down Expand Up @@ -84,6 +84,11 @@ def exercise_dir
File.join('exercises', slug)
end

def static_readme
path = File.join(implementation_dir, 'README.md')
return File.read(path) if File.exist?(path)
end

def assemble_readme
<<-README
# #{name}
Expand Down
7 changes: 7 additions & 0 deletions test/trackler/implementation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def test_language
assert_equal expected_language, implementation.language
end

def test_prefer_static_readme_if_present
track = Trackler::Track.new('fake', FIXTURE_PATH)
specification = Trackler::Specification.new('two', FIXTURE_PATH)
implementation = Trackler::Implementation.new(track, specification)
assert_equal "custom readme for 'two'\n", implementation.readme
end

#### DEPRECATION TESTS: HINTS ####
# These can be removed when all tracks have renamed their
# HINTS.md files to .meta/hints.md
Expand Down

0 comments on commit 58b942a

Please sign in to comment.