diff --git a/shard.yml b/shard.yml index e25ebbc..6ab6070 100644 --- a/shard.yml +++ b/shard.yml @@ -7,3 +7,7 @@ authors: crystal: 0.24.1 license: MIT + +dependencies: + cry: + github: elorest/cry diff --git a/spec/compiled_license_spec.cr b/spec/compiled_license_spec.cr index fb698b5..cb3364c 100644 --- a/spec/compiled_license_spec.cr +++ b/spec/compiled_license_spec.cr @@ -1,9 +1,22 @@ require "./spec_helper" describe CompiledLicense do - # TODO: Write tests + licenses = {{ run("../src/compiled_license/licenses.cr").stringify }} - it "works" do - false.should eq(true) + it "should return string" do + (licenses.size > 20).should be_true + end + + it "should include license of current file" do + licenses.should contain("Compiled_license") + end + + it "should contain name of author from license file" do + licenses.should contain("Isaac Sloan") + end + + it "should contain more than one license" do + delimiter = "\n\n" + (licenses.split(delimiter).size > 1).should be_true end end diff --git a/src/compiled_license.cr b/src/compiled_license.cr index 4a55552..092d616 100644 --- a/src/compiled_license.cr +++ b/src/compiled_license.cr @@ -3,12 +3,12 @@ require "./compiled_license/version" module Compiled module License def self.display - {{ run("../compiled_license/licenses.cr").stringify }} + {{ run("./compiled_license/licenses.cr").stringify }} end end end if ARGV[0]? && ARGV[0]? == "--license" - puts Amber::Support::Licenses.display + puts Compiled::License.display exit 0 end diff --git a/src/compiled_license/licenses.cr b/src/compiled_license/licenses.cr index 4299fff..d72e2ad 100644 --- a/src/compiled_license/licenses.cr +++ b/src/compiled_license/licenses.cr @@ -1,4 +1,12 @@ licenses = String.build do |s| + if File.exists?("./LICENSE") + s.puts Dir.current.split("/").last.capitalize + s.puts "================================================================================" + s.puts File.read("./LICENSE") + s.puts "================================================================================" + s.puts "\n\n" + end + Dir.glob("./lib/*/LICENSE", "./lib/*/license").each do |path| s.puts path.match(/^\.\/lib\/([^\/]+)\//).try(&.[1]).to_s.capitalize s.puts "================================================================================"