Class: RailsTemplate18f::Generators::NewrelicGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RailsTemplate18f::Generators::NewrelicGenerator
- Includes:
- Base
- Defined in:
- lib/generators/rails_template18f/newrelic/newrelic_generator.rb
Instance Method Summary collapse
- #install_config ⇒ Object
- #install_gem ⇒ Object
- #update_boundary_diagram ⇒ Object
- #update_cloud_gov_manifest ⇒ Object
- #update_content_security_policy ⇒ Object
- #update_oscal_doc ⇒ Object
- #update_readme ⇒ Object
Instance Method Details
#install_config ⇒ Object
31 32 33 |
# File 'lib/generators/rails_template18f/newrelic/newrelic_generator.rb', line 31 def install_config template "config/newrelic.yml" end |
#install_gem ⇒ Object
25 26 27 28 29 |
# File 'lib/generators/rails_template18f/newrelic/newrelic_generator.rb', line 25 def install_gem return if gem_installed?("newrelic_rpm") gem "newrelic_rpm", "~> 9.16" bundle_install end |
#update_boundary_diagram ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/generators/rails_template18f/newrelic/newrelic_generator.rb', line 50 def update_boundary_diagram boundary_filename = "doc/compliance/apps/application.boundary.md" insert_into_file boundary_filename, <<EOB, after: "Boundary(gsa_saas, \"GSA-authorized SaaS\") {\n" System_Ext(newrelic, "New Relic", "Monitoring SaaS") EOB insert_into_file boundary_filename, <<~EOB, before: "@enduml" Rel(app, newrelic, "reports telemetry (ruby agent)", "tcp (443)") Rel(browser, newrelic, "reports ux metrics (javascript agent)", "https (443)") Rel(developer, newrelic, "Manage performance", "https (443)") EOB end |
#update_cloud_gov_manifest ⇒ Object
35 36 37 38 39 |
# File 'lib/generators/rails_template18f/newrelic/newrelic_generator.rb', line 35 def update_cloud_gov_manifest insert_into_file file_path("terraform/app.tf"), <<EOT, after: "environment = {\n" NEW_RELIC_LOG = "stdout" EOT end |
#update_content_security_policy ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/rails_template18f/newrelic/newrelic_generator.rb', line 15 def update_content_security_policy csp_file = "config/initializers/content_security_policy.rb" gsub_file csp_file, /(policy.script_src .*)$/, '\1, "https://js-agent.newrelic.com", "https://*.nr-data.net"' if file_content(csp_file).match?(/policy.connect_src/) gsub_file csp_file, /(policy.connect_src .*)$/, '\1, "https://*.nr-data.net"' else gsub_file csp_file, /((#?)(\s+)policy.script_src .*)$/, "\\1\n\\2\\3policy.connect_src :self, \"https://*.nr-data.net\"" end end |
#update_oscal_doc ⇒ Object
62 63 64 |
# File 'lib/generators/rails_template18f/newrelic/newrelic_generator.rb', line 62 def update_oscal_doc copy_oscal_component "newrelic" end |
#update_readme ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/generators/rails_template18f/newrelic/newrelic_generator.rb', line 41 def update_readme insertion_regex = /^## Documentation$/ if file_content("README.md").match?(insertion_regex) insert_into_file "README.md", readme, before: insertion_regex else append_to_file "README.md", readme end end |