Class: Dryer::Clients::Gems::Create
- Inherits:
-
Services::SimpleService
- Object
- Services::SimpleService
- Dryer::Clients::Gems::Create
- Defined in:
- lib/dryer/clients/gems/create.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(gem_name:, output_directory:, api_description:, contract_directory:) ⇒ Create
constructor
A new instance of Create.
Constructor Details
#initialize(gem_name:, output_directory:, api_description:, contract_directory:) ⇒ Create
Returns a new instance of Create.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dryer/clients/gems/create.rb', line 10 def initialize( gem_name:, output_directory:, api_description:, contract_directory: ) @gem_name = gem_name @output_directory = output_directory @contract_directory = contract_directory @api_description = api_description end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/dryer/clients/gems/create.rb', line 22 def call ContractFiles::Create.call( gem_module_name: camelize(gem_name), input_directory: contract_directory, output_directory: contract_output_dir ).append( ApiDescriptionFiles::Create.call( gem_module_name: camelize(gem_name), api_description: api_description, output_directory: dependencies_dir ), ClientFiles::Create.call( gem_module_name: camelize(gem_name), output_directory: dependencies_dir ), MainFiles::Create.call( gem_name: gem_name, gem_module_name: camelize(gem_name), output_directory: lib_dir ), Gemfiles::Create.call( output_directory: output_directory ) ).then do |files| gemspec = GemspecFiles::Create.call( gem_name: gem_name, output_directory: output_directory ) File.exist?(gemspec[:path]) ? files : files.append(gemspec) end.map do |file| FileUtils.mkdir_p(File.dirname(file[:path])) File.open(File.(file[:path]), "w") do |f| f.write(file[:contents]) end end output_directory end |