Permalink
Browse files

add script/gemspec

  • Loading branch information...
1 parent 5f1d2bf commit d704d6f287cc067899164ef657105eb2caef17b2 @technoweenie committed Dec 28, 2012
Showing with 29 additions and 0 deletions.
  1. +29 −0 script/gemspec
View
29 script/gemspec
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require File.expand_path("../ruby", __FILE__)
+
+def replace_header(head, header_name)
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{MakeScript.send(header_name)}'"}
+end
+
+# read spec file and split out manifest section
+spec = File.read(MakeScript.gemspec_file)
+head, manifest, tail = spec.split(" # = MANIFEST =\n")
+
+# replace name version and date
+replace_header(head, :lib_name)
+replace_header(head, :version)
+
+files = `git ls-files`.
+ split("\n").
+ sort.
+ reject { |file| file =~ /^\./ }.
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
+ map { |file| " #{file}" }.
+ join("\n")
+
+# piece file back together and write
+manifest = " s.files = %w[\n#{files}\n ]\n"
+spec = [head, manifest, tail].join(" # = MANIFEST =\n")
+File.open(MakeScript.gemspec_file, 'w') { |io| io.write(spec) }
+puts "Updated #{MakeScript.gemspec_file}"
+

0 comments on commit d704d6f

Please sign in to comment.