Class: MemberReminder::MemberBank
- Inherits:
-
Object
- Object
- MemberReminder::MemberBank
- Includes:
- DingTalk
- Defined in:
- lib/member_reminder.rb,
lib/member_reminder/member_bank.rb
Defined Under Namespace
Constant Summary collapse
- DEFAULT_PATH =
'http://git.2dfire.net/ios/ci-yaml-shell/raw/master/boss_keeper_members.yml'
Instance Attribute Summary collapse
-
#member_yaml ⇒ Object
readonly
Returns the value of attribute member_yaml.
Instance Method Summary collapse
-
#initialize(path = DEFAULT_PATH) ⇒ MemberBank
constructor
A new instance of MemberBank.
- #member_of_authors(authors) ⇒ Object
- #member_of_spec(spec) ⇒ Object
- #members ⇒ Object
- #post(members, content) ⇒ Object
- #teams ⇒ Object
Methods included from DingTalk
Constructor Details
#initialize(path = DEFAULT_PATH) ⇒ MemberBank
Returns a new instance of MemberBank.
25 26 27 28 |
# File 'lib/member_reminder/member_bank.rb', line 25 def initialize(path = DEFAULT_PATH) file = open(path || DEFAULT_PATH) @member_yaml = YAML.load(file.read) end |
Instance Attribute Details
#member_yaml ⇒ Object (readonly)
Returns the value of attribute member_yaml.
23 24 25 |
# File 'lib/member_reminder/member_bank.rb', line 23 def member_yaml @member_yaml end |
Instance Method Details
#member_of_authors(authors) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/member_reminder/member_bank.rb', line 30 def () member = .keys.map do |name| members.find do |member| (Array(member.name) + Array(member.alias_names)).map(&:pinyin).include?(name..downcase) end end.compact.first member end |
#member_of_spec(spec) ⇒ Object
39 40 41 |
# File 'lib/member_reminder/member_bank.rb', line 39 def member_of_spec(spec) (spec.) end |
#members ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/member_reminder/member_bank.rb', line 43 def members @members ||= begin mobiles = @member_yaml['mobiles'] groups = @member_yaml['groups'] @member_yaml['members'].map do |name, alias_names| member = Member.new member.name = name member.alias_names = alias_names member.team = teams.find do |team| token, _ = groups.find { |token, ms| ms.include?(name) } team.ding_token == token end member.mobile = mobiles[name] member end end end |
#post(members, content) ⇒ Object
9 10 11 12 13 |
# File 'lib/member_reminder.rb', line 9 def post(members, content) members.compact.group_by { |m| m.team.ding_token }.each do |token ,ms| super token, content, ms.map(&:mobile) end end |