Class: ReadmeScore::Document::Loader::GithubReadmeFinder
- Inherits:
-
Object
- Object
- ReadmeScore::Document::Loader::GithubReadmeFinder
- Defined in:
- lib/readme-score/document/loader/github_readme_finder.rb
Constant Summary collapse
- POSSIBLE_README_FILES =
%w{README.md readme.md README readme ReadMe ReadMe.md}
Instance Method Summary collapse
- #find_url ⇒ Object
-
#initialize(github_repo_url) ⇒ GithubReadmeFinder
constructor
A new instance of GithubReadmeFinder.
Constructor Details
#initialize(github_repo_url) ⇒ GithubReadmeFinder
Returns a new instance of GithubReadmeFinder.
9 10 11 |
# File 'lib/readme-score/document/loader/github_readme_finder.rb', line 9 def initialize(github_repo_url) @repo_url = github_repo_url end |
Instance Method Details
#find_url ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/readme-score/document/loader/github_readme_finder.rb', line 13 def find_url uri = URI.parse(@repo_url) uri.scheme = "https" uri.host = "raw.githubusercontent.com" original_path = uri.path readme_url = nil POSSIBLE_README_FILES.each {|f| uri.path = File.join(original_path, "master/#{f}") readme_url = uri.to_s if reachable?(uri.to_s) break if readme_url } readme_url end |