This commit is contained in:
Isaac Sloan 2018-02-20 00:07:01 -07:00
parent 5612dfa4df
commit 09fdd517bd
4 changed files with 30 additions and 5 deletions

View file

@ -7,3 +7,7 @@ authors:
crystal: 0.24.1 crystal: 0.24.1
license: MIT license: MIT
dependencies:
cry:
github: elorest/cry

View file

@ -1,9 +1,22 @@
require "./spec_helper" require "./spec_helper"
describe CompiledLicense do describe CompiledLicense do
# TODO: Write tests licenses = {{ run("../src/compiled_license/licenses.cr").stringify }}
it "works" do it "should return string" do
false.should eq(true) (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
end end

View file

@ -3,12 +3,12 @@ require "./compiled_license/version"
module Compiled module Compiled
module License module License
def self.display def self.display
{{ run("../compiled_license/licenses.cr").stringify }} {{ run("./compiled_license/licenses.cr").stringify }}
end end
end end
end end
if ARGV[0]? && ARGV[0]? == "--license" if ARGV[0]? && ARGV[0]? == "--license"
puts Amber::Support::Licenses.display puts Compiled::License.display
exit 0 exit 0
end end

View file

@ -1,4 +1,12 @@
licenses = String.build do |s| 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| 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.capitalize
s.puts "================================================================================" s.puts "================================================================================"