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/**", "**/tmp/**", "**/spec/**", "**/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.
11 12 13 |
# File 'lib/kettle/family/config.rb', line 11 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/kettle/family/config.rb', line 11 def path @path end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
11 12 13 |
# File 'lib/kettle/family/config.rb', line 11 def root @root end |
Class Method Details
.load(root:, path: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/kettle/family/config.rb', line 13 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
124 125 126 |
# File 'lib/kettle/family/config.rb', line 124 def branch_lanes fetch_path("branch_lanes") || fetch_path("branches", "lanes") || {} end |
#command_for(name) ⇒ Object
80 81 82 |
# File 'lib/kettle/family/config.rb', line 80 def command_for(name) fetch_path("commands", name) end |
#discover_members? ⇒ Boolean
61 62 63 64 |
# File 'lib/kettle/family/config.rb', line 61 def discover_members? members = data.fetch("members", {}) members.fetch("discover", true) end |
#explicit_members ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/kettle/family/config.rb', line 51 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
34 35 36 |
# File 'lib/kettle/family/config.rb', line 34 def family_mode fetch_path("family", "mode") || "monorepo" end |
#family_name ⇒ Object
30 31 32 |
# File 'lib/kettle/family/config.rb', line 30 def family_name fetch_path("family", "name") || File.basename(root) end |
#member_exclude_patterns ⇒ Object
66 67 68 69 70 |
# File 'lib/kettle/family/config.rb', line 66 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
43 44 45 46 47 48 49 |
# File 'lib/kettle/family/config.rb', line 43 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
38 39 40 41 |
# File 'lib/kettle/family/config.rb', line 38 def members_root configured = fetch_path("family", "members_root") || fetch_path("members", "root") configured ? File.(configured, root) : root end |
#normalize_lockfiles? ⇒ Boolean
96 97 98 |
# File 'lib/kettle/family/config.rb', line 96 def normalize_lockfiles? fetch_path("template", "normalize_lockfiles") == true end |
#normalize_lockfiles_command ⇒ Object
100 101 102 |
# File 'lib/kettle/family/config.rb', line 100 def normalize_lockfiles_command fetch_path("template", "normalize_lockfiles_command") || "bundle lock" end |
#order_hints ⇒ Object
76 77 78 |
# File 'lib/kettle/family/config.rb', line 76 def order_hints fetch_path("members", "order", "hints") || [] end |
#order_mode ⇒ Object
72 73 74 |
# File 'lib/kettle/family/config.rb', line 72 def order_mode fetch_path("members", "order", "mode") || "dependency" end |
#release_build_command ⇒ Object
104 105 106 |
# File 'lib/kettle/family/config.rb', line 104 def release_build_command fetch_path("release", "build_command") || command_for("release_build") || "bundle exec rake build" end |
#release_publish_command ⇒ Object
108 109 110 |
# File 'lib/kettle/family/config.rb', line 108 def release_publish_command fetch_path("release", "publish_command") || command_for("release_publish") || "bundle exec kettle-release" end |
#release_push_command ⇒ Object
116 117 118 |
# File 'lib/kettle/family/config.rb', line 116 def release_push_command fetch_path("release", "push_command") || command_for("release_push") || "git push --follow-tags" end |
#release_tag_command ⇒ Object
112 113 114 |
# File 'lib/kettle/family/config.rb', line 112 def release_tag_command fetch_path("release", "tag_command") || command_for("release_tag") || "git tag" end |
#release_target_branches ⇒ Object
120 121 122 |
# File 'lib/kettle/family/config.rb', line 120 def release_target_branches fetch_path("release", "target_branches") || fetch_path("branches", "release_targets") || [] end |
#template_command ⇒ Object
84 85 86 |
# File 'lib/kettle/family/config.rb', line 84 def template_command fetch_path("template", "command") || command_for("template") end |
#template_profile ⇒ Object
88 89 90 |
# File 'lib/kettle/family/config.rb', line 88 def template_profile fetch_path("template", "profile") end |
#template_repository_topology ⇒ Object
92 93 94 |
# File 'lib/kettle/family/config.rb', line 92 def template_repository_topology fetch_path("template", "repository_topology") end |