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 =
"~/.project_details/servers.yml"
- JIRA_PREFIX_KEY =
"jira_prefix"
- PROJECT_NAME_KEY =
"name"
- FULL_DNS_KEY =
"full_dns"
- RVM_RUBY_VERSION_KEY =
"ruby_version"
- SENTRY_DSN_KEY =
"sentry_dsn"
- SENTRY_PROJECT_KEY =
"sentry_project"
- SMTP_DOMAIN =
"smtp_domain"
- WHENEVER_KEY =
"uses_whenever"
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#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
-
#deploy_to ⇒ Object
:nocov:.
- #full_dns(stage) ⇒ Object
-
#initialize(projects_yaml:, servers_yaml:, repository_name:, git: nil) ⇒ Project
constructor
:nocov:.
- #jira_prefix ⇒ Object
- #project_name ⇒ Object
-
#repo_url ⇒ Object
:nocov:.
-
#rvm_ruby_version ⇒ Object
:nocov:.
-
#sentry_dsn ⇒ Object
:nocov:.
-
#sentry_project ⇒ Object
:nocov:.
-
#server_config(stage) ⇒ Object
:nocov:.
-
#smtp_domain ⇒ Object
:nocov:.
-
#tags ⇒ Object
:nocov:.
-
#uses_whenever? ⇒ Boolean
:nocov:.
Constructor Details
#initialize(projects_yaml:, servers_yaml:, repository_name:, git: nil) ⇒ Project
:nocov:
39 40 41 42 43 44 45 |
# File 'lib/groundskeeper/project.rb', line 39 def initialize(projects_yaml:, servers_yaml:, repository_name:, git: nil) projects = YAML.safe_load(projects_yaml) || {} @details = projects[repository_name] || {} @servers = YAML.safe_load(servers_yaml) || {} @repo_name = repository_name @git = git 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 |
#git ⇒ Object (readonly)
Returns the value of attribute git.
9 10 11 |
# File 'lib/groundskeeper/project.rb', line 9 def git @git 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
:nocov:
32 33 34 35 36 |
# File 'lib/groundskeeper/project.rb', line 32 def self.available_applications yaml = Document.new(DETAILS_PATH).read projects = YAML.safe_load(yaml) || {} projects.keys.join(", ") end |
.build(repository_name) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/groundskeeper/project.rb', line 22 def self.build(repository_name) new( projects_yaml: Document.new(DETAILS_PATH).read, servers_yaml: Document.new(SERVERS_PATH).read, repository_name: repository_name, git: Git.build ) end |
Instance Method Details
#deploy_to ⇒ Object
:nocov:
100 101 102 |
# File 'lib/groundskeeper/project.rb', line 100 def deploy_to "/var/www/apps/#{repo_name}" end |
#full_dns(stage) ⇒ Object
55 56 57 |
# File 'lib/groundskeeper/project.rb', line 55 def full_dns(stage) details.dig(FULL_DNS_KEY, stage.to_s) || "" end |
#jira_prefix ⇒ Object
51 52 53 |
# File 'lib/groundskeeper/project.rb', line 51 def jira_prefix details[JIRA_PREFIX_KEY] || "" end |
#project_name ⇒ Object
47 48 49 |
# File 'lib/groundskeeper/project.rb', line 47 def project_name details[PROJECT_NAME_KEY] || "" end |
#repo_url ⇒ Object
:nocov:
94 95 96 |
# File 'lib/groundskeeper/project.rb', line 94 def repo_url git.origin_url end |
#rvm_ruby_version ⇒ Object
:nocov:
66 67 68 |
# File 'lib/groundskeeper/project.rb', line 66 def rvm_ruby_version details[RVM_RUBY_VERSION_KEY] || "" end |
#sentry_dsn ⇒ Object
:nocov:
72 73 74 |
# File 'lib/groundskeeper/project.rb', line 72 def sentry_dsn details[SENTRY_DSN_KEY] || "" end |
#sentry_project ⇒ Object
:nocov:
77 78 79 |
# File 'lib/groundskeeper/project.rb', line 77 def sentry_project details[SENTRY_PROJECT_KEY] || "" end |
#server_config(stage) ⇒ Object
:nocov:
88 89 90 |
# File 'lib/groundskeeper/project.rb', line 88 def server_config(stage) servers[full_dns(stage)] end |
#smtp_domain ⇒ Object
:nocov:
60 61 62 |
# File 'lib/groundskeeper/project.rb', line 60 def smtp_domain details[SMTP_DOMAIN] || "" end |
#tags ⇒ Object
:nocov:
106 107 108 |
# File 'lib/groundskeeper/project.rb', line 106 def git. end |
#uses_whenever? ⇒ Boolean
:nocov:
82 83 84 |
# File 'lib/groundskeeper/project.rb', line 82 def uses_whenever? details[WHENEVER_KEY] == true end |