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 | 25f3d40a2f2de394d8727270406b3e9db056989a (patch) | |
tree | b018b63af17998e4bc84d1961f6b98c923798f8a | |
parent | 9aaef6e1f8444b59a7777e7d0979a87cb7b0a41a (diff) | |
download | rabbitmq-server-25f3d40a2f2de394d8727270406b3e9db056989a.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 4db345a1..7c12cc1c 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 |