weblog 0.1.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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in weblog.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Pavel Pachkovskij
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Weblog
2
+
3
+ This gem makes Rails environment log tail available through the Web.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'weblog'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install weblog
18
+
19
+ ## Usage
20
+
21
+ In your application.rb file add
22
+
23
+ config.middleware.use Weblog::Middleware, password: 'secret'
24
+
25
+ Restart the server and navigate to *http://yourserver/weblog*
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/lib/weblog.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "weblog/version"
2
+ require "weblog/rack/middleware"
3
+ require "weblog/rack/handler"
4
+
5
+ module Weblog
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,20 @@
1
+ module Weblog
2
+ class Handler
3
+ def initialize(app, options = {})
4
+ @app = app
5
+ @options = options
6
+ end
7
+
8
+ def call(env)
9
+ dup._call(env)
10
+ end
11
+
12
+ def _call(env)
13
+ Rack::Response.new(log_content).finish
14
+ end
15
+
16
+ def log_content
17
+ %x[tail -n 100 "#{File.join(Rails.root, 'log', "#{Rails.env}.log")}"].split("\n\n").reverse.join("<br/><br/>").gsub("\n", '<br/>')
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module Weblog
2
+ class Middleware
3
+ def initialize(app, options = {})
4
+ @app = app
5
+ @options = options
6
+ @handler = Handler.new(app, options)
7
+ end
8
+
9
+ def call(env)
10
+ enabled?(env) ? auth_basic.call(env) : @app.call(env)
11
+ end
12
+
13
+ protected
14
+ def enabled?(env)
15
+ env['PATH_INFO'] == '/weblog'
16
+ end
17
+
18
+ def auth_basic
19
+ @auth_basic ||= Rack::Auth::Basic.new(@handler) { |username, password| password == (@options[:password] || 'secret') }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Weblog
2
+ VERSION = "0.1.0"
3
+ end
data/weblog.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/weblog/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Pavel Pachkovskij"]
6
+ gem.email = ["pavel.pachkovskij@gmail.com"]
7
+ gem.description = %q{Provides web access to Rails environment log.}
8
+ gem.summary = %q{Provides web access to Rails environment log.}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "weblog"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Weblog::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: weblog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Pavel Pachkovskij
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Provides web access to Rails environment log.
15
+ email:
16
+ - pavel.pachkovskij@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/weblog.rb
27
+ - lib/weblog/rack/handler.rb
28
+ - lib/weblog/rack/middleware.rb
29
+ - lib/weblog/version.rb
30
+ - weblog.gemspec
31
+ homepage: ''
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.21
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Provides web access to Rails environment log.
55
+ test_files: []