- def get_pkg_common_dir
- common_dir = ""
- if @hash["cci-makepkg"]?
pkg_style = "cci-makepkg"
- elsif @hash["cci-depends"]?
pkg_style = "cci-depends"
- elsif @hash["build-pkg"]?
pkg_style = "build-pkg"
- else
pkg_style = nil
- end
- if pkg_style
tmp = @hash["#{pkg_style}"]
tmp_os = tmp["os"]? ? tmp["os"].to_s : "#{os}"
No need to use 'to_s' here, "#{}" will do this automatically. Just make 'tmp_os': JSON::Any | String.
tmp_os_arch = tmp["os_arch"]? ? tmp["os_arch"].to_s : "#{os_arch}"
tmp_os_version = tmp["os_version"]? ? tmp["os_version"].to_s : "#{os_version}"
tmp_os_mount = tmp["os_mount"]? ? tmp["os_mount"].to_s : "#{os_mount}"
mount_type = tmp_os_mount == "cifs" ? "nfs" : tmp_os_mount.dup
common_dir = "#{mount_type}/#{tmp_os}/#{tmp_os_arch}/#{tmp_os_version}"
- end
How about this, save the @hash[pkg_style]? first :
v1 = nil ["cci-makepkg", "cci-depends", "build-pkg"].each do |pkg_style| v1 = @hash[pkg_style]? break if v1 end
return "" unless v1 ...
Thanks, RenWen
- return common_dir
- end
- def get_package_dir if @hash["cci-makepkg"]? || @hash["cci-depends"]? || @hash["build-pkg"]?
mount_type = os_mount == "cifs" ? "nfs" : os_mount.dup
common_dir = "#{mount_type}/#{os}/#{os_arch}/#{os_version}"
common_dir = get_pkg_common_dir
end
if @hash["cci-makepkg"]?
-- 2.23.0