Automaticly add username and email if configured in git-scm, as bundle gem

This commit is contained in:
Abd ar-Rahman Hamidi 2013-04-06 19:02:13 +05:00 committed by Rafael Mendonça França
parent 6bfcc34b0a
commit 7bf10f5c8f
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
3 changed files with 19 additions and 3 deletions

View File

@ -304,6 +304,22 @@ task default: :test
@camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize
end
def author
if @author.nil?
git_user_name = `git config user.name`.chomp
@author = git_user_name.empty? ? "TODO: Write your name" : git_user_name
end
@author
end
def email
if @email.nil?
git_user_email = `git config user.email`.chomp
@email = git_user_email.empty? ? "TODO: Write your email address" : git_user_email
end
@email
end
def valid_const?
if original_name =~ /[^0-9a-zA-Z_]+/
raise Error, "Invalid plugin name #{original_name}. Please give a name which use only alphabetic or numeric or \"_\" characters."

View File

@ -7,8 +7,8 @@ require "<%= name %>/version"
Gem::Specification.new do |s|
s.name = "<%= name %>"
s.version = <%= camelized %>::VERSION
s.authors = ["TODO: Your name"]
s.email = ["TODO: Your email"]
s.authors = ["<%= author %>"]
s.email = ["<%= email %>"]
s.homepage = "TODO"
s.summary = "TODO: Summary of <%= camelized %>."
s.description = "TODO: Description of <%= camelized %>."

View File

@ -1,4 +1,4 @@
Copyright <%= Date.today.year %> YOURNAME
Copyright <%= Date.today.year %> <%= author %>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the