strict_templates 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad65aaa77460ae4b7b2b9d75ada8f28ef12f2283
4
- data.tar.gz: 91251e1096a2c3f8fac84fc8398c7f88aee5ab53
3
+ metadata.gz: 330ac4e189172743eefe10ad36e7f339041625b6
4
+ data.tar.gz: d36000298f92b650d15d1d50c57c9fc242f01db3
5
5
  SHA512:
6
- metadata.gz: d439ec62591c419d55d57b20596ee82631c9c73b091c44c086dc1b4491dfe83cb2930008fd97530bf5dfaea7429c0d8a743f9b861d5bc72e353f7ef925691068
7
- data.tar.gz: ddb9c9d6dd9ccc7e21283ce78c2800c19cda05dd3770a27047ea39da2e44057db8dbc0b5510de02e9fabc0c8319089cc996d1d41c7416fb19f5d43e25511b18f
6
+ metadata.gz: a5706e18d6df56217b877db175302a13379caf0bb1e6caafac19893db176441d7cb18e38f5e96a69c4e4e4a4afa90322cf2cf112cfb916b968fb5839ce0f4648
7
+ data.tar.gz: 54efbeb76df432aaed43e99732db46b65d9acb8880d71b276a35fe7071da2d82bf414e9d2f4b2d9a70cfb2b1d0d42f1f5b5349908236c7807715ff6fd8a93146
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
- # StrictTemplates
1
+ # StrictTemplates [![Build Status](https://travis-ci.org/kellysutton/strict_templates.svg?branch=master)](https://travis-ci.org/kellysutton/strict_templates)
2
2
 
3
- A gem for ensuring that database queries do not execute while
4
- rendering templates in a Rails application.
3
+ A gem for ensuring that database queries do not execute while rendering templates in a Rails application.
5
4
 
6
- This is a work in progress, as it does not currently work in multi-threaded
7
- environments (e.g. Puma).
5
+ With great power comes great responsibility. ERB is an extremely flexible templating language, but can also . Gems like [`bullet`](https://github.com/flyerhzm/bullet) are great for detecting N+1 queries within an application. But for those of us that want to go the extra mile and **prevent any database access from within a template**, this gem is for you.
6
+
7
+ Doing this helps keep all database access centralized to your controller layer.
8
+
9
+ Pull Requests welcome to enable other methods of generating responses (RABL, etc.)
8
10
 
9
11
  ## Installation
10
12
 
@@ -16,14 +18,21 @@ group :development, :test do
16
18
  end
17
19
  ```
18
20
 
19
- And then execute:
21
+ And then do your normal:
20
22
 
21
23
  $ bundle
22
24
 
25
+ Next, include `StrictTemplates::Concern` in all controllers you wish to prevent database queries while rendering. If it's a new app, you should include it in your `ApplicationController`, e.g.
26
+
27
+ ```ruby
28
+ class ApplicationController < ActionController::Base
29
+ include StrictTemplates::Concern
30
+ end
31
+ ```
32
+
23
33
  ## Usage
24
34
 
25
- Errors will be raised whenever a request issues a SQL statement from
26
- within a template.
35
+ Errors will be raised whenever a request issues a SQL statement from within a template.
27
36
 
28
37
  ## Development
29
38
 
@@ -33,7 +42,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
33
42
 
34
43
  ## Contributing
35
44
 
36
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/strict_templates. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kellysutton/strict_templates. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
37
46
 
38
47
 
39
48
  ## License
@@ -10,7 +10,7 @@ module StrictTemplates
10
10
  def render(*args, &block)
11
11
  callback = lambda do |name, start, finish, id, payload|
12
12
  if !should_ignore_sql_statement?(payload[:name])
13
- raise SqlPerformedWithinTemplateError.new("A SQL request was issued within the template: \n #{payload[:sql]}")
13
+ raise SQLPerformedWithinTemplateError.new("A SQL request was issued within the template: \n #{payload[:sql]}")
14
14
  end
15
15
  end
16
16
 
@@ -1,3 +1,3 @@
1
1
  module StrictTemplates
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strict_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Sutton