Sha256: 8d207541b0f3c8bd1130483194cefeff1e85bd769bf3db19c92ab31de005dbeb
Contents?: true
Size: 1.78 KB
Versions: 16
Compression:
Stored size: 1.78 KB
Contents
require 'thor' require 'thor/group' module Utter module Generators # Usage # generator = Utter::Generators::Microservice.new # generator.destination_root = path #optional, will use current directory by default # generator.invoke_all class Microservice < Thor::Group include Thor::Actions desc 'Generate an utter microservice directory structure' def create_microservice params={} path = params[:path] module_name = params[:module_name] api_version = params[:api_version] service_name = params[:service_name] empty_directory "#{path}/microservice" empty_directory "#{path}/microservice/lib" empty_directory "#{path}/microservice/lib/internals" # microservice/lib/main.rb create_file "#{path}/microservice/lib/main.rb" @file = <<-FOO require 'utter' require 'json' Dir[File.dirname(__FILE__) + '/**/*.rb'].each {|file| require_relative file } module #{module_name.capitalize} module #{api_version.capitalize} class #{service_name.capitalize} < Utter::Microservice \$log.info("mounting \#{self}") get '/' do domain_stack = Utter::Stack.new do #use MyDomainExtension, "data message" end \$log.info(domain_stack.to_s) {"status": "running"}.to_json end #run! if app_file == $0 end end end FOO append_to_file "#{path}/microservice/lib/main.rb", @file # end of microservice/lib/main.rb empty_directory "#{path}/microservice/spec" create_file "#{path}/microservice/spec/main_spec.rb" create_file "#{path}/microservice/spec/spec_helper.rb" # microservice/README.md create_file "#{path}/microservice/README.md" @file = <<-FOO # describe how to use the microservice here FOO append_to_file "#{path}/microservice/README.md", @file # end of microservice/README.md end end end end
Version data entries
16 entries across 16 versions & 1 rubygems