Class: Kettle::Family::Config
- Inherits:
-
Object
- Object
- Kettle::Family::Config
- Defined in:
- lib/kettle/family/config.rb
Constant Summary collapse
- DEFAULT_PATHS =
[".kettle-family.yml", ".structuredmerge/kettle-family.yml"].freeze
- DEFAULT_MEMBER_EXCLUDES =
[ "vendor/**", "**/vendor/**", "tmp/**", "**/tmp/**", "spec/**", "**/spec/**", "test/**", "**/test/**" ].freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #branch_lanes ⇒ Object
- #command_for(name) ⇒ Object
- #discover_members? ⇒ Boolean
- #explicit_members ⇒ Object
- #family_mode ⇒ Object
- #family_name ⇒ Object
-
#initialize(root:, path:, data:) ⇒ Config
constructor
A new instance of Config.
- #member_exclude_patterns ⇒ Object
- #member_roots ⇒ Object
- #members_root ⇒ Object
- #normalize_lockfiles? ⇒ Boolean
- #normalize_lockfiles_command ⇒ Object
- #order_hints ⇒ Object
- #order_mode ⇒ Object
- #release_build_command ⇒ Object
- #release_publish_command ⇒ Object
- #release_push_command ⇒ Object
- #release_tag_command ⇒ Object
- #release_target_branches ⇒ Object
- #template_command ⇒ Object
- #template_profile ⇒ Object
- #template_repository_topology ⇒ Object
Constructor Details
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
20 21 22 |
# File 'lib/kettle/family/config.rb', line 20 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
20 21 22 |
# File 'lib/kettle/family/config.rb', line 20 def path @path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
20 21 22 |
# File 'lib/kettle/family/config.rb', line 20 def root @root end |
Class Method Details
.load(root:, path: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/kettle/family/config.rb', line 22 def self.load(root:, path: nil) = File.(root) config_path = path && File.(path, ) config_path ||= DEFAULT_PATHS .map { |candidate| File.join(, candidate) } .find { |candidate| File.file?(candidate) } data = config_path ? YAML.load_file(config_path) : {} new(root: , path: config_path, data: data || {}) end |
Instance Method Details
#branch_lanes ⇒ Object
133 134 135 |
# File 'lib/kettle/family/config.rb', line 133 def branch_lanes fetch_path("branch_lanes") || fetch_path("branches", "lanes") || {} end |
#command_for(name) ⇒ Object
89 90 91 |
# File 'lib/kettle/family/config.rb', line 89 def command_for(name) fetch_path("commands", name) end |
#discover_members? ⇒ Boolean
70 71 72 73 |
# File 'lib/kettle/family/config.rb', line 70 def discover_members? members = data.fetch("members", {}) members.fetch("discover", true) end |
#explicit_members ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/kettle/family/config.rb', line 60 def explicit_members members = data.fetch("members", {}) explicit = members.fetch("explicit", []) explicit.map do |entry| entry = stringify_keys(entry) member_root = File.(entry.fetch("root"), root) entry.merge("root" => member_root) end end |
#family_mode ⇒ Object
43 44 45 |
# File 'lib/kettle/family/config.rb', line 43 def family_mode fetch_path("family", "mode") || "monorepo" end |
#family_name ⇒ Object
39 40 41 |
# File 'lib/kettle/family/config.rb', line 39 def family_name fetch_path("family", "name") || File.basename(root) end |
#member_exclude_patterns ⇒ Object
75 76 77 78 79 |
# File 'lib/kettle/family/config.rb', line 75 def member_exclude_patterns members = data.fetch("members", {}) patterns = members.fetch("exclude", nil) || members.fetch("ignore", nil) || [] DEFAULT_MEMBER_EXCLUDES + Array(patterns) end |
#member_roots ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/kettle/family/config.rb', line 52 def member_roots configured = fetch_path("members", "roots") return configured.map { |path| File.(path, root) } if configured return sibling_member_roots if family_mode == "sibling_repos" [members_root] end |
#members_root ⇒ Object
47 48 49 50 |
# File 'lib/kettle/family/config.rb', line 47 def members_root configured = fetch_path("family", "members_root") || fetch_path("members", "root") configured ? File.(configured, root) : root end |
#normalize_lockfiles? ⇒ Boolean
105 106 107 |
# File 'lib/kettle/family/config.rb', line 105 def normalize_lockfiles? fetch_path("template", "normalize_lockfiles") == true end |
#normalize_lockfiles_command ⇒ Object
109 110 111 |
# File 'lib/kettle/family/config.rb', line 109 def normalize_lockfiles_command fetch_path("template", "normalize_lockfiles_command") || "bundle lock" end |
#order_hints ⇒ Object
85 86 87 |
# File 'lib/kettle/family/config.rb', line 85 def order_hints fetch_path("members", "order", "hints") || [] end |
#order_mode ⇒ Object
81 82 83 |
# File 'lib/kettle/family/config.rb', line 81 def order_mode fetch_path("members", "order", "mode") || "dependency" end |
#release_build_command ⇒ Object
113 114 115 |
# File 'lib/kettle/family/config.rb', line 113 def release_build_command fetch_path("release", "build_command") || command_for("release_build") || "bundle exec rake build" end |
#release_publish_command ⇒ Object
117 118 119 |
# File 'lib/kettle/family/config.rb', line 117 def release_publish_command fetch_path("release", "publish_command") || command_for("release_publish") || "bundle exec kettle-release" end |
#release_push_command ⇒ Object
125 126 127 |
# File 'lib/kettle/family/config.rb', line 125 def release_push_command fetch_path("release", "push_command") || command_for("release_push") || "git push --follow-tags" end |
#release_tag_command ⇒ Object
121 122 123 |
# File 'lib/kettle/family/config.rb', line 121 def release_tag_command fetch_path("release", "tag_command") || command_for("release_tag") || "git tag" end |
#release_target_branches ⇒ Object
129 130 131 |
# File 'lib/kettle/family/config.rb', line 129 def release_target_branches fetch_path("release", "target_branches") || fetch_path("branches", "release_targets") || [] end |
#template_command ⇒ Object
93 94 95 |
# File 'lib/kettle/family/config.rb', line 93 def template_command fetch_path("template", "command") || command_for("template") end |
#template_profile ⇒ Object
97 98 99 |
# File 'lib/kettle/family/config.rb', line 97 def template_profile fetch_path("template", "profile") end |
#template_repository_topology ⇒ Object
101 102 103 |
# File 'lib/kettle/family/config.rb', line 101 def template_repository_topology fetch_path("template", "repository_topology") end |