about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-07 15:49:55 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-07 16:00:07 -0700
commitcee939b527e82237f89eb8eece62610854ac888a (patch)
tree019f3874373ea19c4292df73d90c8df85cee634c
parent00814d46e9e82fa24d38bd77172143df3757f020 (diff)
downloadclogger-cee939b527e82237f89eb8eece62610854ac888a.tar.gz
Several bikeshed reasons brought me to this point:

* I like the README.html layout more than any default index.html
  even if it's using README content.  Having links on the side
  helps navigation IMHO.

* publish_docs preserves timestamps to improve cache hit rate

* git is used to maintain the manifest at packaging/release-time
  so my changesets have less noise in them

* git is used to generate history files (from tag messages),
  this is a more DRY approach to me.

* I don't like the ".txt" suffix being translated to "_txt.html" in
  URLs.  I don't like the ".txt" suffix in general.

* I don't like Manifest.txt showing up in my RDoc
-rw-r--r--.document4
-rw-r--r--.gitignore2
-rw-r--r--GNUmakefile58
-rw-r--r--History.txt45
-rw-r--r--Manifest.txt15
-rw-r--r--README (renamed from README.txt)0
-rw-r--r--Rakefile48
-rw-r--r--clogger.gemspec30
8 files changed, 105 insertions, 97 deletions
diff --git a/.document b/.document
new file mode 100644
index 0000000..b9cb90b
--- /dev/null
+++ b/.document
@@ -0,0 +1,4 @@
+README
+History
+lib
+ext/clogger_ext/clogger.c
diff --git a/.gitignore b/.gitignore
index 6d1222b..31a1a8b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,5 @@ Makefile
 /doc
 /local.mk
 /pkg
+/.manifest
+/History
diff --git a/GNUmakefile b/GNUmakefile
index b57c947..b690ca9 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,5 +1,6 @@
 all:: test
 ruby = ruby
+rake = rake
 
 -include local.mk
 
@@ -7,10 +8,6 @@ ifeq ($(DLEXT),) # "so" for Linux
   DLEXT := $(shell $(ruby) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
 endif
 
-ifeq ($(RUBY_VERSION),)
-  RUBY_VERSION := $(shell $(ruby) -e 'puts RUBY_VERSION')
-endif
-
 ext/clogger_ext/Makefile: ext/clogger_ext/clogger.c ext/clogger_ext/extconf.rb
         cd ext/clogger_ext && $(ruby) extconf.rb
 
@@ -29,10 +26,13 @@ test-pure:
 
 test: test-ext test-pure
 
-Manifest.txt:
-        git ls-files > $@+
-        cmp $@+ $@ || mv $@+ $@
-        $(RM) $@+
+History:
+        $(rake) -s history > $@+
+        mv $@+ $@
+
+.manifest: History
+        (git ls-files; for i in $^ $@; do echo $$i; done) | LC_ALL=C sort > $@+
+        mv $@+ $@
 
 VERSION := $(shell git describe 2>/dev/null | sed 's/^v//')
 
@@ -41,6 +41,8 @@ v := /^v$(VERSION)$$/
 vPREV := $(shell git tag -l 2>/dev/null | sed -n -e '$(v)!h' -e '$(v){x;p;q}')
 release_notes := release_notes-$(VERSION).txt
 release_changes := release_changes-$(VERSION).txt
+release-notes: $(release_notes)
+release-changes: $(release_changes)
 $(release_changes): verify
         git diff --stat $(vPREV) v$(VERSION) > $@+
         echo >> $@+
@@ -55,24 +57,48 @@ verify:
         @test -n "$(VERSION)" || { echo >&2 VERSION= not defined; exit 1; }
         git rev-parse --verify refs/tags/v$(VERSION)^{}
         @test -n "$(VISUAL)" || { echo >&2 VISUAL= not defined; exit 1; }
-
-package: verify
         git diff-index --quiet HEAD^0
         test `git rev-parse --verify HEAD^0` = \
              `git rev-parse --verify refs/tags/v$(VERSION)^{}`
-        $(RM) -r pkg
-        unset CLOGGER_EXT; rake package VERSION=$(VERSION)
-        CLOGGER_EXT=1 rake package VERSION=$(VERSION)
+
+pkg/clogger-$(VERSION).gem: .manifest History clogger.gemspec
+        gem build clogger.gemspec
+        mkdir -p pkg
+        mv $(@F) $@
+
+pkg/clogger-$(VERSION).tgz: HEAD = v$(VERSION)
+pkg/clogger-$(VERSION).tgz: .manifest History
+        $(RM) -r $(basename $@)
+        git archive --format=tar --prefix=$(basename $@)/ $(HEAD) | tar xv
+        install -m644 $^ $(basename $@)
+        cd pkg && tar cv $(basename $(@F)) | gzip -9 > $(@F)+
+        mv $@+ $@
+
+package: pkg/clogger-$(VERSION).gem pkg/clogger-$(VERSION).tgz
 
 # not using Hoe's release system since we release 2 gems but only one tgz
-release: package Manifest.txt $(release_notes) $(release_changes)
+release: package $(release_notes) $(release_changes)
         rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
           clogger clogger $(VERSION) pkg/clogger-$(VERSION).gem
         rubyforge add_file \
           clogger clogger $(VERSION) pkg/clogger-$(VERSION).tgz
         rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
           clogger clogger_ext $(VERSION) pkg/clogger_ext-$(VERSION).gem
-        rake post_news
 endif
 
-.PHONY: test doc Manifest.txt release
+doc: .document History
+        rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
+        install -m644 COPYING doc/COPYING
+        cd doc && ln README.html tmp.html && mv tmp.html index.html
+
+# publishes docs to http://clogger.rubyforge.org/
+# this preserves timestamps as best as possible to help HTTP caches out
+# git set-file-times can is here: http://git-scm.org/gitwiki/ExampleScripts
+publish_doc:
+        git set-file-times
+        $(RM) -r doc
+        $(MAKE) doc
+        rsync -av --delete doc/ rubyforge.org:/var/www/gforge-projects/clogger/
+        git ls-files | xargs touch
+
+.PHONY: test doc .manifest release History
diff --git a/History.txt b/History.txt
deleted file mode 100644
index a989a0a..0000000
--- a/History.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-=== 0.0.5 / 2009-09-02
-
-   The following variables are now exposed: $request_method,
-   $content_length and $content_type.  Additionally, attempts
-   to use $http_content_length or $http_content_type will be
-   remapped to use the non-"$http_"-prefixed variable instead
-   since the "$http_"-variants of those variables is not allowed
-   by Rack.
-
-=== 0.0.4 / 2009-09-02
-
-    The pure Ruby version now escapes with uppercase A-F
-    characters to match nginx log output.  There are now extra
-    checks against badly behaving Rack applications and 500
-    errors will be logged before TypeError is raised if the
-    application response does not conform (minimally) to Rack
-    expectations.  Finally, handling of $request (requests
-    without "HTTP_VERSION" set in the Rack env) should now be
-    logged correctly without unnecessary trailing characters.
-
-    Hackers: the primary git repository has been moved to
-    git://git.bogomips.org/clogger.git for now since I'm having
-    issues with pushing to Rubyforge (seems related to Support
-    Requests item #26185).
-
-=== 0.0.3 / 2009-08-29
-
-    The MRI extension clogger_ext gets GC bug fix and
-    cleanups/robustness improvements.  It should now be more
-    tolerant of misbehaving applications in that it'll be less
-    likely to segfault.  No changes to the (recommended) pure
-    implementation.
-
-=== 0.0.2 / 2009-08-29
-
-* 2 bug fixes
-
-   * support "$request_uri" as a log variable
-   * Log bad/invalid app responses as 500 errors
-
-=== 0.0.1 / 2009-08-28
-
-* 1 major enhancement
-
-  * initial release
diff --git a/Manifest.txt b/Manifest.txt
deleted file mode 100644
index c627799..0000000
--- a/Manifest.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-.gitignore
-COPYING
-GNUmakefile
-History.txt
-Manifest.txt
-README.txt
-Rakefile
-ext/clogger_ext/clogger.c
-ext/clogger_ext/extconf.rb
-ext/clogger_ext/ruby_1_9_compat.h
-lib/clogger.rb
-lib/clogger/format.rb
-lib/clogger/pure.rb
-setup.rb
-test/test_clogger.rb
diff --git a/README.txt b/README
index 707b851..707b851 100644
--- a/README.txt
+++ b/README
diff --git a/Rakefile b/Rakefile
index 0cc50a7..cdcded1 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,6 +1,3 @@
-require 'hoe'
-$LOAD_PATH << 'lib'
-require 'clogger'
 begin
   require 'rake/extensiontask'
   Rake::ExtensionTask.new('clogger_ext')
@@ -8,24 +5,33 @@ rescue LoadError
   warn "rake-compiler not available, cross compiling disabled"
 end
 
-common = lambda do |hoe|
-  title = hoe.paragraphs_of("README.txt", 0).first.sub(/^= /, '')
-  hoe.version = Clogger::VERSION
-  hoe.summary = title.split(/\s*-\s*/, 2).last
-  hoe.description = hoe.paragraphs_of("README.txt", 3)
-  hoe.rubyforge_name = 'clogger'
-  hoe.author = 'Eric Wong'
-  hoe.email = 'clogger@librelist.com'
-  hoe.spec_extras.merge!('rdoc_options' => [ "--title", title ])
-  hoe.remote_rdoc_dir = ''
-  hoe.extra_deps << [ 'rack', '> 0.9' ]
+desc 'prints RDoc-formatted history'
+task :history do
+  tags = `git tag -l`.split(/\n/).grep(/^v/).reverse
+  timefmt = '%Y-%m-%d %H:%M UTC'
+  tags.each do |tag|
+    header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/)
+    tagger = header.split(/\n/).grep(/^tagger /).first.split(/\s/)
+    time = Time.at(tagger[-2].to_i).utc
+    puts "=== #{tag.sub(/^v/, '')} / #{time.strftime(timefmt)}"
+    puts ""
+    puts body
+    puts ""
+  end
 end
 
-if ENV['CLOGGER_EXT']
-  Hoe.spec('clogger_ext') do
-    common.call(self)
-    self.spec_extras.merge!(:extensions => Dir.glob('ext/*/extconf.rb'))
-  end
-else
-  Hoe.spec('clogger') { common.call(self) }
+desc "read news article from STDIN and post to rubyforge"
+task :publish_news do
+  require 'rubyforge'
+  IO.select([STDIN], nil, nil, 1) or abort "E: news must be read from stdin"
+  msg = STDIN.readlines
+  subject = msg.shift
+  blank = msg.shift
+  blank == "\n" or abort "no newline after subject!"
+  subject.strip!
+  body = msg.join("").strip!
+
+  rf = RubyForge.new.configure
+  rf.login
+  rf.post_news('clogger', subject, body)
 end
diff --git a/clogger.gemspec b/clogger.gemspec
new file mode 100644
index 0000000..0876b0a
--- /dev/null
+++ b/clogger.gemspec
@@ -0,0 +1,30 @@
+ENV["VERSION"] or abort "VERSION= must be specified"
+
+Gem::Specification.new do |s|
+  s.name = %q{clogger}
+  s.version = ENV["VERSION"]
+
+  if s.respond_to? :required_rubygems_version=
+    s.required_rubygems_version = Gem::Requirement.new(">= 0")
+  end
+  s.homepage = 'http://clogger.rubyforge.org/'
+  s.authors = ["Eric Wong"]
+  s.date = Time.now.utc.strftime('%Y-%m-%d')
+  s.description = %q{
+Clogger is Rack middleware for logging HTTP requests.  The log format
+is customizable so you can specify exactly which fields to log.
+}.strip
+  s.email = %q{clogger@librelist.com}
+  s.extra_rdoc_files = %w(README History)
+  s.files = File.readlines('.manifest').map! { |x| x.chomp! }
+  s.rdoc_options = [ "-Na",
+                     "-t", "Clogger - configurable request logging for Rack"
+                   ]
+  s.require_paths = %w(lib ext)
+  s.rubyforge_project = %q{clogger}
+  s.summary = %q{configurable request logging for Rack}
+  s.test_files = %w(test/test_clogger.rb)
+
+  # HeaderHash wasn't case-insensitive in old versions
+  s.add_dependency(%q<rack>, ["> 0.9"])
+end