Class: Gitomator::Task::Config::TeamConfig
- Inherits:
-
Object
- Object
- Gitomator::Task::Config::TeamConfig
- Defined in:
- lib/gitomator/task/config/team_config.rb
Instance Attribute Summary collapse
-
#members ⇒ Object
readonly
Hash[String -> String], username to role.
-
#name ⇒ Object
readonly
Hash[String -> String], username to role.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, members_config) ⇒ TeamConfig
constructor
A new instance of TeamConfig.
- #parse_members_config(members_config) ⇒ Object
Constructor Details
#initialize(name, members_config) ⇒ TeamConfig
Returns a new instance of TeamConfig.
28 29 30 31 |
# File 'lib/gitomator/task/config/team_config.rb', line 28 def initialize(name, members_config) @name = name @members = parse_members_config(members_config) end |
Instance Attribute Details
#members ⇒ Object (readonly)
Hash[String -> String], username to role
22 23 24 |
# File 'lib/gitomator/task/config/team_config.rb', line 22 def members @members end |
#name ⇒ Object (readonly)
Hash[String -> String], username to role
22 23 24 |
# File 'lib/gitomator/task/config/team_config.rb', line 22 def name @name end |
Class Method Details
.from_hash(config) ⇒ Enumerable<Gitomator::Task::Config::TeamConfig>
15 16 17 |
# File 'lib/gitomator/task/config/team_config.rb', line 15 def self.from_hash(config) return config.map {|name, members| new(name, members) } end |
Instance Method Details
#parse_members_config(members_config) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gitomator/task/config/team_config.rb', line 34 def parse_members_config(members_config) result = {} members_config.each do |entry| if entry.is_a? String result[entry] = 'member' # Default role is 'member' elsif entry.is_a?(Hash) && entry.length == 1 result[entry.keys.first] = entry.values.first else raise "Invalid team-member config, #{entry}." end end return result end |