| |   |
| 4 | 4 | Gitorious.register_command :gem, "Gemify" do |options, summary| |
| 5 | 5 | require_working_dir! |
| 6 | 6 | |
| 7 | if summary.to_s.empty? |
| 8 | error("Summary is required") |
| 9 | raise Gitorious::EvalException |
| 10 | end |
| 11 | |
| 7 | 12 | name = File.basename(Dir.getwd) |
| 8 | | summary ||= "" |
| 9 | 13 | description = "" |
| 10 | 14 | |
| 11 | 15 | files = [] |
| 12 | 16 | executables = [] |
| 17 | options[:deps] ||= [] |
| 13 | 18 | config = get_config(Dir.getwd) |
| 14 | 19 | |
| 15 | 20 | git.ls_files({}) do |stdout, stderr| |
| … | … | |
| 34 | 34 | version = time.strftime("%Y.#{day_of_year}") |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | | description = get_content_from_editor("gem description\n\n") |
| 37 | |
| 38 | description = nil |
| 39 | if options[:description] |
| 40 | if File.exist?(options[:description]) |
| 41 | description = File.open(options[:description]).read |
| 42 | end |
| 43 | end |
| 38 | 44 | |
| 39 | 45 | gem_spec = Gem::Specification.new do |s| |
| 40 | 46 | s.name = name |
| 41 | 47 | s.version = version |
| 42 | 48 | s.summary = summary |
| 43 | | s.description = description.to_s |
| 49 | s.description = description if description |
| 50 | s.has_rdoc = true |
| 44 | 51 | |
| 45 | 52 | s.files = files |
| 46 | 53 | s.executables = executables |
| 54 | s.has_rdoc = true if options[:has_rdoc] |
| 47 | 55 | |
| 48 | 56 | s.author = [ config["user"]["name"] ] |
| 49 | 57 | s.email = [ config["user"]["email"] ] |
| 50 | 58 | s.homepage = options[:homepage] |
| 51 | 59 | s.rubyforge_project = options[:rubyforge] |
| 60 | |
| 61 | options[:deps].each { |dep| |
| 62 | s.add_dependency dep |
| 63 | } |
| 52 | 64 | end |
| 53 | 65 | |
| 54 | | unless options[:only_spec] |
| 55 | | info("Generating `#{name}-#{version}.gem`...") |
| 56 | | Gem::Builder.new(gem_spec).build |
| 57 | | else |
| 66 | if options[:only_spec] |
| 58 | 67 | spec_name = "#{name}.gemspec" |
| 59 | 68 | info("Generating `#{spec_name}`...") |
| 60 | 69 | File.open(spec_name, "w") do |file| |
| 61 | 70 | file << gem_spec.to_ruby |
| 62 | 71 | end |
| 72 | elsif options[:gemify_spec] |
| 73 | info("Generating gemify spec") |
| 74 | File.open(".gemified", "w") do |file| |
| 75 | file << "---" << "\n" |
| 76 | file << ":name: " << gem_spec.name << "\n" |
| 77 | file << ":version: " << gem_spec.version << "\n" |
| 78 | file << ":summary: " << gem_spec.summary << "\n" |
| 79 | file << ":author: " << gem_spec.author << "\n" |
| 80 | file << ":email: " << gem_spec.email << "\n" |
| 81 | file << ":has_rdoc: " << "true" << "\n" if options[:has_rdoc] |
| 82 | file << ":homepage: " << gem_spec.homepage << "\n" |
| 83 | file << ":rubyforge_project: " << gem_spec.rubyforge_project << "\n" |
| 84 | unless options[:deps].empty? |
| 85 | file << ":dependencies: \n" |
| 86 | options[:deps].each { |dep| |
| 87 | file << "- #{dep}\n" |
| 88 | } |
| 89 | end |
| 90 | end |
| 91 | File.open(".manifiest", "w") do |file| |
| 92 | file << gem_spec.files.join("\n") |
| 93 | end |
| 94 | else |
| 95 | info("Generating `#{name}-#{version}.gem`...") |
| 96 | Gem::Builder.new(gem_spec).build |
| 63 | 97 | end |
| 64 | 98 | end |
| 65 | 99 | |
| … | … | |
| 111 | 111 | options[:rubyforge] = value |
| 112 | 112 | end |
| 113 | 113 | |
| 114 | Gitorious.add_option(:gem, "--description=FILE", "Set the description" ) do |options, value| |
| 115 | options[:description] = value |
| 116 | end |
| 117 | |
| 114 | 118 | Gitorious.add_option(:gem, "-s", "--only-spec", "Generate the gemspec" ) do |options, value| |
| 115 | 119 | options[:only_spec] = true |
| 116 | 120 | end |
| 117 | 121 | |
| 122 | Gitorious.add_option(:gem, "--gemify-spec", "Generate gemify spec" ) do |options, value| |
| 123 | options[:gemify_spec] = true |
| 124 | end |
| 125 | |
| 126 | Gitorious.add_option(:gem, "--dependency=DEP", "Add a dependency" ) do |options, value| |
| 127 | options[:deps] ||= [] |
| 128 | options[:deps] << value |
| 129 | end |
| 130 | |
| 131 | Gitorious.add_option(:gem, "--has-rdoc", "" ) do |options, value| |
| 132 | options[:has_rdoc] = true |
| 133 | end |
| 118 | 134 | |
| 119 | 135 | # Gitorious.add_option(:gem, "--from-gitorious", "Use gitorious project info (project name, project home, ...)" ) do |options, value| TODO :) |
| 120 | 136 | # options[:gitorious] = true |
| toggle raw diff |
--- a/lib/gitorious/commands/support/ruby/gem.rb
+++ b/lib/gitorious/commands/support/ruby/gem.rb
@@ -4,12 +4,17 @@ require 'rubygems/builder'
Gitorious.register_command :gem, "Gemify" do |options, summary|
require_working_dir!
+ if summary.to_s.empty?
+ error("Summary is required")
+ raise Gitorious::EvalException
+ end
+
name = File.basename(Dir.getwd)
- summary ||= ""
description = ""
files = []
executables = []
+ options[:deps] ||= []
config = get_config(Dir.getwd)
git.ls_files({}) do |stdout, stderr|
@@ -29,32 +34,66 @@ Gitorious.register_command :gem, "Gemify" do |options, summary|
version = time.strftime("%Y.#{day_of_year}")
end
- description = get_content_from_editor("gem description\n\n")
+
+ description = nil
+ if options[:description]
+ if File.exist?(options[:description])
+ description = File.open(options[:description]).read
+ end
+ end
gem_spec = Gem::Specification.new do |s|
s.name = name
s.version = version
s.summary = summary
- s.description = description.to_s
+ s.description = description if description
+ s.has_rdoc = true
s.files = files
s.executables = executables
+ s.has_rdoc = true if options[:has_rdoc]
s.author = [ config["user"]["name"] ]
s.email = [ config["user"]["email"] ]
s.homepage = options[:homepage]
s.rubyforge_project = options[:rubyforge]
+
+ options[:deps].each { |dep|
+ s.add_dependency dep
+ }
end
- unless options[:only_spec]
- info("Generating `#{name}-#{version}.gem`...")
- Gem::Builder.new(gem_spec).build
- else
+ if options[:only_spec]
spec_name = "#{name}.gemspec"
info("Generating `#{spec_name}`...")
File.open(spec_name, "w") do |file|
file << gem_spec.to_ruby
end
+ elsif options[:gemify_spec]
+ info("Generating gemify spec")
+ File.open(".gemified", "w") do |file|
+ file << "---" << "\n"
+ file << ":name: " << gem_spec.name << "\n"
+ file << ":version: " << gem_spec.version << "\n"
+ file << ":summary: " << gem_spec.summary << "\n"
+ file << ":author: " << gem_spec.author << "\n"
+ file << ":email: " << gem_spec.email << "\n"
+ file << ":has_rdoc: " << "true" << "\n" if options[:has_rdoc]
+ file << ":homepage: " << gem_spec.homepage << "\n"
+ file << ":rubyforge_project: " << gem_spec.rubyforge_project << "\n"
+ unless options[:deps].empty?
+ file << ":dependencies: \n"
+ options[:deps].each { |dep|
+ file << "- #{dep}\n"
+ }
+ end
+ end
+ File.open(".manifiest", "w") do |file|
+ file << gem_spec.files.join("\n")
+ end
+ else
+ info("Generating `#{name}-#{version}.gem`...")
+ Gem::Builder.new(gem_spec).build
end
end
@@ -72,10 +111,26 @@ Gitorious.add_option(:gem, "--rubyforge=VALUE", "Specify the rubyforge project"
options[:rubyforge] = value
end
+Gitorious.add_option(:gem, "--description=FILE", "Set the description" ) do |options, value|
+ options[:description] = value
+end
+
Gitorious.add_option(:gem, "-s", "--only-spec", "Generate the gemspec" ) do |options, value|
options[:only_spec] = true
end
+Gitorious.add_option(:gem, "--gemify-spec", "Generate gemify spec" ) do |options, value|
+ options[:gemify_spec] = true
+end
+
+Gitorious.add_option(:gem, "--dependency=DEP", "Add a dependency" ) do |options, value|
+ options[:deps] ||= []
+ options[:deps] << value
+end
+
+Gitorious.add_option(:gem, "--has-rdoc", "" ) do |options, value|
+ options[:has_rdoc] = true
+end
# Gitorious.add_option(:gem, "--from-gitorious", "Use gitorious project info (project name, project home, ...)" ) do |options, value| TODO :)
# options[:gitorious] = true |