Repository: conan-io/conan-center-index

Issue:
[request] kangaru/4.2.4
### Package Details
  * Package Name/Version: gracicot/kangaru/4.2.4
  * Website: https://github.com/gracicot/kangaru/wiki
  * Source code: https://github.com/gracicot/kangaru


### Description Of The Library / Tool
This is a straight-forward **header-only** library that provides a DI mechanism.


Discussion:
Even though it's a header only library, I rely on CMake to generate some configuration header. I properly export a CMake target and the library is installable. It expects either to be installed or used from the build tree.
Hi @AGreat1 ! Thanks for your request. May you interested in creating this recipe? It would be great having you contribution.

There is a full tutorial here how to contribute: https://github.com/conan-io/conan-center-index/wiki#adding-packages-to-conancenter

Regards!
I'll give it a try.
I'm not sure here, but am I correct that [this](https://github.com/conan-io/conan-center-index/wiki/Error-Knowledge-Base#kb-h019-cmake-file-not-in-build-folders) paragraph is out-dated, and `builddirs` is now `build_modules` ?
also [this](https://github.com/conan-io/conan-center-index/wiki/Error-Knowledge-Base#kb-h041-no-final-endline) is a problem not with the package itself, rather with the library being packaged, right?

Resolving patch:
diff --git a/recipes/kangaru/all/conanfile.py b/recipes/kangaru/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/kangaru/all/conanfile.py
@@ -0,0 +1,40 @@
+from conans import ConanFile, tools, CMake
+import os
+
+class KangaruConan(ConanFile):
+    name = "kangaru"
+    description = "A dependency injection container for C++11, C++14 and later"
+    license = "MIT"
+    topics = ("conan", "gracicot", "kangaru", "DI", "IoC", "inversion of control")
+    homepage = "https://github.com/gracicot/kangaru/wiki"
+    url = "https://github.com/conan-io/conan-center-index"
+    options = {"reverse_destruction": [True, False],
+                "no_exception": [True, False]}
+    default_options = {"reverse_destruction": True,
+                        "no_exception": False}
+    no_copy_source = True
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version])
+        os.rename(self.name + "-" + self.version, self._source_subfolder)
+
+    def _configure_cmake(self):
+        cmake = CMake(self)
+        cmake.definitions["KANGARU_REVERSE_DESTRUCTION"] = self.options.reverse_destruction
+        cmake.definitions["KANGARU_NO_EXCEPTION"] = self.options.no_exception
+        cmake.configure(source_folder=self._source_subfolder)
+        return cmake
+
+    def build(self):
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package(self):
+        cmake = self._configure_cmake()
+        cmake.install()
+        tools.rmdir(os.path.join(self.package_folder, "lib"))
+        self.copy(os.path.join(self._source_subfolder, "LICENSE"), "licenses")


Test patch:
diff --git a/recipes/kangaru/all/test_package/CMakeLists.txt b/recipes/kangaru/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/kangaru/all/test_package/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 2.8.11)
+project(test_package CXX)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+add_executable(${PROJECT_NAME} test_package.cpp)
+target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
diff --git a/recipes/kangaru/all/test_package/conanfile.py b/recipes/kangaru/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/kangaru/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self.settings):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/kangaru/all/test_package/test_package.cpp b/recipes/kangaru/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/kangaru/all/test_package/test_package.cpp
@@ -0,0 +1,36 @@
+#include <kangaru/kangaru.hpp>
+#include <iostream>
+
+/**
+ * This example only show basic usage of services and the conatainer.
+ */
+
+// Normal classes with dependency between them
+struct Camera {};
+
+struct Scene {
+	Camera& camera;
+};
+
+// This is the configuration of our classes.
+// Structure and dependency graph is defined here.
+
+// Camera is a single service so the service has a shared instance.
+struct CameraService : kgr::single_service<Camera> {};
+
+// Scene is not single, so the container return scenes by value.
+// Also, we depends on a camera to be constructed.
+struct SceneService : kgr::service<Scene, kgr::dependency<CameraService>> {};
+
+int main()
+{
+	kgr::container container;
+	
+	// The service function return instances of the normal classes.
+	Scene scene = container.service<SceneService>();
+	Camera& camera = container.service<CameraService>();
+	
+	std::cout
+		<< std::boolalpha
+		<< (&scene.camera == &camera) << std::endl; // outputs true
+}