Skip to content

Commit

Permalink
Clean up strict warnings for credo
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhamelink committed Oct 5, 2016
1 parent 82583a9 commit 65bd0a1
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 20 deletions.
5 changes: 3 additions & 2 deletions lib/exrm_deb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule ReleaseManager.Plugin.Deb do

import Logger, only: [info: 1, debug: 1]
alias ExrmDeb.{Control, Data, Deb}
alias Mix.Project

def before_release(_), do: nil

Expand Down Expand Up @@ -37,13 +38,13 @@ defmodule ReleaseManager.Plugin.Deb do
end

def remove_deb_dir do
[Mix.Project.build_path, "deb"]
[Project.build_path, "deb"]
|> Path.join
|> File.rm_rf
end

defp initialize_dir do
deb_root = Path.join([Mix.Project.build_path, "deb"])
deb_root = Path.join([Project.build_path, "deb"])

debug("Building base debian directory")
:ok = File.mkdir_p(deb_root)
Expand Down
9 changes: 5 additions & 4 deletions lib/exrm_deb/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule ExrmDeb.Config do

use Vex.Struct
alias ReleaseManager.Utils.Logger
alias Mix.Project
import Logger, only: [debug: 1, error: 1]

# This version number format should be able to handle regular version
Expand All @@ -32,11 +33,11 @@ defmodule ExrmDeb.Config do
def build_config(old_config = %{} \\ %{}) do
base_config =
[
{:name, Atom.to_string(Mix.Project.config[:app])},
{:version, Mix.Project.config[:version]},
{:description, Mix.Project.config[:description]},
{:name, Atom.to_string(Project.config[:app])},
{:version, Project.config[:version]},
{:description, Project.config[:description]},
{:arch, ExrmDeb.Utils.Config.detect_arch}
] ++ config_from_package(Mix.Project.config[:package])
] ++ config_from_package(Project.config[:package])

base_config =
base_config
Expand Down
6 changes: 4 additions & 2 deletions lib/exrm_deb/control.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ defmodule ExrmDeb.Control do
custom control data such as pre/post install hooks.
"""
alias ReleaseManager.Utils.Logger
alias ExrmDeb.Generators.Control
alias ExrmDeb.Utils.Compression
import Logger, only: [debug: 1]

# - Add ability to create pre-inst / post-inst hooks [WIP]
Expand All @@ -13,9 +15,9 @@ defmodule ExrmDeb.Control do
debug "Building debian control directory"
:ok = File.mkdir_p(control_dir)

ExrmDeb.Generators.Control.build(config, control_dir)
Control.build(config, control_dir)
add_custom_hooks(config, control_dir)
ExrmDeb.Utils.Compression.compress(
Compression.compress(
control_dir,
Path.join([control_dir, "..", "control.tar.gz"])
)
Expand Down
13 changes: 8 additions & 5 deletions lib/exrm_deb/data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@ defmodule ExrmDeb.Data do
debian package.
"""
alias ReleaseManager.Utils.Logger
alias ReleaseManager.Utils
alias ExrmDeb.Utils.Compression
alias ExrmDeb.Generators.{Changelog, Upstart, Systemd}
import Logger, only: [debug: 1]

def build(dir, config) do
data_dir = make_data_dir(dir, config)
copy_release(data_dir, config)
remove_targz_file(data_dir, config)
ExrmDeb.Utils.File.remove_fs_metadata(data_dir)
ExrmDeb.Generators.Changelog.build(data_dir, config)
ExrmDeb.Generators.Upstart.build(data_dir, config)
ExrmDeb.Generators.Systemd.build(data_dir, config)
Changelog.build(data_dir, config)
Upstart.build(data_dir, config)
Systemd.build(data_dir, config)

config = Map.put_new(
config,
:installed_size,
ExrmDeb.Utils.File.get_dir_size(data_dir)
)

ExrmDeb.Utils.Compression.compress(
Compression.compress(
data_dir,
Path.join([data_dir, "..", "data.tar.gz"]),
owner: config.owner
Expand Down Expand Up @@ -51,7 +54,7 @@ defmodule ExrmDeb.Data do

defp copy_release(data_dir, config) do
dest = Path.join([data_dir, "opt", config.name])
src = Path.join(ReleaseManager.Utils.rel_dest_path, config.name)
src = Path.join(Utils.rel_dest_path, config.name)

debug("Copying #{src} into #{dest} directory")
{:ok, _} = File.cp_r(src, dest)
Expand Down
3 changes: 2 additions & 1 deletion lib/exrm_deb/deb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ defmodule ExrmDeb.Deb do
"""

alias ReleaseManager.Utils.Logger
alias ReleaseManager.Utils
import Logger, only: [debug: 1]

def build(dir, config) do
debug "Building deb file"

out = Path.join([
ReleaseManager.Utils.rel_dest_path,
Utils.rel_dest_path,
"#{config.sanitized_name}-#{config.version}.deb"
])

Expand Down
3 changes: 2 additions & 1 deletion lib/exrm_deb/generators/changelog.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule ExrmDeb.Generators.Changelog do
"""
alias ReleaseManager.Utils.Logger
alias ExrmDeb.Generators.TemplateFinder
alias ExrmDeb.Utils.Compression
import Logger, only: [debug: 1]

def build(data_dir, config) do
Expand Down Expand Up @@ -35,7 +36,7 @@ defmodule ExrmDeb.Generators.Changelog do
|> Path.join
|> File.write(changelog)

ExrmDeb.Utils.Compression.compress(doc_dir, "../changelog.gz")
Compression.compress(doc_dir, "../changelog.gz")

[doc_dir, "changelog"]
|> Path.join
Expand Down
6 changes: 4 additions & 2 deletions lib/exrm_deb/generators/template_finder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ defmodule ExrmDeb.Generators.TemplateFinder do
This module decides whether to use a custom template or to use the default.
"""
alias ReleaseManager.Utils.Logger
alias ReleaseManager.Utils, as: Utils
alias ExrmDeb.Utils.Config, as: ConfigUtil
import Logger, only: [debug: 1, info: 1]

def retrieve(pathname) do
Expand All @@ -20,7 +22,7 @@ defmodule ExrmDeb.Generators.TemplateFinder do

defp user_provided_path(pathname) do
[
ReleaseManager.Utils.rel_dest_path,
Utils.rel_dest_path,
"exrm_deb", "templates", pathname
]
|> List.flatten
Expand All @@ -29,7 +31,7 @@ defmodule ExrmDeb.Generators.TemplateFinder do

defp default_path(pathname) do
[
ExrmDeb.Utils.Config.root,
ConfigUtil.root,
"templates", pathname
]
|> List.flatten
Expand Down
3 changes: 2 additions & 1 deletion lib/exrm_deb/utils/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule ExrmDeb.Utils.Config do
@moduledoc ~S"""
This module is used to retrieve basic information for use with configuration
"""
alias Mix.Project

@doc """
Use uname to detect the architecture we're currently building for
Expand Down Expand Up @@ -33,7 +34,7 @@ defmodule ExrmDeb.Utils.Config do
in the library (such as templates)
"""
def root do
Mix.Project.deps_paths
Project.deps_paths
|> Map.fetch(:exrm_deb)
|> case do
{:ok, path} -> path
Expand Down
6 changes: 4 additions & 2 deletions lib/mix/tasks/release.deb.generate_templates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ defmodule Mix.Tasks.Release.Deb.GenerateTemplates do

use Mix.Task
require Logger
alias ExrmDeb.Utils.Config, as: ConfigUtil
alias ReleaseManager.Utils

def run(_args) do
make_dest_dir
Expand All @@ -20,7 +22,7 @@ defmodule Mix.Tasks.Release.Deb.GenerateTemplates do
def copy_templates(dest \\ destination_dir) do
Logger.info "Copying templates to ./rel/exrm_deb/templates"
{:ok, _} =
[ExrmDeb.Utils.Config.root, "templates"]
[ConfigUtil.root, "templates"]
|> Path.join
|> File.cp_r(dest, fn(_source, destination) ->
IO.gets("Overwriting #{destination |> Path.basename }." <>
Expand All @@ -36,7 +38,7 @@ defmodule Mix.Tasks.Release.Deb.GenerateTemplates do
end

defp destination_dir do
[ReleaseManager.Utils.rel_dest_path, "exrm_deb", "templates"]
[Utils.rel_dest_path, "exrm_deb", "templates"]
|> Path.join
end

Expand Down

0 comments on commit 65bd0a1

Please sign in to comment.