rescue-dog 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -13
- data/lib/rescue/controller.rb +1 -1
- data/lib/rescue/controllers/flash.rb +5 -7
- data/lib/rescue/version.rb +1 -1
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a18b84c74e4bb5bb4a2c4784cc7e11232a57576
|
4
|
+
data.tar.gz: 2f76a69daa8f6c4d2f0ee866b67857b335100e2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c6a40788a4a2350f5dd3337f832ae7c3945837d2c24473ffca18376cdb3b1b2920aebb958f1b096b8fe7e2146da9db409884e698a8f796474788fc49ae200ce
|
7
|
+
data.tar.gz: 47b547e1994dc5e54d70247953db094d9f532d869a1b07e381afcdba5b2d90021b19680a6c2dbde0185839909d0597c072ae522533de92a32b652c6a18dcc719
|
data/README.md
CHANGED
@@ -8,23 +8,13 @@ The Rescue-Dog responds HTTP status (the code and message) when raises the excep
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
Add
|
11
|
+
Add "rescue-dog" gem to your `Gemfile`
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
gem 'rescue-dog'
|
15
15
|
```
|
16
16
|
|
17
|
-
And
|
18
|
-
|
19
|
-
```bash
|
20
|
-
$ bundle
|
21
|
-
```
|
22
|
-
|
23
|
-
Or install it yourself as:
|
24
|
-
|
25
|
-
```bash
|
26
|
-
$ gem install rescue-dog
|
27
|
-
```
|
17
|
+
And run `bundle install` command.
|
28
18
|
|
29
19
|
## Declare CRUD Actions
|
30
20
|
|
@@ -142,7 +132,7 @@ rescue_associate ActiveRecord::RecordNotFound ,with: 404
|
|
142
132
|
rescue_associate Mongoid::Errors::DocumentNotFound, BSON::InvalidObjectId, with: 404
|
143
133
|
```
|
144
134
|
|
145
|
-
Learn more usage, check [`spec`](https://github.com/yulii/rescue-dog/blob/master/spec/
|
135
|
+
Learn more usage, check [`spec`](https://github.com/yulii/rescue-dog/blob/master/spec/fake_rails.rb)
|
146
136
|
|
147
137
|
### Respond Application Error Codes
|
148
138
|
1. Include `Rescue::Controller::Dynamic` (NOT `Rescue::Controller::Static`).
|
data/lib/rescue/controller.rb
CHANGED
@@ -58,7 +58,7 @@ module Rescue
|
|
58
58
|
def rescue_controller clazz, *actions
|
59
59
|
options = actions.extract_options!
|
60
60
|
method_names = actions + options.keys
|
61
|
-
name = clazz.name.
|
61
|
+
name = clazz.name.underscore
|
62
62
|
|
63
63
|
[:show, :edit, :new].each do |type|
|
64
64
|
(options.delete(type)||[]).each do |name|
|
@@ -4,20 +4,18 @@ module Rescue
|
|
4
4
|
class Flash
|
5
5
|
|
6
6
|
def self.message object, key
|
7
|
-
scope =
|
8
|
-
scope += object.controller_path.split('/')
|
9
|
-
scope << object.action_name
|
10
|
-
scope << :flash
|
7
|
+
scope = "views.#{object.controller_path.gsub(%r{/}, '.')}.#{object.action_name}.flash"
|
11
8
|
text(key, scope)
|
12
9
|
end
|
13
10
|
|
11
|
+
# Private Methods
|
14
12
|
def self.default key
|
15
|
-
s = I18n.t(
|
13
|
+
s = I18n.t("default.flash.#{key}", default: '')
|
16
14
|
s.blank? ? nil : s
|
17
15
|
end
|
18
16
|
|
19
|
-
def self.text key, scope
|
20
|
-
s = I18n.t(key,
|
17
|
+
def self.text key, scope
|
18
|
+
s = I18n.t("#{scope}.#{key}", default: '')
|
21
19
|
s.blank? ? default(key) : s
|
22
20
|
end
|
23
21
|
private_class_method :default, :text
|
data/lib/rescue/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rescue-dog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yulii
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 4.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.0
|
27
27
|
description: Responds status and error handling for Rails
|
@@ -31,9 +31,9 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- .gitignore
|
35
|
-
- .rspec
|
36
|
-
- .travis.yml
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
36
|
+
- ".travis.yml"
|
37
37
|
- Gemfile
|
38
38
|
- LICENSE.txt
|
39
39
|
- README.md
|
@@ -85,17 +85,17 @@ require_paths:
|
|
85
85
|
- lib
|
86
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.2.2
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Declare simple CRUD and respond error methods
|
@@ -110,3 +110,4 @@ test_files:
|
|
110
110
|
- spec/rescue_spec.rb
|
111
111
|
- spec/spec_helper.rb
|
112
112
|
- spec/test_case.rb
|
113
|
+
has_rdoc:
|