sinatra-verbose 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fcbb1eb989b4f9016854ba3a06336942c5eb4721
4
+ data.tar.gz: 8c77b08c5ed7a6b22f62e6c64a4622611bd67b8d
5
+ SHA512:
6
+ metadata.gz: f9d5a89c503a2bd4a8ae190834452ecdf05c5e7c2a217fc9aebf7a17e9314435471c881ae58a3245dd016f0d1ba07049ff04c255581e3984abfb74af6eb32ec1
7
+ data.tar.gz: d85dcc0b2dcd4042a2c03992dfc108bc9e07d7938dd9f98cf35867c8120710169d82a6ac2da1f6f5f7f07b368fedc87095c608b8fa7088942db30d2275884998
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Patricio Mac Adden
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,67 @@
1
+ # Sinatra::Verbose
2
+
3
+ Sinatra verbose logging extension
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sinatra-verbose'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ $ gem install sinatra-verbose
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### Classic Application
28
+
29
+ To enable the verbose logger in a classic application all you need to do is
30
+ require it:
31
+
32
+ ```ruby
33
+ require 'sinatra'
34
+ require 'sinatra/verbose' if development?
35
+
36
+ # Your classic application code goes here...
37
+ ```
38
+
39
+ ### Modular Application
40
+
41
+ To enable the verbose logger in a modular application all you need to do is
42
+ require it, and then, register it:
43
+
44
+ ```ruby
45
+ require 'sinatra/base'
46
+ require 'sinatra/verbose'
47
+
48
+ class MyApp < Sinatra::Base
49
+ configure :development do
50
+ register Sinatra::Verbose
51
+ end
52
+
53
+ # Your modular application code goes here...
54
+ end
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create new Pull Request
64
+
65
+ ## License
66
+
67
+ See the [LICENSE](https://github.com/patriciomacadden/sinatra-verbose/blob/master/LICENSE).
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'spec'
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ end
8
+
9
+ task default: :test
@@ -0,0 +1,81 @@
1
+ require 'sinatra/verbose/version'
2
+
3
+ module Sinatra
4
+ # = Sinatra::Verbose
5
+ #
6
+ # Extension to log verbosely. Useful during development, since
7
+ # it will automatically log all the blocks that are invoked.
8
+ #
9
+ # == Usage
10
+ #
11
+ # === Classic Application
12
+ #
13
+ # To enable the verbose logger in a classic application all you need to do is
14
+ # require it:
15
+ #
16
+ # require "sinatra"
17
+ # require "sinatra/verbose" if development?
18
+ #
19
+ # # Your classic application code goes here...
20
+ #
21
+ # === Modular Application
22
+ #
23
+ # To enable the verbose logger in a modular application all you need to do is
24
+ # require it, and then, register it:
25
+ #
26
+ # require "sinatra/base"
27
+ # require "sinatra/verbose"
28
+ #
29
+ # class MyApp < Sinatra::Base
30
+ # configure :development do
31
+ # register Sinatra::Verbose
32
+ # end
33
+ #
34
+ # # Your modular application code goes here...
35
+ # end
36
+ #
37
+ module Verbose
38
+ def before(path = nil, options = {}, &block)
39
+ blk, block = block, Proc.new do
40
+ logger.info "passing through a before block at #{blk.source_location.join(':')}"
41
+ blk.call
42
+ end
43
+ super path, options, &block
44
+ end
45
+
46
+ def after(path = nil, options = {}, &block)
47
+ blk, block = block, Proc.new do
48
+ logger.info "passing through an after block at #{blk.source_location.join(':')}"
49
+ blk.call
50
+ end
51
+ super path, options, &block
52
+ end
53
+
54
+ def error(*codes, &block)
55
+ blk, block = block, Proc.new do
56
+ logger.info "passing through an error block at #{blk.source_location.join(':')}"
57
+ blk.call
58
+ end
59
+ super codes, &block
60
+ end
61
+ end
62
+
63
+ module VerboseTemplates
64
+ %w(erb haml builder liquid markaby nokogiri slim wlang).each do |lang|
65
+ define_method lang do |template, options = {}, locals = {}, &block|
66
+ logger.info "rendering #{template}.#{lang}"
67
+ super template, options, locals, &block
68
+ end
69
+ end
70
+
71
+ %w(erubis sass scss less stylus markdown textile rdoc radius coffee creole yajl rabl).each do |lang|
72
+ define_method lang do |template, options = {}, locals = {}|
73
+ logger.info "rendering #{template}.#{lang}"
74
+ super template, options, locals
75
+ end
76
+ end
77
+ end
78
+
79
+ Sinatra::Base.send :include, VerboseTemplates
80
+ register Verbose
81
+ end
@@ -0,0 +1,5 @@
1
+ module Sinatra
2
+ module Verbose
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sinatra/verbose/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'sinatra-verbose'
8
+ spec.version = Sinatra::Verbose::VERSION
9
+ spec.authors = ['Patricio Mac Adden']
10
+ spec.email = ['patriciomacadden@gmail.com']
11
+ spec.description = 'Sinatra verbose logging extension'
12
+ spec.summary = 'Sinatra verbose logging extension'
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'minitest'
23
+ spec.add_development_dependency 'rack-test'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'sinatra'
26
+
27
+ spec.add_runtime_dependency 'sinatra'
28
+ end
@@ -0,0 +1,10 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+
3
+ require 'minitest/autorun'
4
+ require 'sinatra'
5
+ require 'sinatra/verbose'
6
+ require 'rack/test'
7
+
8
+ def mock_app(base = Sinatra::Base, &block)
9
+ @app = Sinatra.new(base, &block)
10
+ end
@@ -0,0 +1,68 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Sinatra::Verbose do
4
+ include Rack::Test::Methods
5
+
6
+ def app
7
+ Rack::Lint.new(@app)
8
+ end
9
+
10
+ it 'must log on after filters blocks' do
11
+ mock_app do
12
+ enable :logging
13
+ register Sinatra::Verbose
14
+
15
+ after { 'do something' }
16
+ get('/') { 'GET /' }
17
+ end
18
+
19
+ get '/'
20
+ last_response.must_be :ok?
21
+ last_response.body.must_equal 'GET /'
22
+ last_response.errors.must_match /passing through an after block/
23
+ end
24
+
25
+ it 'must log on before filters blocks' do
26
+ mock_app do
27
+ enable :logging
28
+ register Sinatra::Verbose
29
+
30
+ before { 'do something' }
31
+ get('/') { 'GET /' }
32
+ end
33
+
34
+ get '/'
35
+ last_response.must_be :ok?
36
+ last_response.body.must_equal 'GET /'
37
+ last_response.errors.must_match /passing through a before block/
38
+ end
39
+
40
+ it 'must log on error blocks' do
41
+ mock_app do
42
+ disable :raise_errors
43
+ enable :logging
44
+ register Sinatra::Verbose
45
+
46
+ error { 'do something' }
47
+ get('/') { raise 'Error!' }
48
+ end
49
+
50
+ get '/'
51
+ last_response.status.must_equal 500
52
+ last_response.errors.must_match /passing through an error block/
53
+ end
54
+
55
+ it 'must log when rendering' do
56
+ mock_app do
57
+ enable :logging
58
+ register Sinatra::Verbose
59
+
60
+ get('/') { erb '<%= "hello sinatra-contrib!" %>' }
61
+ end
62
+
63
+ get '/'
64
+ last_response.must_be :ok?
65
+ last_response.body.must_equal 'hello sinatra-contrib!'
66
+ last_response.errors.must_match /rendering <%= "hello sinatra-contrib!" %>.erb/
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-verbose
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patricio Mac Adden
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sinatra
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Sinatra verbose logging extension
98
+ email:
99
+ - patriciomacadden@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - Gemfile
106
+ - LICENSE
107
+ - README.md
108
+ - Rakefile
109
+ - lib/sinatra/verbose.rb
110
+ - lib/sinatra/verbose/version.rb
111
+ - sinatra-verbose.gemspec
112
+ - spec/minitest_helper.rb
113
+ - spec/verbose_spec.rb
114
+ homepage: ''
115
+ licenses:
116
+ - MIT
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.0.3
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Sinatra verbose logging extension
138
+ test_files:
139
+ - spec/minitest_helper.rb
140
+ - spec/verbose_spec.rb