This commit is contained in:
Dominic Grimm 2021-10-23 12:17:50 +02:00
parent ba052e31f8
commit 22ab96d7d0
7 changed files with 20 additions and 31 deletions

View file

@ -1 +0,0 @@
language: crystal

View file

@ -3,7 +3,8 @@ version: 1.0.0
authors: authors:
- Isaac Sloan <isaac@isaacsloan.com> - Isaac Sloan <isaac@isaacsloan.com>
- grimmigerFuchs <dominic.grimm@gmail.com>
crystal: "> 0.24.1, < 1.1.0" crystal: 1.20.1
license: MIT license: MIT

View file

@ -1,14 +1,15 @@
require "./spec_helper" require "spec"
require "../src/compiled_license"
describe CompiledLicense do describe CompiledLicense do
licenses = {{ run("../src/compiled_license/licenses.cr").stringify }} licenses = CompiledLicense::LICENSES
it "should return string" do it "should return string" do
(licenses.size > 20).should be_true (licenses.size > 20).should be_true
end end
it "should include license of current file" do it "should include license of current file" do
licenses.should contain("Compiled_license") licenses.should contain("compiled_license")
end end
it "should contain name of author from license file" do 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 it "should contain more than one license" do
delimiter = "\n\n" delimiter = "\n\n"
(licenses.split(delimiter).size > 1).should be_true (licenses.split(delimiter).size > 1).should be_true
end end
end end

View file

@ -1,2 +0,0 @@
require "spec"
require "../src/compiled_license"

View file

@ -1,14 +1,5 @@
require "./compiled_license/version" module CompiledLicense
VERSION = {{ `shards version`.stringify.chomp }}
module Compiled LICENSES = {{ run("./compiled_license/licenses.cr").stringify }}
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
end end

View file

@ -1,19 +1,21 @@
licenses = String.build do |s| DELIMITER = "================================================================================"
LICENSES = String.build do |s|
if File.exists?("./LICENSE") if File.exists?("./LICENSE")
s.puts Dir.current.split("/").last.capitalize s.puts Dir.current.split("/").last
s.puts "================================================================================" s.puts DELIMITER
s.puts File.read("./LICENSE") s.puts File.read("./LICENSE")
s.puts "================================================================================" s.puts DELIMITER
s.puts "\n\n" s.puts "\n\n"
end end
Dir.glob("./lib/*/LICENSE", "./lib/*/license").each do |path| Dir.glob("./lib/*/LICENSE", "./lib/*/license").each do |path|
s.puts path.match(/^\.\/lib\/([^\/]+)\//).try(&.[1]).to_s.capitalize s.puts path.match(/^\.\/lib\/([^\/]+)\//).try(&.[1]).to_s
s.puts "================================================================================" s.puts DELIMITER
s.puts File.read(path) s.puts File.read(path)
s.puts "================================================================================" s.puts DELIMITER
s.puts "\n\n" s.puts "\n\n"
end end
end end
puts licenses puts LICENSES

View file

@ -1,3 +0,0 @@
module CompiledLicense
VERSION = "1.0.0"
end