Skip to content

Instantly share code, notes, and snippets.

@nwtgck
Last active April 1, 2019 07:30
Show Gist options
  • Save nwtgck/71788998c1159bde38758adc52c92834 to your computer and use it in GitHub Desktop.
Save nwtgck/71788998c1159bde38758adc52c92834 to your computer and use it in GitHub Desktop.
def mit_license(year, person_name)
<<EOS
MIT License
Copyright (c) #{year} #{person_name}
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
EOS
end
def readme(project_name)
<<EOS
# #{project_name}
EOS
end
readme_file_path = "./README.md"
license_file_path = "./LICENSE"
dir_name = File.basename(Dir.getwd)
year = Time.now.year
person_name = `git config user.name`.chomp
puts("Project Name: #{dir_name}")
puts("Year: #{year}")
puts("You: #{person_name}")
if File.exist?(readme_file_path)
puts("#{readme_file_path} already exists")
else
File.write(readme_file_path, readme(dir_name))
puts("#{readme_file_path} generated!")
end
if File.exist?(license_file_path)
puts("#{license_file_path} already exists")
else
File.write(license_file_path, mit_license(year, person_name))
puts("#{license_file_path} generated!")
end
@nwtgck
Copy link
Author

nwtgck commented Jan 27, 2019

Create MIT License and README!

One-Liner

curl https://gist.githubusercontent.com/nwtgck/71788998c1159bde38758adc52c92834/raw/project-init.rb | ruby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment