Class: Utter::Generators::Container

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/generators/project_container_gem_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_container(params = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
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
60
61
62
63
# File 'lib/generators/project_container_gem_generator.rb', line 10

def create_container params={}
	path = params[:path]
	module_name = params[:module_name]
	api_version = params[:api_version]
	service_name = params[:service_name]

	# config.ru
	@file = <<-FOO
Dir[File.dirname(__FILE__) + '/microservice/**/*.rb'].each {|file| require_relative file }
Dir[File.dirname(__FILE__) + '/domain/**/*.rb'].each {|file| require_relative file }
map "/" do
  run #{module_name.capitalize}::#{api_version.capitalize}::#{service_name.capitalize}
end
	FOO
	create_file "#{path}/config.ru"
	append_to_file "#{path}/config.ru", @file
	# end of config.ru
	############################	
	# Gemfile 
	@file = <<-FOO
source 'https://rubygems.org'
gem 'utter'
	FOO
	create_file "#{path}/Gemfile"
	append_to_file "#{path}/Gemfile", @file
	# end of Gemfile
	############################	
	# Dockerfile 
	@file = <<-FOO
Docker stuff here
	FOO
	create_file "#{path}/Dockerfile"
	append_to_file "#{path}/Dockerfile", @file
	# end of Dockerfile
	############################	
	# README.md for the utter container 
	@file = <<-FOO
Abou this utter project. 1.Microservice 2.Domain
	FOO
	create_file "#{path}/README.md"
	append_to_file "#{path}/README.md", @file
	# end of README.md 
	############################	
	# Log for the utter container 
	@file = <<-FOO
Abou this log directory 
	FOO
	empty_directory "#{path}/log"
	create_file  	"#{path}/log/README.md"
	append_to_file "#{path}/log/README.md", @file
	# end of log 
	############################	
	#TODO container_name.gemspec
end