Class: RubyLens::ShowcaseGenerator
- Inherits:
-
Object
- Object
- RubyLens::ShowcaseGenerator
- Defined in:
- lib/rubylens/showcase_generator.rb
Constant Summary collapse
- DEFAULT_SHOWCASE_NAME =
"rubylens-showcase.html"
Instance Method Summary collapse
- #call(path: Dir.pwd, output: nil, lockfile: nil) ⇒ Object
-
#initialize(manifest_builder: Index::Manifest, adapter: Index::RubydexAdapter.new, model_builder: ArtModelBuilder.new, showcase_model: ShowcaseModel.new, showcase_writer: ShowcaseWriter.new, pipeline: nil) ⇒ ShowcaseGenerator
constructor
A new instance of ShowcaseGenerator.
Constructor Details
#initialize(manifest_builder: Index::Manifest, adapter: Index::RubydexAdapter.new, model_builder: ArtModelBuilder.new, showcase_model: ShowcaseModel.new, showcase_writer: ShowcaseWriter.new, pipeline: nil) ⇒ ShowcaseGenerator
Returns a new instance of ShowcaseGenerator.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rubylens/showcase_generator.rb', line 11 def initialize( manifest_builder: Index::Manifest, adapter: Index::RubydexAdapter.new, model_builder: ArtModelBuilder.new, showcase_model: ShowcaseModel.new, showcase_writer: ShowcaseWriter.new, pipeline: nil ) @pipeline = pipeline || GenerationPipeline.new(manifest_builder:, adapter:, model_builder:) @showcase_model = showcase_model @showcase_writer = showcase_writer end |
Instance Method Details
#call(path: Dir.pwd, output: nil, lockfile: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubylens/showcase_generator.rb', line 24 def call(path: Dir.pwd, output: nil, lockfile: nil) root = File.realpath(path) if output.nil? output = File.join(root, DEFAULT_SHOWCASE_NAME) if File.exist?(output) && !@showcase_writer.rubylens_showcase?(output) raise Error, "default showcase path already exists and is not a RubyLens showcase" end GitRepository.new(root).exclude_local(output, description: "showcase") end model, warnings = @pipeline.call(root:, lockfile:) output_path = @showcase_writer.write(@showcase_model.call(model), output: output) Result.new(output_path:, counts: model.fetch("totals").freeze, warnings:) rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP => error raise Error, error. end |