grape-rabl 0.4.1 → 0.4.2

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: 808bb9d1fe12e1f3879525ff73e61415fcc3135e
4
- data.tar.gz: 95e2e7e6f1b8d73d1cf38bbe24139f424b3af6de
3
+ metadata.gz: 4f66c2fd9f44ff3363235629017ad85ef7aed831
4
+ data.tar.gz: d97536b97d1bce6b360f967d59b8047651a1afda
5
5
  SHA512:
6
- metadata.gz: e1652a0a0d314bdd17d8e1bb174a22959891a82fcf0ed5aec5968c4a438a4c0c67711238294ca64697fc60767b730c598de62f6d8aca2af72da559b4c26fc8cb
7
- data.tar.gz: ddeb3a86e10961f115295db92624b8f5d5c3c627cd6b4938f79b5b2f5f236435ec49b4c6141b7a6f150f91c3eee1de43b1f16e3e8322811514cca0ab70fce431
6
+ metadata.gz: a044c927a6dd449c97963c3f8dcf4450aa548db7d382c6fbb371f6ec43d0e3c6fbf4b4a896ae095648ffdf8233c8e342ca0148d49427c09103d8269ed06eb483
7
+ data.tar.gz: 4dae323c5e5ef547e406eeb2c6b11ea7d2e3a473bc67fe6a7452ff0290fdcd7db4a395e004920f9bb8d22acc41d2d9396fd36aee8ceb974288e95ce199623fa0
data/.rubocop.yml CHANGED
@@ -3,32 +3,4 @@ AllCops:
3
3
  - vendor/**
4
4
  - .bundle
5
5
 
6
- LineLength:
7
- Enabled: false
8
-
9
- MethodLength:
10
- Enabled: false
11
-
12
- ClassLength:
13
- Enabled: false
14
-
15
- Documentation:
16
- # don't require classes to be documented
17
- Enabled: false
18
-
19
- Encoding:
20
- # no need to always specify encoding
21
- Enabled: false
22
-
23
- CollectionMethods:
24
- # don't prefer map to collect, recuce to inject
25
- Enabled: false
26
-
27
- RescueException:
28
- Enabled: false
29
-
30
- DoubleNegation:
31
- Enabled: false
32
-
33
- FileName:
34
- Enabled: false
6
+ inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,50 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-06-08 16:00:13 -0400 using RuboCop version 0.40.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Lint/RescueException:
11
+ Exclude:
12
+ - 'spec/grape_rabl_spec.rb'
13
+
14
+ # Offense count: 21
15
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
16
+ # URISchemes: http, https
17
+ Metrics/LineLength:
18
+ Max: 148
19
+
20
+ # Offense count: 1
21
+ # Configuration parameters: CountComments.
22
+ Metrics/MethodLength:
23
+ Max: 13
24
+
25
+ # Offense count: 5
26
+ Style/Documentation:
27
+ Exclude:
28
+ - 'spec/**/*'
29
+ - 'test/**/*'
30
+ - 'lib/grape-rabl.rb'
31
+ - 'lib/grape-rabl/configuration.rb'
32
+ - 'lib/grape-rabl/formatter.rb'
33
+ - 'lib/grape-rabl/render.rb'
34
+ - 'lib/grape/rabl.rb'
35
+
36
+ # Offense count: 1
37
+ Style/DoubleNegation:
38
+ Exclude:
39
+ - 'lib/grape-rabl/formatter.rb'
40
+
41
+ # Offense count: 1
42
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
43
+ Style/FileName:
44
+ Exclude:
45
+ - 'lib/grape-rabl.rb'
46
+
47
+ # Offense count: 1
48
+ Style/IfInsideElse:
49
+ Exclude:
50
+ - 'lib/grape-rabl/formatter.rb'
data/.travis.yml CHANGED
@@ -1,14 +1,14 @@
1
1
  rvm:
2
- - 1.9.3
3
2
  - 2.0.0
4
3
  - 2.1.0
5
4
  - ruby-head
6
5
  - jruby-19mode
7
6
  - jruby-head
8
- - rbx-2.2.10
7
+ - rbx-2
9
8
 
10
9
  matrix:
11
10
  allow_failures:
12
11
  - rvm: jruby-19mode
13
12
  - rvm: jruby-head
14
13
  - rvm: ruby-head
14
+ - rvm: rbx-2
data/CHANGELOG.md CHANGED
@@ -1,70 +1,74 @@
1
+ #### v0.4.2
2
+
3
+ * Fix template caching for multiple formats. [#43](https://github.com/ruby-grape/grape-rabl/pull/43) [@kushkella](https://github.com/kushkella)
4
+
1
5
  #### v0.4.1
2
6
 
3
- * Automatically require 'grape/rabl'. [#39](https://github.com/LTe/grape-rabl/issues/39) [@martinezcoder](https://github.com/martinezcoder)
7
+ * Automatically require 'grape/rabl'. [#39](https://github.com/ruby-grape/grape-rabl/issues/39) [@martinezcoder](https://github.com/martinezcoder)
4
8
 
5
9
  #### v0.4.0
6
10
 
7
- * Make grape-rabl thread-safe. [#37](https://github.com/LTe/grape-rabl/issues/37) [@kushkella](https://github.com/kushkella)
11
+ * Make grape-rabl thread-safe. [#37](https://github.com/ruby-grape/grape-rabl/issues/37) [@kushkella](https://github.com/kushkella)
8
12
 
9
13
  #### v0.3.1
10
14
 
11
- * The `render` method will no longer modify endpoint options at runtime. [#35](https://github.com/LTe/grape-rabl/issues/35) [@yesmeck](https://github.com/yesmeck)
15
+ * The `render` method will no longer modify endpoint options at runtime. [#35](https://github.com/ruby-grape/grape-rabl/issues/35) [@yesmeck](https://github.com/yesmeck)
12
16
 
13
17
  #### v0.3.0
14
18
 
15
- * Enable using a layout template in Rabl. [@koko1000ban](https://github.com/koko1000ban) [view commit](https://github.com/LTe/grape-rabl/commit/1fbfbd58c3fb320be1b52b3247fda2a23cacc9fc)
16
- * Implemented Rubocop, Ruby style linter. [@dblock](https://github.com/dblock) [view commit](https://github.com/LTe/grape-rabl/commit/1211056de22a5989c063d57b7b37ebb1f1977e83)
17
- * Removed JRuby support. [@dblock](https://github.com/dblock) [view commit](https://github.com/LTe/grape-rabl/commit/59905c1b09670fe08501e09bad4ec8714839f2d3)
18
- * Enable using locals with #render. [@hobofan](https://github.com/hobofan) [view commit](https://github.com/LTe/grape-rabl/commit/6c24130f6a670e52e6119c56904b8ed2e6f60b39)
19
- * Enable support for template caching. [#28](https://github.com/LTe/grape-rabl/pull/28) [@kushkella](https://github.com/kushkella) [view commit](https://github.com/LTe/grape-rabl/commit/79b1e58d767c6286b510af669e718310c0ad25c2)
19
+ * Enable using a layout template in Rabl. [@koko1000ban](https://github.com/koko1000ban) [view commit](https://github.com/ruby-grape/grape-rabl/commit/1fbfbd58c3fb320be1b52b3247fda2a23cacc9fc)
20
+ * Implemented Rubocop, Ruby style linter. [@dblock](https://github.com/dblock) [view commit](https://github.com/ruby-grape/grape-rabl/commit/1211056de22a5989c063d57b7b37ebb1f1977e83)
21
+ * Removed JRuby support. [@dblock](https://github.com/dblock) [view commit](https://github.com/ruby-grape/grape-rabl/commit/59905c1b09670fe08501e09bad4ec8714839f2d3)
22
+ * Enable using locals with #render. [@hobofan](https://github.com/hobofan) [view commit](https://github.com/ruby-grape/grape-rabl/commit/6c24130f6a670e52e6119c56904b8ed2e6f60b39)
23
+ * Enable support for template caching. [#28](https://github.com/ruby-grape/grape-rabl/pull/28) [@kushkella](https://github.com/kushkella) [view commit](https://github.com/ruby-grape/grape-rabl/commit/79b1e58d767c6286b510af669e718310c0ad25c2)
20
24
 
21
25
  #### v0.2.2
22
26
 
23
- * Relaxed dependency on a specific version of Grape. [#20](https://github.com/LTe/grape-rabl/pull/20) [@cheef](https://github.com/cheef) [view commit](https://github.com/LTe/grape-rabl/commit/56da0a5bcecb16501cdd93ac25f3b6ca6d7a86f0)
27
+ * Relaxed dependency on a specific version of Grape. [#20](https://github.com/ruby-grape/grape-rabl/pull/20) [@cheef](https://github.com/cheef) [view commit](https://github.com/ruby-grape/grape-rabl/commit/56da0a5bcecb16501cdd93ac25f3b6ca6d7a86f0)
24
28
 
25
29
  #### v0.2.1
26
30
 
27
- * Fix: render template according to request format. [#11](https://github.com/LTe/grape-rabl/pull/11) [@alovak](https://github.com/alovak) [view commit](http://github.com/LTe/grape-rabl/commit/f9658cf7a3026122afbb77e0da613731a5828338)
31
+ * Fix: render template according to request format. [#11](https://github.com/ruby-grape/grape-rabl/pull/11) [@alovak](https://github.com/alovak) [view commit](http://github.com/ruby-grape/grape-rabl/commit/f9658cf7a3026122afbb77e0da613731a5828338)
28
32
 
29
33
  #### v0.2.0
30
34
 
31
- * Allow to use partials in Grape. [#10](https://github.com/LTe/grape-rabl/pull/10) [@ichilton](https://github.com/ichilton) [view commit](http://github.com/LTe/grape-rabl/commit/72c96c5acc9d8000f56ee8400ae0229053fb3e7e)
32
- * Stick to gem conventions. [@LTe](https://github.com/lte) [view commit](http://github.com/LTe/grape-rabl/commit/aabd0e2ad72f56a75427eebcc586deed57cf5f58)
33
- * Update for Grape 0.3 compatibility. [@alovak](https://github.com/alovak) [view commit](http://github.com/LTe/grape-rabl/commit/78bfdceffbfe90b700868ff1e79ab87e8baded81)
34
- * Format fix. [@LTe](https://github.com/lte) [view commit](http://github.com/LTe/grape-rabl/commit/13749cc18d332dcd0050bb32980cc233868a7992)
35
+ * Allow to use partials in Grape. [#10](https://github.com/ruby-grape/grape-rabl/pull/10) [@ichilton](https://github.com/ichilton) [view commit](http://github.com/ruby-grape/grape-rabl/commit/72c96c5acc9d8000f56ee8400ae0229053fb3e7e)
36
+ * Stick to gem conventions. [@LTe](https://github.com/lte) [view commit](http://github.com/ruby-grape/grape-rabl/commit/aabd0e2ad72f56a75427eebcc586deed57cf5f58)
37
+ * Update for Grape 0.3 compatibility. [@alovak](https://github.com/alovak) [view commit](http://github.com/ruby-grape/grape-rabl/commit/78bfdceffbfe90b700868ff1e79ab87e8baded81)
38
+ * Format fix. [@LTe](https://github.com/lte) [view commit](http://github.com/ruby-grape/grape-rabl/commit/13749cc18d332dcd0050bb32980cc233868a7992)
35
39
 
36
40
  #### v0.1.0
37
41
 
38
- * Updated w/ released Grape 0.2.3. [view commit](http://github.com/LTe/grape-rabl/commit/9a055dfd8e13e0952a587de7a2e19c9f762e939c)
39
- * Added link to Rabl. [view commit](http://github.com/LTe/grape-rabl/commit/2a7650cb5f9327761cac8b928453e451a973e131)
40
- * Grape 0.2.x and put back dependency status. [view commit](http://github.com/LTe/grape-rabl/commit/9c1183f3758db8a79737ff35f0c328be646a3f65)
41
- * Grape 0.2.3. [view commit](http://github.com/LTe/grape-rabl/commit/d06a6559a02095e1d84fbbd8df0c3eccdd31930b)
42
- * Updated Grape dependency via .gemspec. [view commit](http://github.com/LTe/grape-rabl/commit/fd44b6a91fa327438eac968fea62ac00ec3ae01f)
42
+ * Updated w/ released Grape 0.2.3. [view commit](http://github.com/ruby-grape/grape-rabl/commit/9a055dfd8e13e0952a587de7a2e19c9f762e939c)
43
+ * Added link to Rabl. [view commit](http://github.com/ruby-grape/grape-rabl/commit/2a7650cb5f9327761cac8b928453e451a973e131)
44
+ * Grape 0.2.x and put back dependency status. [view commit](http://github.com/ruby-grape/grape-rabl/commit/9c1183f3758db8a79737ff35f0c328be646a3f65)
45
+ * Grape 0.2.3. [view commit](http://github.com/ruby-grape/grape-rabl/commit/d06a6559a02095e1d84fbbd8df0c3eccdd31930b)
46
+ * Updated Grape dependency via .gemspec. [view commit](http://github.com/ruby-grape/grape-rabl/commit/fd44b6a91fa327438eac968fea62ac00ec3ae01f)
43
47
 
44
48
  #### v0.0.6
45
49
 
46
- * Use Grape formatter syntax instead of monkey-patching. [view commit](http://github.com/LTe/grape-rabl/commit/bfba4c382933fd0f912d9114676b6d79d627c3be)
47
- * Close block code in README. [view commit](http://github.com/LTe/grape-rabl/commit/f397a0de4399d0797b5e327d56234464091d7e3d)
48
- * Change home to user. [view commit](http://github.com/LTe/grape-rabl/commit/45178ec13c613d872c65475b330d20a548459681)
50
+ * Use Grape formatter syntax instead of monkey-patching. [view commit](http://github.com/ruby-grape/grape-rabl/commit/bfba4c382933fd0f912d9114676b6d79d627c3be)
51
+ * Close block code in README. [view commit](http://github.com/ruby-grape/grape-rabl/commit/f397a0de4399d0797b5e327d56234464091d7e3d)
52
+ * Change home to user. [view commit](http://github.com/ruby-grape/grape-rabl/commit/45178ec13c613d872c65475b330d20a548459681)
49
53
 
50
54
  #### v0.0.5
51
55
 
52
- * Respect default_format for rabl response. [view commit](http://github.com/LTe/grape-rabl/commit/ac54ebbb1d43d1fb76ee9516c5aa683c750c73b0)
56
+ * Respect default_format for rabl response. [view commit](http://github.com/ruby-grape/grape-rabl/commit/ac54ebbb1d43d1fb76ee9516c5aa683c750c73b0)
53
57
 
54
58
  #### v0.0.4
55
59
 
56
- * Require `grape/rabl`. [view commit](http://github.com/LTe/grape-rabl/commit/e99a185b20974f5e72ac3c19ec377a5853780a33)
60
+ * Require `grape/rabl`. [view commit](http://github.com/ruby-grape/grape-rabl/commit/e99a185b20974f5e72ac3c19ec377a5853780a33)
57
61
 
58
62
  #### v0.0.3
59
63
 
60
- * Template without `.rabl`. [view commit](http://github.com/LTe/grape-rabl/commit/cecca03a680f8ae50b406e1b8c170eba27d1bc99)
64
+ * Template without `.rabl`. [view commit](http://github.com/ruby-grape/grape-rabl/commit/cecca03a680f8ae50b406e1b8c170eba27d1bc99)
61
65
 
62
66
  #### v0.0.2
63
67
 
64
- * Add Travis. [view commit](http://github.com/LTe/grape-rabl/commit/71c905bc91066c6fdb628afb555561e23219e213)
65
- * Remove ruby debug. [view commit](http://github.com/LTe/grape-rabl/commit/f80fad14a49b14ae7264b08eff12832c37cbd0b2)
66
- * Works with rubinius. [view commit](http://github.com/LTe/grape-rabl/commit/fceece344de095916ded7c477bb5891537bb8663)
67
- * Add dependency status. [view commit](http://github.com/LTe/grape-rabl/commit/66820fb52155c65d4cd9bd7b67f0f22c1105fa46)
68
+ * Add Travis. [view commit](http://github.com/ruby-grape/grape-rabl/commit/71c905bc91066c6fdb628afb555561e23219e213)
69
+ * Remove ruby debug. [view commit](http://github.com/ruby-grape/grape-rabl/commit/f80fad14a49b14ae7264b08eff12832c37cbd0b2)
70
+ * Works with rubinius. [view commit](http://github.com/ruby-grape/grape-rabl/commit/fceece344de095916ded7c477bb5891537bb8663)
71
+ * Add dependency status. [view commit](http://github.com/ruby-grape/grape-rabl/commit/66820fb52155c65d4cd9bd7b67f0f22c1105fa46)
68
72
 
69
73
  #### v0.0.1
70
74
 
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,118 @@
1
+ Contributing to Grape-Rabl
2
+ ==========================
3
+
4
+ Grape-Rabl is work of [many of contributors](https://github.com/ruby-grape/grape-rabl/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/ruby-grape/grape-rabl/pulls), [propose features and discuss issues](https://github.com/ruby-grape/grape-rabl/issues). When in doubt, ask a question in the [Grape Google Group](http://groups.google.com/group/ruby-grape).
5
+
6
+ #### Fork the Project
7
+
8
+ Fork the [project on Github](https://github.com/ruby-grape/grape-rabl) and check out your copy.
9
+
10
+ ```
11
+ git clone https://github.com/contributor/grape-rabl.git
12
+ cd grape-rabl
13
+ git remote add upstream https://github.com/ruby-grape/grape-rabl.git
14
+ ```
15
+
16
+ #### Create a Topic Branch
17
+
18
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
19
+
20
+ ```
21
+ git checkout master
22
+ git pull upstream master
23
+ git checkout -b my-feature-branch
24
+ ```
25
+
26
+ #### Bundle Install and Test
27
+
28
+ Ensure that you can build the project and run tests.
29
+
30
+ ```
31
+ bundle install
32
+ bundle exec rake
33
+ ```
34
+
35
+ #### Write Tests
36
+
37
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/grape-rabl](spec/grape-rabl).
38
+
39
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
40
+
41
+ #### Write Code
42
+
43
+ Implement your feature or bug fix.
44
+
45
+ Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
46
+
47
+ Make sure that `bundle exec rake` completes without errors.
48
+
49
+ #### Write Documentation
50
+
51
+ Document any external behavior in the [README](README.md).
52
+
53
+ #### Update Changelog
54
+
55
+ Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
56
+
57
+ #### Commit Changes
58
+
59
+ Make sure git knows your name and email address:
60
+
61
+ ```
62
+ git config --global user.name "Your Name"
63
+ git config --global user.email "contributor@example.com"
64
+ ```
65
+
66
+ Writing good commit logs is important. A commit log should describe what changed and why.
67
+
68
+ ```
69
+ git add ...
70
+ git commit
71
+ ```
72
+
73
+ #### Push
74
+
75
+ ```
76
+ git push origin my-feature-branch
77
+ ```
78
+
79
+ #### Make a Pull Request
80
+
81
+ Go to https://github.com/contributor/grape-rabl and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
82
+
83
+ #### Rebase
84
+
85
+ If you've been working on a change for a while, rebase with upstream/master.
86
+
87
+ ```
88
+ git fetch upstream
89
+ git rebase upstream/master
90
+ git push origin my-feature-branch -f
91
+ ```
92
+
93
+ #### Update CHANGELOG Again
94
+
95
+ Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
96
+
97
+ ```
98
+ * [#123](https://github.com/ruby-grape/grape-rabl/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
99
+ ```
100
+
101
+ Amend your previous commit and force push the changes.
102
+
103
+ ```
104
+ git commit --amend
105
+ git push origin my-feature-branch -f
106
+ ```
107
+
108
+ #### Check on Your Pull Request
109
+
110
+ Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
111
+
112
+ #### Be Patient
113
+
114
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
115
+
116
+ #### Thank You
117
+
118
+ Please do know that we really appreciate and value your time and work. We love you, really.
data/Gemfile CHANGED
@@ -3,18 +3,18 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem "rubocop", "0.20.1"
6
+ gem 'rubocop', '0.40.0'
7
7
  end
8
8
 
9
9
  group :test do
10
- gem "json", '~> 1.7.7'
11
- gem "rspec", "~> 2.12.0"
12
- gem "rack-test"
13
- gem "rake"
14
- gem "coveralls", require: false
15
- gem "rabl", :github => "nesquena/rabl"
10
+ gem 'json'
11
+ gem 'rspec'
12
+ gem 'rack-test'
13
+ gem 'rake'
14
+ gem 'coveralls', require: false
15
+ gem 'rabl'
16
16
 
17
17
  platforms :rbx do
18
- gem "iconv"
18
+ gem 'iconv'
19
19
  end
20
20
  end
data/README.md CHANGED
@@ -3,10 +3,10 @@
3
3
  Use [Rabl](https://github.com/nesquena/rabl) templates in [Grape](https://github.com/intridea/grape)!
4
4
 
5
5
  [![Gem Version](http://img.shields.io/gem/v/grape-rabl.svg)](http://badge.fury.io/rb/grape-rabl)
6
- [![Build Status](http://img.shields.io/travis/LTe/grape-rabl.svg)](https://travis-ci.org/LTe/grape-rabl)
7
- [![Dependency Status](https://gemnasium.com/LTe/grape-rabl.svg)](https://gemnasium.com/LTe/grape-rabl)
8
- [![Code Climate](https://codeclimate.com/github/LTe/grape-rabl.svg)](https://codeclimate.com/github/LTe/grape-rabl)
9
- [![Coverage Status](https://img.shields.io/coveralls/LTe/grape-rabl.svg)](https://coveralls.io/r/LTe/grape-rabl?branch=master)
6
+ [![Build Status](http://img.shields.io/travis/ruby-grape/grape-rabl.svg)](https://travis-ci.org/ruby-grape/grape-rabl)
7
+ [![Dependency Status](https://gemnasium.com/ruby-grape/grape-rabl.svg)](https://gemnasium.com/ruby-grape/grape-rabl)
8
+ [![Code Climate](https://codeclimate.com/github/ruby-grape/grape-rabl.svg)](https://codeclimate.com/github/ruby-grape/grape-rabl)
9
+ [![Coverage Status](https://img.shields.io/coveralls/ruby-grape/grape-rabl.svg)](https://coveralls.io/r/ruby-grape/grape-rabl?branch=master)
10
10
 
11
11
  ## Installation
12
12
 
@@ -77,7 +77,7 @@ end
77
77
 
78
78
  ### Enable template caching
79
79
 
80
- Gape-rabl allows for template caching after templates are loaded initially.
80
+ Grape-rabl allows for template caching after templates are loaded initially.
81
81
 
82
82
  You can enable template caching:
83
83
 
@@ -204,5 +204,5 @@ Enjoy :)
204
204
  5. Create new Pull Request
205
205
 
206
206
 
207
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/LTe/grape-rabl/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
207
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ruby-grape/grape-rabl/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
208
208
 
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
2
+ require 'bundler/gem_tasks'
3
3
 
4
4
  require 'rspec/core'
5
5
  require 'rspec/core/rake_task'
@@ -9,6 +9,6 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
9
9
  end
10
10
 
11
11
  require 'rubocop/rake_task'
12
- Rubocop::RakeTask.new(:rubocop)
12
+ RuboCop::RakeTask.new(:rubocop)
13
13
 
14
14
  task default: [:rubocop, :spec]
data/grape-rabl.gemspec CHANGED
@@ -3,21 +3,21 @@ require File.expand_path('../lib/grape-rabl/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Piotr Niełacny"]
6
- gem.email = ["piotr.nielacny@gmail.com"]
7
- gem.description = %q{Use rabl in grape}
8
- gem.summary = %q{Use rabl in grape}
9
- gem.homepage = "https://github.com/LTe/grape-rabl"
6
+ gem.email = ['piotr.nielacny@gmail.com']
7
+ gem.description = 'Use rabl in grape'
8
+ gem.summary = 'Use rabl in grape'
9
+ gem.homepage = 'https://github.com/ruby-grape/grape-rabl'
10
10
 
11
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
12
12
  gem.files = `git ls-files`.split("\n")
13
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
- gem.name = "grape-rabl"
15
- gem.require_paths = ["lib"]
14
+ gem.name = 'grape-rabl'
15
+ gem.require_paths = ['lib']
16
16
  gem.version = Grape::Rabl::VERSION
17
17
  gem.required_ruby_version = '>= 1.9.3'
18
18
 
19
- gem.add_dependency "grape"
20
- gem.add_dependency "rabl"
21
- gem.add_dependency "tilt"
22
- gem.add_dependency "i18n"
19
+ gem.add_dependency 'grape'
20
+ gem.add_dependency 'rabl'
21
+ gem.add_dependency 'tilt'
22
+ gem.add_dependency 'i18n'
23
23
  end
data/lib/grape-rabl.rb CHANGED
@@ -11,7 +11,7 @@ require 'grape-rabl/configuration'
11
11
  module Grape
12
12
  module Rabl
13
13
  class << self
14
- def configure(&block)
14
+ def configure
15
15
  yield(configuration)
16
16
  configuration
17
17
  end
@@ -48,7 +48,7 @@ module Grape
48
48
  end
49
49
 
50
50
  def rabl
51
- fail 'missing rabl template' unless rabl_template
51
+ raise 'missing rabl template' unless rabl_template
52
52
  set_view_root unless env['api.tilt.root']
53
53
  yield rabl_template
54
54
  end
@@ -62,12 +62,12 @@ module Grape
62
62
  end
63
63
 
64
64
  def set_view_root
65
- fail "Use Rack::Config to set 'api.tilt.root' in config.ru"
65
+ raise "Use Rack::Config to set 'api.tilt.root' in config.ru"
66
66
  end
67
67
 
68
68
  def tilt_template(template)
69
69
  if Grape::Rabl.configuration.cache_template_loading
70
- Grape::Rabl::Formatter.tilt_cache.fetch(template) { ::Tilt.new(view_path(template), tilt_options) }
70
+ Grape::Rabl::Formatter.tilt_cache.fetch(tilt_cache_key(template)) { ::Tilt.new(view_path(template), tilt_options) }
71
71
  else
72
72
  ::Tilt.new(view_path(template), tilt_options)
73
73
  end
@@ -80,11 +80,15 @@ module Grape
80
80
  def layout_template
81
81
  layout_path = view_path(env['api.tilt.layout'] || 'layouts/application')
82
82
  if Grape::Rabl.configuration.cache_template_loading
83
- Grape::Rabl::Formatter.tilt_cache.fetch(layout_path) { ::Tilt.new(layout_path, tilt_options) if File.exist?(layout_path) }
83
+ Grape::Rabl::Formatter.tilt_cache.fetch(tilt_cache_key(layout_path)) { ::Tilt.new(layout_path, tilt_options) if File.exist?(layout_path) }
84
84
  else
85
85
  ::Tilt.new(layout_path, tilt_options) if File.exist?(layout_path)
86
86
  end
87
87
  end
88
+
89
+ def tilt_cache_key(path)
90
+ Digest::MD5.hexdigest("#{path}#{tilt_options}")
91
+ end
88
92
  end
89
93
  end
90
94
  end
@@ -1,5 +1,5 @@
1
1
  module Grape
2
2
  module Rabl
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'.freeze
4
4
  end
5
5
  end
@@ -3,16 +3,16 @@ require 'spec_helper'
3
3
  describe 'Grape::Rabl configuration' do
4
4
  context 'configuration' do
5
5
  it 'returns default values' do
6
- Grape::Rabl.configuration.cache_template_loading.should == false
6
+ expect(Grape::Rabl.configuration.cache_template_loading).to eq(false)
7
7
  end
8
8
 
9
9
  it 'should set and reset configuration' do
10
10
  Grape::Rabl.configure do |config|
11
11
  config.cache_template_loading = true
12
12
  end
13
- Grape::Rabl.configuration.cache_template_loading.should be == true
13
+ expect(Grape::Rabl.configuration.cache_template_loading).to eq(true)
14
14
  Grape::Rabl.reset_configuration!
15
- Grape::Rabl.configuration.cache_template_loading.should == false
15
+ expect(Grape::Rabl.configuration.cache_template_loading).to eq(false)
16
16
  end
17
17
  end
18
18
  end
@@ -28,8 +28,9 @@ describe 'Grape::Rabl layout' do
28
28
  end
29
29
 
30
30
  get('/about')
31
- parsed_response.should ==
32
- JSON.parse(%Q({"status":200,"result":{"user":{"name":"LTe","project":{"name":"First"}}}}))
31
+ expect(parsed_response).to eq(
32
+ JSON.parse(%({"status":200,"result":{"user":{"name":"LTe","project":{"name":"First"}}}}))
33
+ )
33
34
  end
34
35
  end
35
36
 
@@ -47,17 +48,18 @@ describe 'Grape::Rabl layout' do
47
48
 
48
49
  get('/about')
49
50
  puts last_response.body
50
- parsed_response.should ==
51
- JSON.parse(%Q({"result":{"user":{"name":"LTe","project":{"name":"First"}}}}))
51
+ expect(parsed_response).to eq(
52
+ JSON.parse(%({"result":{"user":{"name":"LTe","project":{"name":"First"}}}}))
53
+ )
52
54
  end
53
55
  end
54
56
 
55
57
  context 'layout cache' do
56
58
  before do
57
- @views_dir = FileUtils.mkdir_p("#{File.expand_path("..", File.dirname(__FILE__))}/tmp")[0]
59
+ @views_dir = FileUtils.mkdir_p("#{File.expand_path('..', File.dirname(__FILE__))}/tmp")[0]
58
60
  @layout = "#{@views_dir}/layouts/application.rabl"
59
61
  FileUtils.cp_r("#{File.dirname(__FILE__)}/views/layout_test/.", @views_dir)
60
- subject.before { env['api.tilt.root'] = "#{File.expand_path("..", File.dirname(__FILE__))}/tmp" }
62
+ subject.before { env['api.tilt.root'] = "#{File.expand_path('..', File.dirname(__FILE__))}/tmp" }
61
63
  subject.get('/home', rabl: 'user') do
62
64
  @user = OpenStruct.new(name: 'LTe', email: 'email@example.com')
63
65
  @project = OpenStruct.new(name: 'First')
@@ -75,24 +77,24 @@ describe 'Grape::Rabl layout' do
75
77
  config.cache_template_loading = true
76
78
  end
77
79
  get '/home'
78
- last_response.status.should be == 200
80
+ expect(last_response.status).to eq(200)
79
81
  old_response = last_response.body
80
82
  open(@layout, 'a') { |f| f << 'node(:test) { "test" }' }
81
83
  get '/home'
82
- last_response.status.should be == 200
84
+ expect(last_response.status).to eq(200)
83
85
  new_response = last_response.body
84
- old_response.should == new_response
86
+ expect(old_response).to eq(new_response)
85
87
  end
86
88
 
87
89
  it 'should serve new template if cache_template_loading' do
88
90
  get '/home'
89
- last_response.status.should be == 200
91
+ expect(last_response.status).to eq(200)
90
92
  old_response = last_response.body
91
93
  open(@layout, 'a') { |f| f << 'node(:test) { "test" }' }
92
94
  get '/home'
93
- last_response.status.should be == 200
95
+ expect(last_response.status).to eq(200)
94
96
  new_response = last_response.body
95
- old_response.should_not == new_response
97
+ expect(old_response).not_to eq(new_response)
96
98
  end
97
99
  end
98
100
  end
@@ -25,7 +25,8 @@ describe 'Grape::Rabl partials' do
25
25
  end
26
26
 
27
27
  get('/home')
28
- parsed_response.should ==
29
- JSON.parse("{\"project\":{\"name\":\"First\",\"info\":{\"type\":\"paper\"},\"author\":{\"author\":\"LTe\"}}}")
28
+ expect(parsed_response).to eq(
29
+ JSON.parse('{"project":{"name":"First","info":{"type":"paper"},"author":{"author":"LTe"}}}')
30
+ )
30
31
  end
31
32
  end
@@ -6,8 +6,9 @@ describe Grape::Rabl do
6
6
  end
7
7
 
8
8
  before do
9
- subject.format :json
9
+ subject.default_format :json
10
10
  subject.formatter :json, Grape::Formatter::Rabl
11
+ subject.formatter :xml, Grape::Formatter::Rabl
11
12
  subject.helpers MyHelper
12
13
  end
13
14
 
@@ -18,7 +19,7 @@ describe Grape::Rabl do
18
19
  it 'should work without rabl template' do
19
20
  subject.get('/home') { 'Hello World' }
20
21
  get '/home'
21
- last_response.body.should == "\"Hello World\""
22
+ expect(last_response.body).to eq('"Hello World"')
22
23
  end
23
24
 
24
25
  it 'should raise error about root directory' do
@@ -26,11 +27,11 @@ describe Grape::Rabl do
26
27
  subject.get('/home', rabl: true) {}
27
28
  get '/home'
28
29
  rescue Exception => e
29
- e.message.should include "Use Rack::Config to set 'api.tilt.root' in config.ru"
30
+ expect(e.message).to include "Use Rack::Config to set 'api.tilt.root' in config.ru"
30
31
  end
31
32
  end
32
33
 
33
- context 'titl root is setup' do
34
+ context 'titl root is setup' do
34
35
  let(:parsed_response) { JSON.parse(last_response.body) }
35
36
 
36
37
  before do
@@ -41,7 +42,7 @@ describe Grape::Rabl do
41
42
  it 'should execute helper' do
42
43
  subject.get('/home', rabl: 'helper') { @user = OpenStruct.new }
43
44
  get '/home'
44
- parsed_response.should == JSON.parse("{\"user\":{\"helper\":\"my_helper\"}}")
45
+ expect(parsed_response).to eq(JSON.parse('{"user":{"helper":"my_helper"}}'))
45
46
  end
46
47
  end
47
48
 
@@ -75,33 +76,33 @@ describe Grape::Rabl do
75
76
 
76
77
  it 'renders template passed as argument to render method' do
77
78
  get('/home')
78
- parsed_response.should == JSON.parse('{"admin":{"name":"LTe"}}')
79
+ expect(parsed_response).to eq(JSON.parse('{"admin":{"name":"LTe"}}'))
79
80
  end
80
81
 
81
82
  it 'renders admin template' do
82
83
  get('/admin/1')
83
- parsed_response.should == JSON.parse('{"admin":{"name":"LTe"}}')
84
+ expect(parsed_response).to eq(JSON.parse('{"admin":{"name":"LTe"}}'))
84
85
  end
85
86
 
86
87
  it 'renders user template' do
87
88
  get('/admin/2')
88
- parsed_response.should == JSON.parse('{"user":{"name":"LTe","project":null}}')
89
+ expect(parsed_response).to eq(JSON.parse('{"user":{"name":"LTe","project":null}}'))
89
90
  end
90
91
 
91
92
  it 'renders template passed as argument to render method with locals' do
92
93
  get('/home-detail')
93
- parsed_response.should == JSON.parse('{"admin":{"name":"LTe","details":"amazing detail"}}')
94
+ expect(parsed_response).to eq(JSON.parse('{"admin":{"name":"LTe","details":"amazing detail"}}'))
94
95
  end
95
96
 
96
97
  it 'renders with locals without overriding template' do
97
98
  get('/about-detail')
98
- parsed_response.should == JSON.parse('{"user":{"name":"LTe","details":"just a user","project":null}}')
99
+ expect(parsed_response).to eq(JSON.parse('{"user":{"name":"LTe","details":"just a user","project":null}}'))
99
100
  end
100
101
 
101
102
  it 'does not save rabl options after called #render method' do
102
103
  get('/home')
103
104
  get('/about')
104
- parsed_response.should == JSON.parse('{"user":{"name":"LTe","project":null}}')
105
+ expect(parsed_response).to eq(JSON.parse('{"user":{"name":"LTe","project":null}}'))
105
106
  end
106
107
 
107
108
  it 'does not modify endpoint options' do
@@ -113,14 +114,14 @@ describe Grape::Rabl do
113
114
  it 'should respond with proper content-type' do
114
115
  subject.get('/home', rabl: 'user') {}
115
116
  get('/home')
116
- last_response.headers['Content-Type'].should == 'application/json'
117
+ expect(last_response.headers['Content-Type']).to eq('application/json')
117
118
  end
118
119
 
119
120
  it 'should not raise error about root directory' do
120
121
  subject.get('/home', rabl: 'user') {}
121
122
  get '/home'
122
- last_response.status.should eq 200
123
- last_response.body.should_not include "Use Rack::Config to set 'api.tilt.root' in config.ru"
123
+ expect(last_response.status).to eq 200
124
+ expect(last_response.body).not_to include "Use Rack::Config to set 'api.tilt.root' in config.ru"
124
125
  end
125
126
 
126
127
  ['user', 'user.rabl'].each do |rabl_option|
@@ -131,16 +132,16 @@ describe Grape::Rabl do
131
132
  end
132
133
 
133
134
  get '/home'
134
- parsed_response.should == JSON.parse('{"user":{"name":"LTe","email":"email@example.com","project":{"name":"First"}}}')
135
+ expect(parsed_response).to eq(JSON.parse('{"user":{"name":"LTe","email":"email@example.com","project":{"name":"First"}}}'))
135
136
  end
136
137
  end
137
138
 
138
139
  describe 'template cache' do
139
140
  before do
140
- @views_dir = FileUtils.mkdir_p("#{File.expand_path("..", File.dirname(__FILE__))}/tmp")[0]
141
+ @views_dir = FileUtils.mkdir_p("#{File.expand_path('..', File.dirname(__FILE__))}/tmp")[0]
141
142
  @template = "#{@views_dir}/user.rabl"
142
143
  FileUtils.cp("#{File.dirname(__FILE__)}/views/user.rabl", @template)
143
- subject.before { env['api.tilt.root'] = "#{File.expand_path("..", File.dirname(__FILE__))}/tmp" }
144
+ subject.before { env['api.tilt.root'] = "#{File.expand_path('..', File.dirname(__FILE__))}/tmp" }
144
145
  subject.get('/home', rabl: 'user') do
145
146
  @user = OpenStruct.new(name: 'LTe', email: 'email@example.com')
146
147
  @project = OpenStruct.new(name: 'First')
@@ -157,24 +158,44 @@ describe Grape::Rabl do
157
158
  config.cache_template_loading = true
158
159
  end
159
160
  get '/home'
160
- last_response.status.should be == 200
161
+ expect(last_response.status).to eq(200)
161
162
  old_response = last_response.body
162
163
  open(@template, 'a') { |f| f << 'node(:test) { "test" }' }
163
164
  get '/home'
164
- last_response.status.should be == 200
165
+ expect(last_response.status).to eq(200)
165
166
  new_response = last_response.body
166
- old_response.should == new_response
167
+ expect(old_response).to eq(new_response)
167
168
  end
168
169
 
169
- it 'should serve new template if cache_template_loading' do
170
+ it 'should maintain different cached templates for different formats' do
171
+ Grape::Rabl.configure do |config|
172
+ config.cache_template_loading = true
173
+ end
174
+ get '/home'
175
+ expect(last_response.status).to eq(200)
176
+ json_response = last_response.body
177
+ get '/home.xml'
178
+ expect(last_response.status).to eq(200)
179
+ xml_response = last_response.body
180
+ expect(json_response).not_to eq(xml_response)
181
+ open(@template, 'a') { |f| f << 'node(:test) { "test" }' }
182
+ get '/home.xml'
183
+ expect(last_response.status).to eq(200)
184
+ expect(last_response.body).to eq(xml_response)
185
+ get '/home.json'
186
+ expect(last_response.status).to eq(200)
187
+ expect(last_response.body).to eq(json_response)
188
+ end
189
+
190
+ it 'should serve new template unless cache_template_loading' do
170
191
  get '/home'
171
- last_response.status.should be == 200
192
+ expect(last_response.status).to eq(200)
172
193
  old_response = last_response.body
173
194
  open(@template, 'a') { |f| f << 'node(:test) { "test" }' }
174
195
  get '/home'
175
- last_response.status.should be == 200
196
+ expect(last_response.status).to eq(200)
176
197
  new_response = last_response.body
177
- old_response.should_not == new_response
198
+ expect(old_response).not_to eq(new_response)
178
199
  end
179
200
  end
180
201
  end
@@ -14,7 +14,7 @@ describe Grape::Rabl do
14
14
  subject
15
15
  end
16
16
 
17
- context 'with xml format' do
17
+ context 'with xml format' do
18
18
  before do
19
19
  subject.before do
20
20
  env['api.tilt.root'] = "#{File.dirname(__FILE__)}/views"
@@ -25,7 +25,7 @@ describe Grape::Rabl do
25
25
  it 'should respond with proper content-type' do
26
26
  subject.get('/home', rabl: 'user') {}
27
27
  get('/home')
28
- last_response.headers['Content-Type'].should == 'application/xml'
28
+ expect(last_response.headers['Content-Type']).to eq('application/xml')
29
29
  end
30
30
 
31
31
  ['user', 'user.rabl'].each do |rabl_option|
@@ -37,7 +37,7 @@ describe Grape::Rabl do
37
37
 
38
38
  get '/home'
39
39
 
40
- last_response.body.should == %Q(<?xml version="1.0" encoding="UTF-8"?>
40
+ expect(last_response.body).to eq(%(<?xml version="1.0" encoding="UTF-8"?>
41
41
  <user>
42
42
  <name>LTe</name>
43
43
  <email>email@example.com</email>
@@ -45,7 +45,7 @@ describe Grape::Rabl do
45
45
  <name>First</name>
46
46
  </project>
47
47
  </user>
48
- )
48
+ ))
49
49
  end
50
50
  end
51
51
  end
data/spec/spec_helper.rb CHANGED
@@ -15,6 +15,7 @@ require 'ostruct'
15
15
 
16
16
  RSpec.configure do |config|
17
17
  config.include Rack::Test::Methods
18
+ config.raise_errors_for_deprecations!
18
19
  end
19
20
 
20
21
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-rabl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Niełacny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-03 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -77,8 +77,10 @@ files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
79
  - ".rubocop.yml"
80
+ - ".rubocop_todo.yml"
80
81
  - ".travis.yml"
81
82
  - CHANGELOG.md
83
+ - CONTRIBUTING.md
82
84
  - Gemfile
83
85
  - LICENSE
84
86
  - README.md
@@ -107,7 +109,7 @@ files:
107
109
  - spec/views/layout_test/user.rabl
108
110
  - spec/views/project.rabl
109
111
  - spec/views/user.rabl
110
- homepage: https://github.com/LTe/grape-rabl
112
+ homepage: https://github.com/ruby-grape/grape-rabl
111
113
  licenses: []
112
114
  metadata: {}
113
115
  post_install_message:
@@ -126,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
128
  version: '0'
127
129
  requirements: []
128
130
  rubyforge_project:
129
- rubygems_version: 2.2.2
131
+ rubygems_version: 2.6.4
130
132
  signing_key:
131
133
  specification_version: 4
132
134
  summary: Use rabl in grape