diff options
| author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-26 18:20:45 +0100 |
|---|---|---|
| committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2011-09-26 18:20:45 +0100 |
| commit | 42bef2998e94e67abce7a53c588186da1f5e9573 (patch) | |
| tree | b018b63af17998e4bc84d1961f6b98c923798f8a | |
| parent | 7202c9d02f85ca8b0126ebbfb6ce457fbf87a064 (diff) | |
| download | rabbitmq-server-git-42bef2998e94e67abce7a53c588186da1f5e9573.tar.gz | |
refactor
| -rw-r--r-- | src/rabbit_plugins.erl | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index 4db345a1d8..7c12cc1c07 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -172,32 +172,28 @@ find_plugins(PluginsDistDir) -> get_plugin_info(Base, {ez, EZ0}) -> EZ = filename:join([Base, EZ0]), case read_app_file(EZ) of - {application, Name, Props} -> - Version = proplists:get_value(vsn, Props, "0"), - Description = proplists:get_value(description, Props, ""), - Dependencies = - filter_applications(proplists:get_value(applications, Props, [])), - #plugin{name = Name, version = Version, description = Description, - dependencies = Dependencies, location = EZ, type = ez}; - {error, Reason} -> - {error, EZ, Reason} + {application, Name, Props} -> mkplugin(Name, Props, ez, EZ); + {error, Reason} -> {error, EZ, Reason} end; %% Get the #plugin{} from an .app. get_plugin_info(Base, {app, App0}) -> App = filename:join([Base, App0]), case rabbit_file:read_term_file(App) of {ok, [{application, Name, Props}]} -> - Version = proplists:get_value(vsn, Props, "0"), - Description = proplists:get_value(description, Props, ""), - Dependencies = - filter_applications(proplists:get_value(applications, Props, [])), - Location = filename:absname(filename:dirname(filename:dirname(App))), - #plugin{name = Name, version = Version, description = Description, - dependencies = Dependencies, location = Location, type = dir}; + mkplugin(Name, Props, dir, + filename:absname(filename:dirname(filename:dirname(App)))); {error, Reason} -> {error, App, {invalid_app, Reason}} end. +mkplugin(Name, Props, Type, Location) -> + Version = proplists:get_value(vsn, Props, "0"), + Description = proplists:get_value(description, Props, ""), + Dependencies = + filter_applications(proplists:get_value(applications, Props, [])), + #plugin{name = Name, version = Version, description = Description, + dependencies = Dependencies, location = Location, type = Type}. + %% Read the .app file from an ez. read_app_file(EZ) -> case zip:list_dir(EZ) of |
