Class: Octopolo::Config
- Inherits:
-
Object
- Object
- Octopolo::Config
- Defined in:
- lib/octopolo/config.rb
Constant Summary collapse
- FILE_NAMES =
%w[.octopolo.yml .automation.yml]
- RECENT_TAG_LIMIT =
9
- RECENT_TAG_FILTER =
we use date-based tags, so look for anything starting with a 4-digit year
/^\d{4}.*/
- InvalidAttributeSupplied =
To be used when attempting to call a Config attribute for which there is a value supplied that is of not the correct type
Class.new(StandardError)
- MissingRequiredAttribute =
To be used when attempting to call a Config attribute for which there is no sensible default and one hasn’t been supplied by the app
Class.new(StandardError)
- NoBranchOfType =
To be used when looking for a branch of a given type (like staging or deployable), but none exist.
Class.new(StandardError)
Instance Attribute Summary collapse
-
#cli ⇒ Object
Returns the value of attribute cli.
Class Method Summary collapse
Instance Method Summary collapse
- #app_name ⇒ Object
- #assign(attributes) ⇒ Object
- #basedir ⇒ Object
- #branches_to_keep ⇒ Object
-
#deploy_branch ⇒ Object
default values for these customizations.
- #deploy_environments ⇒ Object
- #deploy_methods ⇒ Object
- #deployable_label ⇒ Object
- #github_repo ⇒ Object
-
#initialize(attributes = {}) ⇒ Config
constructor
A new instance of Config.
- #jira_password ⇒ Object
- #jira_url ⇒ Object
- #jira_user ⇒ Object
- #load_plugins ⇒ Object
- #merge_resolver ⇒ Object
- #plugins ⇒ Object
- #remote_branch_exists?(branch) ⇒ Boolean
- #semantic_versioning ⇒ Object
- #use_jira ⇒ Object
- #use_pivotal_tracker ⇒ Object
- #user_notifications ⇒ Object
Constructor Details
Instance Attribute Details
#cli ⇒ Object
Returns the value of attribute cli.
13 14 15 |
# File 'lib/octopolo/config.rb', line 13 def cli @cli end |
Class Method Details
.attributes_from_file ⇒ Object
98 99 100 101 102 |
# File 'lib/octopolo/config.rb', line 98 def self.attributes_from_file if path = octopolo_config_path YAML.load_file(path) end end |
.octopolo_config_path ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/octopolo/config.rb', line 104 def self.octopolo_config_path if filepath = FILE_NAMES.detect {|filename| File.exists?(filename)} File.join(Dir.pwd, filepath) else old_dir = Dir.pwd Dir.chdir('..') if old_dir != Dir.pwd octopolo_config_path else Octopolo::CLI.say "*** WARNING: Could not find #{FILE_NAMES.join(' or ')} ***" end end end |
.parse ⇒ Object
end defaults
94 95 96 |
# File 'lib/octopolo/config.rb', line 94 def self.parse new(attributes_from_file || {}) end |
Instance Method Details
#app_name ⇒ Object
145 146 147 |
# File 'lib/octopolo/config.rb', line 145 def app_name basedir end |
#assign(attributes) ⇒ Object
128 129 130 131 132 |
# File 'lib/octopolo/config.rb', line 128 def assign(attributes) attributes.each do |key, value| self.instance_variable_set("@#{key}", value) end end |
#basedir ⇒ Object
134 135 136 |
# File 'lib/octopolo/config.rb', line 134 def basedir File.basename File.dirname Config.octopolo_config_path end |
#branches_to_keep ⇒ Object
27 28 29 |
# File 'lib/octopolo/config.rb', line 27 def branches_to_keep @branches_to_keep || [] end |
#deploy_branch ⇒ Object
default values for these customizations
23 24 25 |
# File 'lib/octopolo/config.rb', line 23 def deploy_branch @deploy_branch || "master" end |
#deploy_environments ⇒ Object
31 32 33 |
# File 'lib/octopolo/config.rb', line 31 def deploy_environments @deploy_environments || [] end |
#deploy_methods ⇒ Object
35 36 37 |
# File 'lib/octopolo/config.rb', line 35 def deploy_methods @deploy_methods || [] end |
#deployable_label ⇒ Object
39 40 41 |
# File 'lib/octopolo/config.rb', line 39 def deployable_label @deployable_label.nil? ? true : @deployable_label end |
#github_repo ⇒ Object
43 44 45 |
# File 'lib/octopolo/config.rb', line 43 def github_repo @github_repo || raise(MissingRequiredAttribute, "GitHub Repo is required") end |
#jira_password ⇒ Object
80 81 82 |
# File 'lib/octopolo/config.rb', line 80 def jira_password @jira_password || raise(MissingRequiredAttribute, "Jira Password is required") if use_jira end |
#jira_url ⇒ Object
84 85 86 |
# File 'lib/octopolo/config.rb', line 84 def jira_url @jira_url || raise(MissingRequiredAttribute, "Jira Url is required") if use_jira end |
#jira_user ⇒ Object
76 77 78 |
# File 'lib/octopolo/config.rb', line 76 def jira_user @jira_user || raise(MissingRequiredAttribute, "Jira User is required") if use_jira end |
#load_plugins ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/octopolo/config.rb', line 118 def load_plugins plugins.each do |plugin| begin require plugin rescue LoadError puts "Plugin '#{plugin}' failed to load" end end end |
#merge_resolver ⇒ Object
47 48 49 |
# File 'lib/octopolo/config.rb', line 47 def merge_resolver @merge_resolver end |
#plugins ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/octopolo/config.rb', line 59 def plugins case @plugins when Array, String then Array(@plugins) when NilClass then [] else raise(InvalidAttributeSupplied, "Plugins must be an array or string") end end |
#remote_branch_exists?(branch) ⇒ Boolean
138 139 140 141 142 143 |
# File 'lib/octopolo/config.rb', line 138 def remote_branch_exists?(branch) branches = Octopolo::CLI.perform "git branch -r", false branch_list = branches.split(/\r?\n/) branch_list.each { |x| x.gsub!(/\*|\s/,'') } branch_list.include? "origin/#{branch}" end |
#semantic_versioning ⇒ Object
88 89 90 |
# File 'lib/octopolo/config.rb', line 88 def semantic_versioning @semantic_versioning || false end |
#use_jira ⇒ Object
72 73 74 |
# File 'lib/octopolo/config.rb', line 72 def use_jira !!@use_jira end |
#use_pivotal_tracker ⇒ Object
68 69 70 |
# File 'lib/octopolo/config.rb', line 68 def use_pivotal_tracker !!@use_pivotal_tracker end |
#user_notifications ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/octopolo/config.rb', line 51 def user_notifications if [NilClass, Array, String].include?(@user_notifications.class) Array(@user_notifications) if @user_notifications else raise(InvalidAttributeSupplied, "User notifications must be an array or string") end end |