From 22ab96d7d08fe4fbe76e4d3df4c7c9e95b2a67e5 Mon Sep 17 00:00:00 2001 From: grimmigerFuchs Date: Sat, 23 Oct 2021 12:17:50 +0200 Subject: [PATCH] rewrite --- .travis.yml | 1 - shard.yml | 3 ++- spec/compiled_license_spec.cr | 9 +++++---- spec/spec_helper.cr | 2 -- src/compiled_license.cr | 15 +++------------ src/compiled_license/licenses.cr | 18 ++++++++++-------- src/compiled_license/version.cr | 3 --- 7 files changed, 20 insertions(+), 31 deletions(-) delete mode 100644 .travis.yml delete mode 100644 spec/spec_helper.cr delete mode 100644 src/compiled_license/version.cr diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ffc7b6a..0000000 --- a/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: crystal diff --git a/shard.yml b/shard.yml index 9208c08..58a9060 100644 --- a/shard.yml +++ b/shard.yml @@ -3,7 +3,8 @@ version: 1.0.0 authors: - Isaac Sloan + - grimmigerFuchs -crystal: "> 0.24.1, < 1.1.0" +crystal: 1.20.1 license: MIT diff --git a/spec/compiled_license_spec.cr b/spec/compiled_license_spec.cr index cb3364c..0d7e535 100644 --- a/spec/compiled_license_spec.cr +++ b/spec/compiled_license_spec.cr @@ -1,14 +1,15 @@ -require "./spec_helper" +require "spec" +require "../src/compiled_license" describe CompiledLicense do - licenses = {{ run("../src/compiled_license/licenses.cr").stringify }} + licenses = CompiledLicense::LICENSES 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") + licenses.should contain("compiled_license") end it "should contain name of author from license file" do @@ -17,6 +18,6 @@ describe CompiledLicense do it "should contain more than one license" do delimiter = "\n\n" - (licenses.split(delimiter).size > 1).should be_true + (licenses.split(delimiter).size > 1).should be_true end end diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr deleted file mode 100644 index 999c873..0000000 --- a/spec/spec_helper.cr +++ /dev/null @@ -1,2 +0,0 @@ -require "spec" -require "../src/compiled_license" diff --git a/src/compiled_license.cr b/src/compiled_license.cr index bd3852a..bc26aea 100644 --- a/src/compiled_license.cr +++ b/src/compiled_license.cr @@ -1,14 +1,5 @@ -require "./compiled_license/version" +module CompiledLicense + VERSION = {{ `shards version`.stringify.chomp }} -module Compiled - module License - def self.display - {{ run("./compiled_license/licenses.cr").stringify }} - end - end -end - -if ARGV[0]? && ARGV[0]? == "--licenses" - puts Compiled::License.display - exit 0 + LICENSES = {{ run("./compiled_license/licenses.cr").stringify }} end diff --git a/src/compiled_license/licenses.cr b/src/compiled_license/licenses.cr index d72e2ad..4f5765e 100644 --- a/src/compiled_license/licenses.cr +++ b/src/compiled_license/licenses.cr @@ -1,19 +1,21 @@ -licenses = String.build do |s| +DELIMITER = "================================================================================" + +LICENSES = String.build do |s| if File.exists?("./LICENSE") - s.puts Dir.current.split("/").last.capitalize - s.puts "================================================================================" + s.puts Dir.current.split("/").last + s.puts DELIMITER s.puts File.read("./LICENSE") - s.puts "================================================================================" + s.puts DELIMITER 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 "================================================================================" + s.puts path.match(/^\.\/lib\/([^\/]+)\//).try(&.[1]).to_s + s.puts DELIMITER s.puts File.read(path) - s.puts "================================================================================" + s.puts DELIMITER s.puts "\n\n" end end -puts licenses +puts LICENSES diff --git a/src/compiled_license/version.cr b/src/compiled_license/version.cr deleted file mode 100644 index 2c264a8..0000000 --- a/src/compiled_license/version.cr +++ /dev/null @@ -1,3 +0,0 @@ -module CompiledLicense - VERSION = "1.0.0" -end