rack-rails-logger 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ pkg
2
+ rdoc
3
+ *.rbc
4
+ .bundle
5
+ .yardoc
6
+ Gemfile.lock
@@ -0,0 +1,3 @@
1
+ [submodule "task"]
2
+ path = task
3
+ url = git://github.com/godfat/gemgem.git
data/README ADDED
@@ -0,0 +1,45 @@
1
+ # rack-logger-rails
2
+ by Lin Jen-Shin (godfat) <http://godfat.org>
3
+
4
+ ## LINKS:
5
+
6
+ * [github](http://github.com/godfat/rack-logger-rails)
7
+ * [rubygems](http://rubygems.org/gems/rack-logger-rails)
8
+
9
+ ## DESCRIPTION:
10
+
11
+ Tell Rails to respect `env['rack.logger']`
12
+
13
+ After installing this middleware, any Rails logs would be redirected to
14
+ `env['rack.logger']`.
15
+
16
+ ## REQUIREMENTS:
17
+
18
+ * Any Ruby
19
+ * Rails 3+
20
+
21
+ ## INSTALLATION:
22
+
23
+ gem install rack-logger-rails
24
+
25
+ ## SYNOPSIS:
26
+
27
+ use Rack::RailsLogger
28
+
29
+ ## LICENSE:
30
+
31
+ Apache License 2.0
32
+
33
+ Copyright (c) 2011, Lin Jen-Shin (godfat)
34
+
35
+ Licensed under the Apache License, Version 2.0 (the "License");
36
+ you may not use this file except in compliance with the License.
37
+ You may obtain a copy of the License at
38
+
39
+ <http://www.apache.org/licenses/LICENSE-2.0>
40
+
41
+ Unless required by applicable law or agreed to in writing, software
42
+ distributed under the License is distributed on an "AS IS" BASIS,
43
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
+ See the License for the specific language governing permissions and
45
+ limitations under the License.
@@ -0,0 +1,45 @@
1
+ # rack-logger-rails
2
+ by Lin Jen-Shin (godfat) <http://godfat.org>
3
+
4
+ ## LINKS:
5
+
6
+ * [github](http://github.com/godfat/rack-logger-rails)
7
+ * [rubygems](http://rubygems.org/gems/rack-logger-rails)
8
+
9
+ ## DESCRIPTION:
10
+
11
+ Tell Rails to respect `env['rack.logger']`
12
+
13
+ After installing this middleware, any Rails logs would be redirected to
14
+ `env['rack.logger']`.
15
+
16
+ ## REQUIREMENTS:
17
+
18
+ * Any Ruby
19
+ * Rails 3+
20
+
21
+ ## INSTALLATION:
22
+
23
+ gem install rack-logger-rails
24
+
25
+ ## SYNOPSIS:
26
+
27
+ use Rack::RailsLogger
28
+
29
+ ## LICENSE:
30
+
31
+ Apache License 2.0
32
+
33
+ Copyright (c) 2011, Lin Jen-Shin (godfat)
34
+
35
+ Licensed under the Apache License, Version 2.0 (the "License");
36
+ you may not use this file except in compliance with the License.
37
+ You may obtain a copy of the License at
38
+
39
+ <http://www.apache.org/licenses/LICENSE-2.0>
40
+
41
+ Unless required by applicable law or agreed to in writing, software
42
+ distributed under the License is distributed on an "AS IS" BASIS,
43
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
+ See the License for the specific language governing permissions and
45
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require "#{dir = File.dirname(__FILE__)}/task/gemgem"
4
+ Gemgem.dir = dir
5
+
6
+ ($LOAD_PATH << File.expand_path("#{Gemgem.dir}/lib" )).uniq!
7
+
8
+ desc 'Generate gemspec'
9
+ task 'gem:spec' do
10
+ Gemgem.spec = Gemgem.create do |s|
11
+ require 'rack-rails-logger/version'
12
+ s.name = 'rack-rails-logger'
13
+ s.version = Rack::RailsLogger::VERSION
14
+ # s.executables = [s.name]
15
+
16
+ %w[].each{ |g| s.add_runtime_dependency(g) }
17
+ %w[].each{ |g| s.add_development_dependency(g) }
18
+ end
19
+
20
+ Gemgem.write
21
+ end
@@ -0,0 +1,19 @@
1
+
2
+ module Rack; end
3
+ class Rack::RailsLogger
4
+ def initialize app
5
+ @app = app
6
+ end
7
+
8
+ def call env
9
+ racklogger(env, @app.config,
10
+ Rails,
11
+ ActionController::Base,
12
+ ActiveRecord::Base)
13
+ @app.call(env)
14
+ end
15
+
16
+ def racklogger env, *mods
17
+ mods.each{ |mod| mod.send(:logger=, env['rack.logger']) }
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+
2
+ module Rack; end
3
+ class Rack::RailsLogger
4
+ VERSION = '1.0.0'
5
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{rack-rails-logger}
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = [%q{Lin Jen-Shin (godfat)}]
9
+ s.date = %q{2011-07-21}
10
+ s.description = %q{Tell Rails to respect `env['rack.logger']`
11
+
12
+ After installing this middleware, any Rails logs would be redirected to
13
+ `env['rack.logger']`.}
14
+ s.email = [%q{godfat (XD) godfat.org}]
15
+ s.files = [
16
+ %q{.gitignore},
17
+ %q{.gitmodules},
18
+ %q{README},
19
+ %q{README.md},
20
+ %q{Rakefile},
21
+ %q{lib/rack-rails-logger.rb},
22
+ %q{lib/rack-rails-logger/version.rb},
23
+ %q{rack-rails-logger.gemspec},
24
+ %q{task/.gitignore},
25
+ %q{task/gemgem.rb}]
26
+ s.homepage = %q{https://github.com/godfat/rack-rails-logger}
27
+ s.rdoc_options = [
28
+ %q{--main},
29
+ %q{README}]
30
+ s.require_paths = [%q{lib}]
31
+ s.rubygems_version = %q{1.8.5}
32
+ s.summary = %q{Tell Rails to respect `env['rack.logger']`}
33
+
34
+ if s.respond_to? :specification_version then
35
+ s.specification_version = 3
36
+
37
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
38
+ else
39
+ end
40
+ else
41
+ end
42
+ end
@@ -0,0 +1 @@
1
+ *.rbc
@@ -0,0 +1,186 @@
1
+
2
+ require 'pathname'
3
+
4
+ module Gemgem
5
+ class << self
6
+ attr_accessor :dir, :spec
7
+ end
8
+
9
+ module_function
10
+ def create
11
+ yield(spec = Gem::Specification.new{ |s|
12
+ s.authors = ['Lin Jen-Shin (godfat)']
13
+ s.email = ['godfat (XD) godfat.org']
14
+
15
+ description = File.read("#{Gemgem.dir}/README").
16
+ match(/DESCRIPTION:\n\n(.+?)(?=\n\n[^\n]+:\n)/m)[1].
17
+ lines.to_a
18
+
19
+ s.description = description.join
20
+ s.summary = description.first
21
+
22
+ s.extra_rdoc_files = %w[CHANGES CONTRIBUTORS LICENSE TODO].select{ |f|
23
+ File.exist?(f) }
24
+ s.rdoc_options = %w[--main README]
25
+ s.rubygems_version = Gem::VERSION
26
+ s.date = Time.now.strftime('%Y-%m-%d')
27
+ s.files = gem_files
28
+ s.test_files = gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
29
+ s.require_paths = %w[lib]
30
+ })
31
+ spec.homepage ||= "https://github.com/godfat/#{spec.name}"
32
+ spec
33
+ end
34
+
35
+ def gem_tag
36
+ "#{spec.name}-#{spec.version}"
37
+ end
38
+
39
+ def write
40
+ File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f|
41
+ f << split_lines(spec.to_ruby) }
42
+ end
43
+
44
+ def split_lines ruby
45
+ ruby.gsub(/(.+?)\[(.+?)\]/){ |s|
46
+ if $2.index(',')
47
+ "#{$1}[\n #{$2.split(',').map(&:strip).join(",\n ")}]"
48
+ else
49
+ s
50
+ end
51
+ }
52
+ end
53
+
54
+ def all_files
55
+ @all_files ||= find_files(Pathname.new(dir)).map{ |file|
56
+ if file.to_s =~ %r{\.git/}
57
+ nil
58
+ else
59
+ file.to_s
60
+ end
61
+ }.compact.sort
62
+ end
63
+
64
+ def gem_files
65
+ @gem_files ||= all_files - ignored_files
66
+ end
67
+
68
+ def ignored_files
69
+ @ignored_file ||= all_files.select{ |path| ignore_patterns.find{ |ignore|
70
+ path =~ ignore && !git_files.include?(path)}}
71
+ end
72
+
73
+ def git_files
74
+ @git_files ||= if File.exist?("#{dir}/.git")
75
+ `git ls-files`.split("\n")
76
+ else
77
+ []
78
+ end
79
+ end
80
+
81
+ # protected
82
+ def find_files path
83
+ path.children.select(&:file?).map{|file| file.to_s[(dir.size+1)..-1]} +
84
+ path.children.select(&:directory?).map{|dir| find_files(dir)}.flatten
85
+ end
86
+
87
+ def ignore_patterns
88
+ @ignore_files ||= expand_patterns(
89
+ File.read("#{dir}/.gitignore").split("\n").reject{ |pattern|
90
+ pattern.strip == ''
91
+ }).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
92
+ end
93
+
94
+ def expand_patterns pathes
95
+ pathes.map{ |path|
96
+ if path !~ /\*/
97
+ path
98
+ else
99
+ expand_patterns(
100
+ Dir[path] +
101
+ Pathname.new(File.dirname(path)).children.select(&:directory?).
102
+ map{ |prefix| "#{prefix}/#{File.basename(path)}" })
103
+ end
104
+ }.flatten
105
+ end
106
+ end
107
+
108
+ namespace :gem do
109
+
110
+ desc 'Install gem'
111
+ task :install => [:build] do
112
+ sh("#{Gem.ruby} -S gem install pkg/#{Gemgem.gem_tag}")
113
+ end
114
+
115
+ desc 'Build gem'
116
+ task :build => [:spec] do
117
+ sh("#{Gem.ruby} -S gem build #{Gemgem.spec.name}.gemspec")
118
+ sh("mkdir -p pkg")
119
+ sh("mv #{Gemgem.gem_tag}.gem pkg/")
120
+ end
121
+
122
+ desc 'Release gem'
123
+ task :release => [:spec, :check, :build] do
124
+ sh("git tag #{Gemgem.gem_tag}")
125
+ sh("git push")
126
+ sh("git push --tags")
127
+ sh("#{Gem.ruby} -S gem push pkg/#{Gemgem.gem_tag}.gem")
128
+ end
129
+
130
+ task :check do
131
+ ver = Gemgem.spec.version.to_s
132
+
133
+ if ENV['VERSION'].nil?
134
+ puts("\x1b[35mExpected " \
135
+ "\x1b[33mVERSION\x1b[35m=\x1b[33m#{ver}\x1b[m")
136
+ exit(1)
137
+
138
+ elsif ENV['VERSION'] != ver
139
+ puts("\x1b[35mExpected \x1b[33mVERSION\x1b[35m=\x1b[33m#{ver} " \
140
+ "\x1b[35mbut got\n " \
141
+ "\x1b[33mVERSION\x1b[35m=\x1b[33m#{ENV['VERSION']}\x1b[m")
142
+ exit(2)
143
+ end
144
+ end
145
+
146
+ end # of gem namespace
147
+
148
+ desc 'Run tests in memory'
149
+ task :test do
150
+ require 'bacon'
151
+ Bacon.extend(Bacon::TestUnitOutput)
152
+ Bacon.summary_on_exit
153
+ $LOAD_PATH.unshift('lib')
154
+ Dir['test/test_*.rb'].each{ |file| load file }
155
+ end
156
+
157
+ desc 'Run tests with shell'
158
+ task 'test:shell', :RUBY_OPTS do |t, args|
159
+ files = unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
160
+ 'test/test_*.rb'
161
+ else
162
+ Dir['test/test_*.rb'].join(' ')
163
+ end
164
+
165
+ cmd = [Gem.ruby, args[:RUBY_OPTS],
166
+ '-I', 'lib', '-S', 'bacon', '--quiet', files]
167
+
168
+ sh(cmd.compact.join(' '))
169
+ end
170
+
171
+ desc 'Generate rdoc'
172
+ task :doc => ['gem:spec'] do
173
+ sh("yardoc -o rdoc --main README.md" \
174
+ " --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
175
+ end
176
+
177
+ desc 'Removed ignored files'
178
+ task :clean => ['gem:spec'] do
179
+ trash = "~/.Trash/#{Gemgem.spec.name}/"
180
+ sh "mkdir -p #{trash}" unless File.exist?(File.expand_path(trash))
181
+ Gemgem.ignored_files.each{ |file| sh "mv #{file} #{trash}" }
182
+ end
183
+
184
+ task :default do
185
+ puts `#{Gem.ruby} -S #{$PROGRAM_NAME} -T`
186
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-rails-logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Lin Jen-Shin (godfat)
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-07-21 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: ! 'Tell Rails to respect `env[''rack.logger'']`
15
+
16
+
17
+ After installing this middleware, any Rails logs would be redirected to
18
+
19
+ `env[''rack.logger'']`.'
20
+ email:
21
+ - godfat (XD) godfat.org
22
+ executables: []
23
+ extensions: []
24
+ extra_rdoc_files: []
25
+ files:
26
+ - .gitignore
27
+ - .gitmodules
28
+ - README
29
+ - README.md
30
+ - Rakefile
31
+ - lib/rack-rails-logger.rb
32
+ - lib/rack-rails-logger/version.rb
33
+ - rack-rails-logger.gemspec
34
+ - task/.gitignore
35
+ - task/gemgem.rb
36
+ homepage: https://github.com/godfat/rack-rails-logger
37
+ licenses: []
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --main
41
+ - README
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 1.8.5
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Tell Rails to respect `env['rack.logger']`
62
+ test_files: []