clogger 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v0.1.0.GIT
4
+ DEF_VER=v0.2.0.GIT
5
5
 
6
6
  LF='
7
7
  '
@@ -1,6 +1,6 @@
1
1
  all:: test
2
- ruby = ruby
3
- rake = rake
2
+ RUBY = ruby
3
+ RAKE = rake
4
4
  GIT_URL = git://git.bogomips.org/clogger.git
5
5
 
6
6
  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@@ -9,11 +9,11 @@ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
9
9
  -include local.mk
10
10
 
11
11
  ifeq ($(DLEXT),) # "so" for Linux
12
- DLEXT := $(shell $(ruby) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
12
+ DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
13
13
  endif
14
14
 
15
15
  ext/clogger_ext/Makefile: ext/clogger_ext/clogger.c ext/clogger_ext/extconf.rb
16
- cd ext/clogger_ext && $(ruby) extconf.rb
16
+ cd ext/clogger_ext && $(RUBY) extconf.rb
17
17
 
18
18
  ext/clogger_ext/clogger.$(DLEXT): ext/clogger_ext/Makefile
19
19
  $(MAKE) -C ext/clogger_ext
@@ -23,10 +23,10 @@ clean:
23
23
  $(RM) ext/clogger_ext/Makefile lib/clogger_ext.$(DLEXT)
24
24
 
25
25
  test-ext: ext/clogger_ext/clogger.$(DLEXT)
26
- $(ruby) -Iext/clogger_ext:lib test/test_clogger.rb
26
+ $(RUBY) -Iext/clogger_ext:lib test/test_clogger.rb
27
27
 
28
28
  test-pure:
29
- CLOGGER_PURE=t $(ruby) -Ilib test/test_clogger.rb
29
+ CLOGGER_PURE=t $(RUBY) -Ilib test/test_clogger.rb
30
30
 
31
31
  test: test-ext test-pure
32
32
 
@@ -42,8 +42,8 @@ manifest: $(pkg_extra)
42
42
  cmp $@+ $@ || mv $@+ $@
43
43
  $(RM) $@+
44
44
 
45
- NEWS: GIT-VERSION-FILE
46
- $(rake) -s news_rdoc > $@+
45
+ NEWS: GIT-VERSION-FILE .manifest
46
+ $(RAKE) -s news_rdoc > $@+
47
47
  mv $@+ $@
48
48
 
49
49
  SINCE = 0.0.7
@@ -63,13 +63,13 @@ doc: .document NEWS ChangeLog
63
63
  rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
64
64
  install -m644 COPYING doc/COPYING
65
65
  install -m644 $(shell grep '^[A-Z]' .document) doc/
66
- $(ruby) -i -p -e \
66
+ $(RUBY) -i -p -e \
67
67
  '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
68
68
  doc/ChangeLog.html
69
- $(ruby) -i -p -e \
69
+ $(RUBY) -i -p -e \
70
70
  '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
71
71
  doc/NEWS.html doc/README.html
72
- $(rake) -s news_atom > doc/NEWS.atom.xml
72
+ $(RAKE) -s news_atom > doc/NEWS.atom.xml
73
73
  cd doc && ln README.html tmp && mv tmp index.html
74
74
 
75
75
  # publishes docs to http://clogger.rubyforge.org/
@@ -79,7 +79,7 @@ publish_doc:
79
79
  git set-file-times
80
80
  $(RM) -r doc
81
81
  $(MAKE) doc
82
- rsync -av --delete doc/ rubyforge.org:/var/www/gforge-projects/clogger/
82
+ rsync -av doc/ rubyforge.org:/var/www/gforge-projects/clogger/
83
83
  git ls-files | xargs touch
84
84
 
85
85
  ifneq ($(VERSION),)
@@ -93,10 +93,10 @@ release_changes := release_changes-$(VERSION)
93
93
  release-notes: $(release_notes)
94
94
  release-changes: $(release_changes)
95
95
  $(release_changes):
96
- $(rake) -s release_changes > $@+
96
+ $(RAKE) -s release_changes > $@+
97
97
  $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
98
98
  $(release_notes):
99
- GIT_URL=$(GIT_URL) $(rake) -s release_notes > $@+
99
+ GIT_URL=$(GIT_URL) $(RUBY) -s release_notes > $@+
100
100
  $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
101
101
 
102
102
  # ensures we're actually on the tagged $(VERSION), only used for release
@@ -135,9 +135,10 @@ package: $(pkgtgz) $(pkggem)
135
135
 
136
136
  release: verify package $(release_notes) $(release_changes)
137
137
  rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
138
- $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
139
- rubyforge add_file \
140
138
  $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
139
+ gem push $(pkggem)
140
+ rubyforge add_file \
141
+ $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
141
142
  else
142
143
  gem install-gem: GIT-VERSION-FILE
143
144
  $(MAKE) $@ VERSION=$(GIT_VERSION)
data/README CHANGED
@@ -31,7 +31,7 @@ Clogger may be loaded as Rack middleware in your config.ru:
31
31
  require "clogger"
32
32
  use Clogger,
33
33
  :format => Clogger::Format::Combined,
34
- :logger => File.open("/path/to/log", "ab")
34
+ :logger => ::File.open("/path/to/log", "ab")
35
35
  run YourApplication.new
36
36
 
37
37
  If you're using Rails 2.3.x or later, in your config/environment.rb
@@ -39,7 +39,7 @@ somewhere inside the "Rails::Initializer.run do |config|" block:
39
39
 
40
40
  config.middleware.use 'Clogger',
41
41
  :format => Clogger::Format::Combined,
42
- :logger => File.open("/path/to/log", "ab")
42
+ :logger => ::File.open("/path/to/log", "ab")
43
43
 
44
44
  == VARIABLES
45
45
 
data/Rakefile CHANGED
@@ -117,3 +117,41 @@ task :release_notes do
117
117
  print "\nChanges:\n\n"
118
118
  puts body
119
119
  end
120
+
121
+ desc "post to RAA"
122
+ task :raa_update do
123
+ require 'rubygems'
124
+ require 'net/http'
125
+ require 'net/netrc'
126
+ rc = Net::Netrc.locate('clogger-raa') or abort "~/.netrc not found"
127
+ password = rc.password
128
+
129
+ s = Gem::Specification.load('clogger.gemspec')
130
+ desc = [ s.description.strip ]
131
+ desc << ""
132
+ desc << "* #{s.email}"
133
+ desc << "* #{git_url}"
134
+ desc << "* #{cgit_url}"
135
+ desc = desc.join("\n")
136
+ uri = URI.parse('http://raa.ruby-lang.org/regist.rhtml')
137
+ form = {
138
+ :name => s.name,
139
+ :short_description => s.summary,
140
+ :version => s.version.to_s,
141
+ :status => 'experimental',
142
+ :owner => s.authors.first,
143
+ :email => s.email,
144
+ :category_major => 'Library',
145
+ :category_minor => 'Rack',
146
+ :url => s.homepage,
147
+ :download => 'http://rubyforge.org/frs/?group_id=8896',
148
+ :license => 'LGPLv3',
149
+ :description_style => 'Plain',
150
+ :description => desc,
151
+ :pass => password,
152
+ :submit => 'Update',
153
+ }
154
+ res = Net::HTTP.post_form(uri, form)
155
+ p res
156
+ puts res.body
157
+ end
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0")
10
10
  end
11
11
  s.homepage = 'http://clogger.rubyforge.org/'
12
- s.authors = ["Eric Wong"]
12
+ s.authors = ["cloggers"]
13
13
  s.date = Time.now.utc.strftime('%Y-%m-%d')
14
14
  s.description = %q{
15
15
  Clogger is Rack middleware for logging HTTP requests. The log format
@@ -689,10 +689,9 @@ static VALUE ccall(struct clogger *c, VALUE env)
689
689
  c->headers = tmp[1];
690
690
  c->body = tmp[2];
691
691
 
692
+ rv = rb_ary_new4(3, tmp);
692
693
  if (c->need_resp && cHeaderHash != rb_obj_class(c->headers)) {
693
694
  c->headers = rb_funcall(cHeaderHash, new_id, 1, tmp[1]);
694
- if (OBJ_FROZEN(rv))
695
- rv = rb_ary_dup(rv);
696
695
  rb_ary_store(rv, 1, c->headers);
697
696
  }
698
697
  } else {
@@ -732,8 +731,7 @@ static VALUE clogger_call(VALUE self, VALUE env)
732
731
  }
733
732
 
734
733
  rv = ccall(c, env);
735
- if (OBJ_FROZEN(rv))
736
- rv = rb_ary_dup(rv);
734
+ assert(!OBJ_FROZEN(rv) && "frozen response array");
737
735
  rb_ary_store(rv, 2, self);
738
736
 
739
737
  return rv;
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: binary -*-
2
2
  class Clogger
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
 
5
5
  OP_LITERAL = 0
6
6
  OP_REQUEST = 1
@@ -27,10 +27,10 @@ class Clogger
27
27
  end
28
28
  status, headers, body = resp
29
29
  headers = Rack::Utils::HeaderHash.new(headers) if @need_resp
30
- if wrap_body?
30
+ if @wrap_body
31
31
  @reentrant = env['rack.multithread']
32
32
  @env, @status, @headers, @body = env, status, headers, body
33
- return [ status, headers, reentrant? ? self.dup : self ]
33
+ return [ status, headers, @reentrant ? self.dup : self ]
34
34
  end
35
35
  log(env, status, headers)
36
36
  [ status, headers, body ]
@@ -39,7 +39,7 @@ class Clogger
39
39
  def each
40
40
  @body_bytes_sent = 0
41
41
  @body.each do |part|
42
- @body_bytes_sent += part.size
42
+ @body_bytes_sent += Rack::Utils.bytesize(part)
43
43
  yield part
44
44
  end
45
45
  ensure
@@ -517,6 +517,22 @@ class TestClogger < Test::Unit::TestCase
517
517
  assert_nil body.close
518
518
  end
519
519
 
520
+ def test_clogger_response_frozen
521
+ response = [ 200, { "AAAA" => "AAAA"}.freeze, [].freeze ].freeze
522
+ s = StringIO.new("")
523
+ app = Rack::Builder.new do
524
+ use Clogger, :logger => s, :format => "$request_time $http_host"
525
+ run lambda { |env| response }
526
+ end
527
+ assert_nothing_raised do
528
+ 3.times do
529
+ resp = app.call(@req)
530
+ assert ! resp.frozen?
531
+ resp.last.each { |x| }
532
+ end
533
+ end
534
+ end
535
+
520
536
  def test_clogger_body_close_return_value
521
537
  s = ''
522
538
  body = []
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Eric Wong
7
+ - cloggers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-06 00:00:00 -07:00
12
+ date: 2010-01-07 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency