lib/sign/generator.rb in sign-1.0.0 vs lib/sign/generator.rb in sign-1.0.1
- old
+ new
@@ -1,32 +1,34 @@
require "Date"
module Sign
class Generator
- def make(license, name, year)
+ def create(license, name, year)
raise ArgumentError, "#{license} is not available." unless File.readable?(license)
license_template = File.read(license)
name = get_name if name.nil?
year = get_year if year.nil?
if placeholders_exist?(license_template)
- modified_license = license_template.gsub("[AUTHOR]", name)
- modified_license = modified_license.gsub("[YEAR]", year)
+ new_license = license_template.gsub("[AUTHOR]", name)
+ new_license = new_license.gsub("[YEAR]", year)
+ else
+ new_license = license_template
end
- create_new_file(modified_license)
+ create_new_file(new_license)
end
def placeholders_exist?(license_template)
placeholders = ["[YEAR]", "[AUTHOR]"]
placeholders.any? { |placeholder| license_template.include?(placeholder) }
end
- def create_new_file(modified_license)
+ def create_new_file(new_license)
new_file = File.new("LICENSE", "w")
- new_file.puts(modified_license)
+ new_file.puts(new_license)
new_file.close
puts "License created \033[91m<3\033[0m"
end
def get_name
\ No newline at end of file