Sha256: 9dbdb440417178a3c6ab086e2121bee807e5cc1b9ee901418ebd6d84b9117fdf
Contents?: true
Size: 1.1 KB
Versions: 13
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true require_relative '../generator_helper' module Rails # rails g api_client class ApiClientGenerator < Rails::Generators::NamedBase include MyApiClient::GeneratorHelper source_root File.expand_path('templates', __dir__) check_class_collision suffix: 'ApiClient' argument :requests, type: :array, default: %w[get:path/to/resource post:path/to/resource], banner: '{method}:{path} {method}:{path}' class_option :endpoint, type: :string, default: 'https://example.com', banner: 'https://example.com', desc: 'Common part of the target API endpoint' def generate_root_class file_path = File.join('app/api_clients', 'application_api_client.rb') return if File.exist?(file_path) template 'application_api_client.rb.erb', file_path end def generate_api_client file_path = File.join('app/api_clients', "#{route_url.singularize}_api_client.rb") template 'api_client.rb.erb', file_path end hook_for :test_framework end end
Version data entries
13 entries across 13 versions & 1 rubygems