aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorAbd ar-Rahman Hamidi <bakhtiyor.h@gmail.com>2013-04-06 19:02:13 +0500
committerArun Agrawal <arunagw@gmail.com>2014-05-02 15:38:07 +0200
commit65b551466bb6eaff933454279fdedfe1e2160b19 (patch)
tree96569215a1479f1122af49594103f03483b3ae33 /railties/lib/rails
parentd4a2f7e8cc7a3af81a5ddf81ce35eec82665dc7c (diff)
downloadrails-65b551466bb6eaff933454279fdedfe1e2160b19.tar.gz
rails-65b551466bb6eaff933454279fdedfe1e2160b19.tar.bz2
rails-65b551466bb6eaff933454279fdedfe1e2160b19.zip
Automaticly add username and email if configured in git-scm, as bundle gem
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/generators/rails/plugin/plugin_generator.rb16
-rw-r--r--railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec4
-rw-r--r--railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE2
3 files changed, 19 insertions, 3 deletions
diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
index f6f529b80a..1b63d5faa0 100644
--- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
+++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
@@ -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."
diff --git a/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec b/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec
index 5fdf0e1554..919c349470 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec
+++ b/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec
@@ -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 %>."
diff --git a/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE b/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE
index d7a9109894..ff2fb3ba4e 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE
+++ b/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE
@@ -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