Class: Generator::Entrypoint
- Inherits:
-
Object
- Object
- Generator::Entrypoint
- Includes:
- FileWriter
- Defined in:
- lib/generator/entrypoint.rb
Instance Attribute Summary collapse
-
#apis ⇒ Object
readonly
Returns the value of attribute apis.
Class Method Summary collapse
Instance Method Summary collapse
- #apis_with_latest_version ⇒ Object
- #generate ⇒ Object
-
#initialize(apis) ⇒ Entrypoint
constructor
A new instance of Entrypoint.
Methods included from FileWriter
Constructor Details
#initialize(apis) ⇒ Entrypoint
Returns a new instance of Entrypoint.
25 26 27 |
# File 'lib/generator/entrypoint.rb', line 25 def initialize(apis) @apis = apis end |
Instance Attribute Details
#apis ⇒ Object (readonly)
Returns the value of attribute apis.
16 17 18 |
# File 'lib/generator/entrypoint.rb', line 16 def apis @apis end |
Class Method Details
Instance Method Details
#apis_with_latest_version ⇒ Object
41 42 43 44 45 46 |
# File 'lib/generator/entrypoint.rb', line 41 def apis_with_latest_version apis.group_by(&:name).transform_values do |api_list| latest_version = VersionSelector.find_latest_version(api_list.map(&:version)) api_list.find { |api| api.version == latest_version } end.to_h end |
#generate ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generator/entrypoint.rb', line 29 def generate written_files = [] # Generate main entrypoint file written_files << write_file(file_path, render_template) # Generate entrypoint signature written_files << RBS::Entrypoint.new(apis).generate format_files(written_files) end |