Class: RailsTemplate18f::Generators::OscalGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RailsTemplate18f::Generators::OscalGenerator
- Includes:
- Base
- Defined in:
- lib/generators/rails_template18f/oscal/oscal_generator.rb
Instance Method Summary collapse
- #configure_compliance_files ⇒ Object
- #configure_gitignore ⇒ Object
- #configure_submodule ⇒ Object
- #copy_github_actions ⇒ Object
- #copy_gitlab_ci ⇒ Object
- #copy_templates ⇒ Object
- #update_readme ⇒ Object
Instance Method Details
#configure_compliance_files ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/rails_template18f/oscal/oscal_generator.rb', line 29 def configure_compliance_files if use_submodule? git submodule: "add #{[:oscal_repo]} doc/compliance/oscal" inside "doc/compliance/oscal" do git switch: "-c #{branch_name}" end else create_file "doc/compliance/oscal/.keep" end end |
#configure_gitignore ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/generators/rails_template18f/oscal/oscal_generator.rb', line 79 def configure_gitignore unless skip_git? || use_submodule? append_to_file ".gitignore", <<~EOM # Trestle working files doc/compliance/oscal/.trestle/_trash doc/compliance/oscal/.trestle/cache # Trestle renders doc/compliance/oscal/ssp-render/#{app_name}_ssp.* EOM end end |
#configure_submodule ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/generators/rails_template18f/oscal/oscal_generator.rb', line 70 def configure_submodule if use_submodule? git config: "-f .gitmodules submodule.\"doc/compliance/oscal\".branch #{branch_name}" git config: "diff.submodule log" git config: "status.submodulesummary 1" git config: "push.recurseSubmodules check" end end |
#copy_github_actions ⇒ Object
46 47 48 49 50 |
# File 'lib/generators/rails_template18f/oscal/oscal_generator.rb', line 46 def copy_github_actions if use_github_actions? directory "github", ".github" end end |
#copy_gitlab_ci ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/generators/rails_template18f/oscal/oscal_generator.rb', line 52 def copy_gitlab_ci if use_gitlab_ci? directory "gitlab", ".gitlab" if file_exists? ".gitlab-ci.yml" insert_into_file ".gitlab-ci.yml", " - local: \".gitlab/trestle.yml\"\n", after: /^include:\n/ insert_into_file ".gitlab-ci.yml", " TRESTLE_VERSION: #{docker_trestle_tag}\n", after: /^variables:\n/ end end end |
#copy_templates ⇒ Object
40 41 42 43 44 |
# File 'lib/generators/rails_template18f/oscal/oscal_generator.rb', line 40 def copy_templates template "bin/trestle" chmod "bin/trestle", 0o755 template "doc/compliance/oscal/trestle-config.yaml" end |
#update_readme ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/generators/rails_template18f/oscal/oscal_generator.rb', line 62 def update_readme if file_content("README.md").match?("## Documentation") insert_into_file "README.md", readme_contents, after: "## Documentation\n" else append_to_file "README.md", "\n## Documentation\n#{readme_contents}" end end |