diff options
author | Saku Ytti <saku@ytti.fi> | 2018-06-22 18:39:59 +0300 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2018-06-22 18:39:59 +0300 |
commit | ee2a575054e3d8f44b6ea92974a22ebb455dc770 (patch) | |
tree | ce10d7e60e025e3c00170159888aaaa88effebd2 /lib/oxidized | |
parent | 73b92861a46f1f1d3be560c12e0e9dd0eab00707 (diff) |
Remove resolve_repo smells
Diffstat (limited to 'lib/oxidized')
-rw-r--r-- | lib/oxidized/node.rb | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index 300221e..bc1a586 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -173,32 +173,18 @@ module Oxidized end def resolve_repo opt - if is_git? opt - remote_repo = Oxidized.config.output.git.repo - - if remote_repo.is_a?(::String) - if Oxidized.config.output.git.single_repo? || @group.nil? - remote_repo - else - File.join(File.dirname(remote_repo), @group + '.git') - end - else - remote_repo[@group] - end - elsif is_gitcrypt? opt - remote_repo = Oxidized.config.output.gitcrypt.repo - - if remote_repo.is_a?(::String) - if Oxidized.config.output.gitcrypt.single_repo? || @group.nil? - remote_repo - else - File.join(File.dirname(remote_repo), @group + '.git') - end + type = git_type opt + return nil unless type + + remote_repo = Oxidized.config.output.send(type).repo + if remote_repo.is_a?(::String) + if Oxidized.config.output.send(type).single_repo? || @group.nil? + remote_repo else - remote_repo[@group] + File.join(File.dirname(remote_repo), @group + '.git') end else - return + remote_repo[@group] end end @@ -237,12 +223,11 @@ module Oxidized value end - def is_git? opt - (opt[:output] || Oxidized.config.output.default) == 'git' + def git_type + type = opt[:output] || Oxidized.config.output.default + return nil unless type[0..2] == "git" + type end - def is_gitcrypt? opt - (opt[:output] || Oxidized.config.output.default) == 'gitcrypt' - end end end |