]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/common/plugin.rb
1 # All plugins should include this module. It defines the basic
2 # operations that all plugins are supposed to support.
6 # Callback, called whenever another class or module includes this
7 # one. The parameter given is the name of the class or module
18 # The Runner associated with this plugin.
19 raise NotImplementedError
23 # The RummyRunner associated with this plugin.
24 raise NotImplementedError
27 def describe_domain(domain
)
28 # Provide a "description" of the domain. This is output along
29 # with the domain name and can be anything of use to the system
31 raise NotImplementedError
34 def describe_user(user
)
35 # Provide a "description" of the user. This is output along
36 # with the domain name and can be anything of use to the system
38 raise NotImplementedError
42 # Return a list of all users managed by this plugin.
43 raise NotImplementedError
46 def user_exists(username
)
47 # Does the given username exist for this plugin? We use a naive
48 # implementation here based on list_users() which is required to
49 # exist above. Plugins can override this with something fast.
51 return users
.include?(username
)
54 def list_domains_users(domains
)
55 # Get all usernames belonging to the given domains. If a username
56 # ends in @example.com, it belongs to the domain example.com
58 # This uses a naive loop, but relies only on the existence of a
59 # list_users() method which is guaranteed above. More efficient
60 # implementations can usually be made within the plugin.
63 usernames
= list_users();
65 matches
= usernames
.select
do |username
|
69 domains_users +
= matches