Class: Kurgan::Init
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Kurgan::Init
- Includes:
- Thor::Actions
- Defined in:
- lib/kurgan/init.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #ci_init ⇒ Object
- #create_cfhighlander_template ⇒ Object
- #create_config_yaml ⇒ Object
- #create_readme ⇒ Object
- #git_init ⇒ Object
- #set_description ⇒ Object
- #set_directory ⇒ Object
- #set_template_components ⇒ Object
- #set_template_parameters ⇒ Object
- #set_type ⇒ Object
Class Method Details
.source_root ⇒ Object
12 13 14 |
# File 'lib/kurgan/init.rb', line 12 def self.source_root File.dirname(__FILE__) end |
Instance Method Details
#ci_init ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/kurgan/init.rb', line 59 def ci_init if yes? "Setup a CI pipeline?" ci = ask "CI flavour", limited_to: ['github', 'jenkins', 'codebuild'] case ci when 'github' template 'templates/github_actions.yaml.tt', "#{@dir}/.github/workflows/rspec.yaml" insert_into_file "#{@dir}/README.md", "![cftest](https://github.com/theonestack/hl-component-#{name}/actions/workflows/rspec.yaml/badge.svg)\n\n", :after => /^# #{name} CfHighlander Component\n\n/ when 'jenkins' template 'templates/Jenkinsfile.tt', "#{@dir}/Jenkinsfile" when 'codebuild' template 'templates/codebuild.yaml.tt', "#{@dir}/.codebuild.yaml" end else say "Skipping CI setup", :yellow end end |
#create_cfhighlander_template ⇒ Object
37 38 39 40 |
# File 'lib/kurgan/init.rb', line 37 def create_cfhighlander_template opts = {parameters: @parameters, components: @components, description: @description} template 'templates/cfhighlander.rb.tt', "#{@dir}/#{name}.cfhighlander.rb", opts end |
#create_config_yaml ⇒ Object
42 43 44 |
# File 'lib/kurgan/init.rb', line 42 def create_config_yaml template 'templates/config.yaml.tt', "#{@dir}/#{name}.config.yaml" end |
#create_readme ⇒ Object
46 47 48 |
# File 'lib/kurgan/init.rb', line 46 def create_readme template "templates/README.md.project.tt", "#{@dir}/README.md" end |
#git_init ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/kurgan/init.rb', line 50 def git_init if yes? "git init project?" run "git init #{@dir}" template 'templates/gitignore.tt', "#{@dir}/.gitignore" else say "Skipping git init", :yellow end end |
#set_description ⇒ Object
25 26 27 |
# File 'lib/kurgan/init.rb', line 25 def set_description @description = ask "template description ", default: name end |
#set_directory ⇒ Object
20 21 22 23 |
# File 'lib/kurgan/init.rb', line 20 def set_directory @dir = ask "directory name ", default: name empty_directory @dir end |
#set_template_components ⇒ Object
33 34 35 |
# File 'lib/kurgan/init.rb', line 33 def set_template_components @components = Kurgan::Projects.properties[['project'].to_sym][:components] end |
#set_template_parameters ⇒ Object
29 30 31 |
# File 'lib/kurgan/init.rb', line 29 def set_template_parameters @parameters = Kurgan::Projects.properties[['project'].to_sym][:parameters] end |
#set_type ⇒ Object
16 17 18 |
# File 'lib/kurgan/init.rb', line 16 def set_type @type = 'project' end |