# A resource for managing SE modules

actions :deploy, :fetch, :compile, :install, :remove
default_action :deploy

attribute :module_name, kind_of: String, name_attribute: true
attribute :force, kind_of: [TrueClass, FalseClass], default: false

attribute :directory, kind_of: String, default: nil # content to work with. Defaults to autogenerated name in the Chef cache. Can be provided and pre-populated
def directory(arg = nil)
  if arg || @directory
    set_or_return(:directory, arg, kind_of: String)
  else
    "#{Chef::Config[:file_cache_path]}/#{module_name}"
  end
end

# Content options:
attribute :content, kind_of: String, default: nil # provide a 'te' file directly. Optional
attribute :directory_source, kind_of: String, default: nil # Source directory for module source code. If specified, will use "remote_directory" on the directory specified as `directory`
attribute :cookbook, kind_of: String, default: nil # Related to directory
