Class: NanDoc::Project
- Inherits:
-
Object
- Object
- NanDoc::Project
- Includes:
- Singleton
- Defined in:
- lib/nandoc/core/project.rb
Instance Method Summary collapse
-
#project_root ⇒ Object
not especially robust at all.
- #require_test_file(testfile) ⇒ Object
- #test_framework_proxy_for_file(path) ⇒ Object
- #testdir ⇒ Object
Instance Method Details
#project_root ⇒ Object
not especially robust at all
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nandoc/core/project.rb', line 16 def project_root @project_root ||= begin presumed_root = File.dirname(FileUtils.pwd) thems = %w(spec test) found = thems.detect{ |dir| File.directory?(presumed_root+'/'+dir) } fail("couldn't find " << StringMethods.oxford_comma(thems,' or ', "ed) << "in #{presumed_root}") unless found presumed_root end end |
#require_test_file(testfile) ⇒ Object
28 29 30 31 32 |
# File 'lib/nandoc/core/project.rb', line 28 def require_test_file testfile path = testdir + '/' + testfile fail("test file not found: #{path.inspect}") unless File.file?(path) require path end |
#test_framework_proxy_for_file(path) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/nandoc/core/project.rb', line 43 def test_framework_proxy_for_file path @the_only_proxy ||= begin require 'nandoc/spec-doc/test-framework/mini-test/proxy' SpecDoc::TestFramework::MiniTest::Proxy.new end end |
#testdir ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/nandoc/core/project.rb', line 34 def testdir @testdir ||= begin tries = [project_root+'/test', project_root+'/spec'] found = tries.detect{ |path| File.directory?(path) } fail("Couldn't find test dir for gem at (#{tries*', '})") unless found found end end |