Class: Service

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions, Util
Defined in:
lib/commands/service.rb

Constant Summary

Constants included from Util

Util::CONFIG_DIR

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#config, #content_root, #licence, #user_email, #user_name

Class Method Details

.source_rootObject



19
20
21
# File 'lib/commands/service.rb', line 19

def self.source_root
  File.expand_path('../',__dir__)
end

Instance Method Details

#add_sourcesObject



45
46
47
48
49
50
51
52
53
# File 'lib/commands/service.rb', line 45

def add_sources
  Dir.chdir(@name) {@licence = licence}
  template 'templates/src/main/java/main/App.java.erb',"#{@name}/src/main/java/#{@group_id.gsub(".","/")}/main/App.java"
  template 'templates/src/main/java/config/AppConfig.java.erb',"#{@name}/src/main/java/#{@group_id.gsub(".","/")}/config/AppConfig.java"
  template 'templates/src/main/resources/application.yml.erb',"#{@name}/src/main/resources/application.yml"
  template 'templates/src/main/resources/bootstrap.yml.erb',"#{@name}/src/main/resources/bootstrap.yml"
  template "templates/gradle/#{@repository_technique}_build.gradle.erb","#{@name}/build.gradle"

end

#init_gitObject



39
40
41
42
43
# File 'lib/commands/service.rb', line 39

def init_git
  g = Git.init @name
  @user_name = g.config['user.name']
  @user_email = g.config['user.email']
end

#prepare_artifactObject



23
24
25
26
27
28
# File 'lib/commands/service.rb', line 23

def prepare_artifact
  parts = @name.split(".")
  @name = @artifact_id = parts.pop
  @group_id = parts.length > 0 ?  parts.join('.') : @name
  @package = @group_id.split(".").each {|part| part.gsub!(/\W/,"")}.join(".")
end

#prepare_projectObject



31
32
33
34
35
36
37
# File 'lib/commands/service.rb', line 31

def prepare_project
  @repository_technique = options['repository_technique'] || 'jpa'
  copy_file 'templates/project/licence.erb',"#{@name}/.spring-gen/licence.erb"
  template 'templates/project/service.yml.erb',"#{@name}/.spring-gen/service.yml"
  directory 'templates/config',"#{@name}/config"
  copy_file 'templates/.gitignore',"#{@name}/.gitignore"
end