rabl 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -1
- data/Rakefile +2 -2
- data/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl +1 -0
- data/fixtures/padrino_test/app/views +1 -0
- data/fixtures/padrino_test/db/migrate +1 -0
- data/fixtures/padrino_test/models +1 -0
- data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +1 -0
- data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +1 -0
- data/fixtures/rails2/app/models +1 -0
- data/fixtures/rails2/app/views +1 -0
- data/fixtures/rails2/db/migrate +1 -0
- data/fixtures/rails2/test/functionals/posts_controller_test.rb +1 -0
- data/fixtures/rails2/test/functionals/users_controller_test.rb +1 -0
- data/fixtures/rails3/app/models +1 -0
- data/fixtures/rails3/app/views +1 -0
- data/fixtures/rails3/db/migrate +1 -0
- data/fixtures/rails3/test/functional/posts_controller_test.rb +1 -0
- data/fixtures/rails3/test/functional/users_controller_test.rb +1 -0
- data/fixtures/rails3_2/app/models +1 -0
- data/fixtures/rails3_2/app/views +1 -0
- data/fixtures/rails3_2/db/migrate +1 -0
- data/fixtures/rails3_2/test/functional/posts_controller_test.rb +1 -0
- data/fixtures/rails3_2/test/functional/users_controller_test.rb +1 -0
- data/fixtures/rails4/app/models +1 -0
- data/fixtures/rails4/app/views +1 -0
- data/fixtures/rails4/db/migrate +1 -0
- data/fixtures/rails4/test/functional/posts_controller_test.rb +1 -0
- data/fixtures/rails4/test/functional/users_controller_test.rb +1 -0
- data/fixtures/rails5/.gitignore +21 -0
- data/fixtures/rails5/Gemfile +52 -0
- data/fixtures/rails5/README.md +24 -0
- data/fixtures/rails5/Rakefile +13 -0
- data/fixtures/rails5/app/assets/config/manifest.js +3 -0
- data/fixtures/rails5/app/assets/images/.keep +0 -0
- data/fixtures/rails5/app/assets/javascripts/application.js +16 -0
- data/fixtures/rails5/app/assets/javascripts/cable.js +13 -0
- data/fixtures/rails5/app/assets/javascripts/channels/.keep +0 -0
- data/fixtures/rails5/app/assets/stylesheets/application.css +15 -0
- data/fixtures/rails5/app/channels/application_cable/channel.rb +4 -0
- data/fixtures/rails5/app/channels/application_cable/connection.rb +4 -0
- data/fixtures/rails5/app/controllers/application_controller.rb +3 -0
- data/fixtures/rails5/app/controllers/concerns/.keep +0 -0
- data/fixtures/rails5/app/controllers/posts_controller.rb +17 -0
- data/fixtures/rails5/app/controllers/users_controller.rb +11 -0
- data/fixtures/rails5/app/helpers/application_helper.rb +5 -0
- data/fixtures/rails5/app/jobs/application_job.rb +2 -0
- data/fixtures/rails5/app/mailers/application_mailer.rb +4 -0
- data/fixtures/rails5/app/models +1 -0
- data/fixtures/rails5/app/views +1 -0
- data/fixtures/rails5/bin/bundle +3 -0
- data/fixtures/rails5/bin/rails +9 -0
- data/fixtures/rails5/bin/rake +9 -0
- data/fixtures/rails5/bin/setup +34 -0
- data/fixtures/rails5/bin/spring +15 -0
- data/fixtures/rails5/bin/update +29 -0
- data/fixtures/rails5/config.ru +5 -0
- data/fixtures/rails5/config/application.rb +15 -0
- data/fixtures/rails5/config/boot.rb +3 -0
- data/fixtures/rails5/config/cable.yml +9 -0
- data/fixtures/rails5/config/database.yml +25 -0
- data/fixtures/rails5/config/environment.rb +5 -0
- data/fixtures/rails5/config/environments/development.rb +54 -0
- data/fixtures/rails5/config/environments/production.rb +86 -0
- data/fixtures/rails5/config/environments/test.rb +42 -0
- data/fixtures/rails5/config/initializers/application_controller_renderer.rb +6 -0
- data/fixtures/rails5/config/initializers/assets.rb +11 -0
- data/fixtures/rails5/config/initializers/backtrace_silencers.rb +7 -0
- data/fixtures/rails5/config/initializers/cookies_serializer.rb +5 -0
- data/fixtures/rails5/config/initializers/filter_parameter_logging.rb +4 -0
- data/fixtures/rails5/config/initializers/inflections.rb +16 -0
- data/fixtures/rails5/config/initializers/mime_types.rb +4 -0
- data/fixtures/rails5/config/initializers/new_framework_defaults.rb +24 -0
- data/fixtures/rails5/config/initializers/session_store.rb +3 -0
- data/fixtures/rails5/config/initializers/wrap_parameters.rb +14 -0
- data/fixtures/rails5/config/locales/en.yml +23 -0
- data/fixtures/rails5/config/puma.rb +47 -0
- data/fixtures/rails5/config/routes.rb +8 -0
- data/fixtures/rails5/config/secrets.yml +22 -0
- data/fixtures/rails5/config/spring.rb +6 -0
- data/fixtures/rails5/db/migrate +1 -0
- data/fixtures/rails5/db/schema.rb +41 -0
- data/fixtures/rails5/db/seeds.rb +7 -0
- data/fixtures/rails5/lib/assets/.keep +0 -0
- data/fixtures/rails5/lib/tasks/.keep +0 -0
- data/fixtures/rails5/log/.keep +0 -0
- data/fixtures/rails5/public/404.html +67 -0
- data/fixtures/rails5/public/422.html +67 -0
- data/fixtures/rails5/public/500.html +66 -0
- data/fixtures/rails5/public/apple-touch-icon-precomposed.png +0 -0
- data/fixtures/rails5/public/apple-touch-icon.png +0 -0
- data/fixtures/rails5/public/favicon.ico +0 -0
- data/fixtures/rails5/public/robots.txt +5 -0
- data/fixtures/rails5/test/controllers/.keep +0 -0
- data/fixtures/rails5/test/fixtures/.keep +0 -0
- data/fixtures/rails5/test/fixtures/files/.keep +0 -0
- data/fixtures/rails5/test/helpers/.keep +0 -0
- data/fixtures/rails5/test/integration/.keep +0 -0
- data/fixtures/rails5/test/mailers/.keep +0 -0
- data/fixtures/rails5/test/models/.keep +0 -0
- data/fixtures/rails5/test/test_helper.rb +26 -0
- data/fixtures/rails5/tmp/.keep +0 -0
- data/fixtures/rails5/vendor/assets/javascripts/.keep +0 -0
- data/fixtures/rails5/vendor/assets/stylesheets/.keep +0 -0
- data/fixtures/sinatra_test/db/migrate +1 -0
- data/fixtures/sinatra_test/models +1 -0
- data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +1 -0
- data/fixtures/sinatra_test/test/functional/users_controller_test.rb +1 -0
- data/fixtures/sinatra_test/views +1 -0
- data/lib/rabl.rb +1 -1
- data/lib/rabl/configuration.rb +1 -1
- data/lib/rabl/digestor.rb +3 -37
- data/lib/rabl/digestor/rails3.rb +10 -0
- data/lib/rabl/digestor/rails41.rb +10 -0
- data/lib/rabl/digestor/rails5.rb +4 -0
- data/lib/rabl/engine.rb +1 -1
- data/lib/rabl/version.rb +1 -1
- metadata +99 -3
- data/fixtures/ashared/views_rails_3/users/phone_number.xml.rabl +0 -8
- data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +0 -108
- data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +0 -87
- data/fixtures/rails2/test/functionals/posts_controller_test.rb +0 -108
- data/fixtures/rails2/test/functionals/users_controller_test.rb +0 -87
- data/fixtures/rails3/test/functional/posts_controller_test.rb +0 -108
- data/fixtures/rails3/test/functional/users_controller_test.rb +0 -87
- data/fixtures/rails3_2/test/functional/posts_controller_test.rb +0 -263
- data/fixtures/rails3_2/test/functional/users_controller_test.rb +0 -87
- data/fixtures/rails4/test/functional/posts_controller_test.rb +0 -248
- data/fixtures/rails4/test/functional/users_controller_test.rb +0 -87
- data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +0 -108
- data/fixtures/sinatra_test/test/functional/users_controller_test.rb +0 -87
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rails secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: 30ff78db787c4ed0bb6cd6c12108dadd9adc955263a563ad43a0d1308aa03b1a541b96bdd09f4461c7c4d75e14f54df506f4bb0dac9ca45c4ef95f133e031185
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 6bca541a67e4fec74dbdf0f83055ca79b2bc628240957763dd0f5cf3dd191736bf1e04bcd2a545a5bc6a2902a0643c88de0fb88ddf4c5d56cb877f2557074d79
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/rails5/db/../../ashared/migrate
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 20111002092024) do
|
14
|
+
|
15
|
+
create_table "phone_numbers", force: :cascade do |t|
|
16
|
+
t.integer "user_id"
|
17
|
+
t.boolean "is_primary"
|
18
|
+
t.string "area_code"
|
19
|
+
t.string "prefix"
|
20
|
+
t.string "suffix"
|
21
|
+
t.string "name"
|
22
|
+
end
|
23
|
+
|
24
|
+
create_table "posts", force: :cascade do |t|
|
25
|
+
t.integer "user_id"
|
26
|
+
t.string "title"
|
27
|
+
t.text "body"
|
28
|
+
t.datetime "created_at"
|
29
|
+
t.datetime "updated_at"
|
30
|
+
end
|
31
|
+
|
32
|
+
create_table "users", force: :cascade do |t|
|
33
|
+
t.string "username"
|
34
|
+
t.string "email"
|
35
|
+
t.string "location"
|
36
|
+
t.boolean "is_admin"
|
37
|
+
t.datetime "created_at"
|
38
|
+
t.datetime "updated_at"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
|
7
|
+
# Character.create(name: 'Luke', movie: movies.first)
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Load Silence Functionality
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../test/silence.rb")
|
3
|
+
|
4
|
+
# Load Environment
|
5
|
+
silence_warnings do
|
6
|
+
ENV["RAILS_ENV"] = "test"
|
7
|
+
require File.expand_path('../../config/environment', __FILE__)
|
8
|
+
require 'rails/test_help'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Load Riot Test Environment
|
12
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../test/integration/test_init.rb")
|
13
|
+
|
14
|
+
# Run Migrations
|
15
|
+
silence_stream(STDOUT) do
|
16
|
+
dbconf = YAML::load(File.open('config/database.yml'))[Rails.env]
|
17
|
+
ActiveRecord::Base.establish_connection(dbconf)
|
18
|
+
ActiveRecord::Base.logger = Logger.new(File.open('log/database.log', 'a'))
|
19
|
+
silence_stream(STDOUT) { ActiveRecord::Migrator.up('db/migrate') }
|
20
|
+
end
|
21
|
+
|
22
|
+
class Riot::Situation
|
23
|
+
def app
|
24
|
+
Rails.application
|
25
|
+
end
|
26
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/sinatra_test/db/../../ashared/migrate
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/sinatra_test/../ashared/models
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/sinatra_test/test/functional/../../../../test/integration/posts_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/sinatra_test/test/functional/../../../../test/integration/users_controller_test.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
fixtures/sinatra_test/../ashared/views/
|
data/lib/rabl.rb
CHANGED
@@ -16,7 +16,7 @@ require 'rabl/configuration'
|
|
16
16
|
require 'rabl/renderer'
|
17
17
|
require 'rabl/cache_engine'
|
18
18
|
|
19
|
-
if defined?(Rails)
|
19
|
+
if defined?(Rails) && Rails.respond_to?(:version)
|
20
20
|
require 'rabl/tracker' if Rails.version =~ /^[45]/
|
21
21
|
require 'rabl/digestor' if Rails.version =~ /^[45]/
|
22
22
|
require 'rabl/railtie' if Rails.version =~ /^[345]/
|
data/lib/rabl/configuration.rb
CHANGED
data/lib/rabl/digestor.rb
CHANGED
@@ -3,45 +3,11 @@ module Rabl
|
|
3
3
|
# Override the original digest function to ignore partial which
|
4
4
|
# rabl doesn't use the Rails conventional _ symbol.
|
5
5
|
if Gem::Version.new(Rails.version) >= Gem::Version.new('5.0.0.beta1')
|
6
|
-
|
7
|
-
|
8
|
-
options.assert_valid_keys(:dependencies, :partial)
|
9
|
-
|
10
|
-
cache_key = ([ name ].compact + Array.wrap(options[:dependencies])).join('.')
|
11
|
-
|
12
|
-
# this is a correctly done double-checked locking idiom
|
13
|
-
# (Concurrent::Map's lookups have volatile semantics)
|
14
|
-
finder.digest_cache[cache_key] || @@digest_monitor.synchronize do
|
15
|
-
finder.digest_cache.fetch(cache_key) do # re-check under lock
|
16
|
-
begin
|
17
|
-
# Prevent re-entry or else recursive templates will blow the stack.
|
18
|
-
# There is no need to worry about other threads seeing the +false+ value,
|
19
|
-
# as they will then have to wait for this thread to let go of the @@digest_monitor lock.
|
20
|
-
|
21
|
-
pre_stored = finder.digest_cache.put_if_absent(cache_key, false).nil? # put_if_absent returns nil on insertion
|
22
|
-
|
23
|
-
finder.digest_cache[cache_key] = stored_digest = Digestor.new(name, finder, options).digest
|
24
|
-
ensure
|
25
|
-
# something went wrong or ActionView::Resolver.caching? is false, make sure not to corrupt the @@cache
|
26
|
-
finder.digest_cache.delete_pair(cache_key, false) if pre_stored && !stored_digest
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
6
|
+
require 'rabl/digestor/rails5'
|
31
7
|
elsif Gem::Version.new(Rails.version) >= Gem::Version.new('4.1')
|
32
|
-
|
33
|
-
cache_key = [options[:name]] + Array.wrap(options[:dependencies])
|
34
|
-
@@cache[cache_key.join('.')] ||= begin
|
35
|
-
Digestor.new({ :name => options[:name], :finder => options[:finder] }.merge!(options)).digest
|
36
|
-
end
|
37
|
-
end
|
8
|
+
require 'rabl/digestor/rails41'
|
38
9
|
else
|
39
|
-
|
40
|
-
cache_key = [name, format] + Array.wrap(options[:dependencies])
|
41
|
-
@@cache[cache_key.join('.')] ||= begin
|
42
|
-
Digestor.new(name, format, finder, options).digest
|
43
|
-
end
|
44
|
-
end
|
10
|
+
require 'rabl/digestor/rails3'
|
45
11
|
end
|
46
12
|
|
47
13
|
private
|