Class: Groundskeeper::Project
- Inherits:
-
Object
- Object
- Groundskeeper::Project
- Defined in:
- lib/groundskeeper/project.rb
Overview
Accesses project details stored in the home directory.
Constant Summary collapse
- DETAILS_PATH =
"~/.project_details/projects.yml"- SERVERS_PATH =
"../../servers.yml"- JIRA_PREFIX_KEY =
"jira_prefix"- PROJECT_NAME_KEY =
"name"- SOURCE_CONTROL_USERNAME_KEY =
"scm_username"- FULL_DNS_KEY =
"full_dns"- RVM_RUBY_VERSION_KEY =
"ruby_version"- DB_ENV_VARIABLES_KEY =
"db_env_variables"- SENTRY_DSN_KEY =
"sentry_dsn"- SENTRY_PUBLIC_DSN_KEY =
"sentry_public_dsn"- SSL_CERTIFICATE_FILE_KEY =
"SSLCertificateFile"- SSL_CERTIFICATE_CHAIN_FILE_KEY =
"SSLCertificateChainFile"- SSL_CERTIFICATE_KEY_FILE_KEY =
"SSLCertificateKeyFile"
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#repo_name ⇒ Object
readonly
Returns the value of attribute repo_name.
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
Class Method Summary collapse
Instance Method Summary collapse
- #db_env_variables(stage) ⇒ Object
- #deploy_to ⇒ Object
- #full_dns(stage) ⇒ Object
-
#initialize(projects_yaml:, servers_yaml:, repository_name:) ⇒ Project
constructor
A new instance of Project.
- #jira_prefix ⇒ Object
- #project_name ⇒ Object
- #repo_url ⇒ Object
- #rvm_ruby_version ⇒ Object
- #sentry_dsn ⇒ Object
- #sentry_public_dsn ⇒ Object
- #server_config(stage) ⇒ Object
- #source_control_username ⇒ Object
- #ssl_certificate_chain_file(stage) ⇒ Object
- #ssl_certificate_file(stage) ⇒ Object
- #ssl_certificate_key_file(stage) ⇒ Object
- #tags ⇒ Object
Constructor Details
#initialize(projects_yaml:, servers_yaml:, repository_name:) ⇒ Project
Returns a new instance of Project.
39 40 41 42 43 44 |
# File 'lib/groundskeeper/project.rb', line 39 def initialize(projects_yaml:, servers_yaml:, repository_name:) projects = YAML.safe_load(projects_yaml) || {} @details = projects[repository_name] || {} @servers = YAML.safe_load(servers_yaml) || {} @repo_name = repository_name end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details.
9 10 11 |
# File 'lib/groundskeeper/project.rb', line 9 def details @details end |
#repo_name ⇒ Object (readonly)
Returns the value of attribute repo_name.
9 10 11 |
# File 'lib/groundskeeper/project.rb', line 9 def repo_name @repo_name end |
#servers ⇒ Object (readonly)
Returns the value of attribute servers.
9 10 11 |
# File 'lib/groundskeeper/project.rb', line 9 def servers @servers end |
Class Method Details
.available_applications ⇒ Object
33 34 35 36 37 |
# File 'lib/groundskeeper/project.rb', line 33 def self.available_applications yaml = Document.new(DETAILS_PATH).read projects = YAML.safe_load(yaml) || {} projects.keys.join(", ") end |
.build(repository_name) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/groundskeeper/project.rb', line 25 def self.build(repository_name) new( projects_yaml: Document.new(DETAILS_PATH).read, servers_yaml: Document.new(SERVERS_PATH).read, repository_name: repository_name ) end |
Instance Method Details
#db_env_variables(stage) ⇒ Object
62 63 64 |
# File 'lib/groundskeeper/project.rb', line 62 def db_env_variables(stage) details.dig(DB_ENV_VARIABLES_KEY, stage.to_s) || "" end |
#deploy_to ⇒ Object
98 99 100 |
# File 'lib/groundskeeper/project.rb', line 98 def deploy_to "/var/www/apps/#{repo_name}" end |
#full_dns(stage) ⇒ Object
58 59 60 |
# File 'lib/groundskeeper/project.rb', line 58 def full_dns(stage) details.dig(FULL_DNS_KEY, stage.to_s) || "" end |
#jira_prefix ⇒ Object
50 51 52 |
# File 'lib/groundskeeper/project.rb', line 50 def jira_prefix details[JIRA_PREFIX_KEY] || "" end |
#project_name ⇒ Object
46 47 48 |
# File 'lib/groundskeeper/project.rb', line 46 def project_name details[PROJECT_NAME_KEY] || "" end |
#repo_url ⇒ Object
94 95 96 |
# File 'lib/groundskeeper/project.rb', line 94 def repo_url "[email protected]:#{source_control_username}/#{repo_name}.git" end |
#rvm_ruby_version ⇒ Object
66 67 68 |
# File 'lib/groundskeeper/project.rb', line 66 def rvm_ruby_version details[RVM_RUBY_VERSION_KEY] || "" end |
#sentry_dsn ⇒ Object
70 71 72 |
# File 'lib/groundskeeper/project.rb', line 70 def sentry_dsn details[SENTRY_DSN_KEY] || "" end |
#sentry_public_dsn ⇒ Object
74 75 76 |
# File 'lib/groundskeeper/project.rb', line 74 def sentry_public_dsn details[SENTRY_PUBLIC_DSN_KEY] || "" end |
#server_config(stage) ⇒ Object
90 91 92 |
# File 'lib/groundskeeper/project.rb', line 90 def server_config(stage) servers[full_dns(stage)] end |
#source_control_username ⇒ Object
54 55 56 |
# File 'lib/groundskeeper/project.rb', line 54 def source_control_username details[SOURCE_CONTROL_USERNAME_KEY] || "" end |
#ssl_certificate_chain_file(stage) ⇒ Object
82 83 84 |
# File 'lib/groundskeeper/project.rb', line 82 def ssl_certificate_chain_file(stage) details.dig(SSL_CERTIFICATE_CHAIN_FILE_KEY, stage.to_s) || "" end |
#ssl_certificate_file(stage) ⇒ Object
78 79 80 |
# File 'lib/groundskeeper/project.rb', line 78 def ssl_certificate_file(stage) details.dig(SSL_CERTIFICATE_FILE_KEY, stage.to_s) || "" end |
#ssl_certificate_key_file(stage) ⇒ Object
86 87 88 |
# File 'lib/groundskeeper/project.rb', line 86 def ssl_certificate_key_file(stage) details.dig(SSL_CERTIFICATE_KEY_FILE_KEY, stage.to_s) || "" end |
#tags ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/groundskeeper/project.rb', line 102 def api_url = "https://api.github.com/repos/" \ "#{source_control_username}/#{repo_name}/tags" = "Authorization: token #{ENV['GITHUB_API_TOKEN']}" response = JSON.parse(`curl -s -H "#{}" #{api_url}`) unless response.is_a?(Array) = response["message"] puts "Failed to obtain response: #{}" return [] end response.map { |h| h["name"] } end |