Class: DocumentGenerator::Repository
- Inherits:
-
Object
- Object
- DocumentGenerator::Repository
- Defined in:
- lib/document_generator/repository.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .default_dirname ⇒ Object
- .default_relative_filename ⇒ Object
- .menu_dirname ⇒ Object
- .menu_relative_filename ⇒ Object
Instance Method Summary collapse
- #base_url ⇒ Object
- #commits ⇒ Object
- #generate ⇒ Object
-
#initialize(url) ⇒ Repository
constructor
A new instance of Repository.
- #name ⇒ Object
Constructor Details
#initialize(url) ⇒ Repository
Returns a new instance of Repository.
21 22 23 |
# File 'lib/document_generator/repository.rb', line 21 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/document_generator/repository.rb', line 3 def url @url end |
Class Method Details
.default_dirname ⇒ Object
13 14 15 |
# File 'lib/document_generator/repository.rb', line 13 def self.default_dirname '_layouts' end |
.default_relative_filename ⇒ Object
17 18 19 |
# File 'lib/document_generator/repository.rb', line 17 def self.default_relative_filename File.join(default_dirname, 'default.html') end |
.menu_dirname ⇒ Object
5 6 7 |
# File 'lib/document_generator/repository.rb', line 5 def self. '_includes' end |
.menu_relative_filename ⇒ Object
9 10 11 |
# File 'lib/document_generator/repository.rb', line 9 def self. File.join(, 'menu.md') end |
Instance Method Details
#base_url ⇒ Object
25 26 27 |
# File 'lib/document_generator/repository.rb', line 25 def base_url "https://#{uri.host}#{uri.path}/" end |
#commits ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/document_generator/repository.rb', line 44 def commits Dir.mktmpdir do |path| repo = Git.clone(url, name, path: path) # TODO: Allow options to influence branch, number of commits, etc. repo.log(nil).reverse_each.map do |git_commit| yield Commit.new(base_url, git_commit) end end end |
#generate ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/document_generator/repository.rb', line 33 def generate prepare File.open(Repository., 'w') do || commits do |commit| .write(commit.link) commit.create end end end |
#name ⇒ Object
29 30 31 |
# File 'lib/document_generator/repository.rb', line 29 def name uri.path.split('/')[-1] end |