moonrope 1.3.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/moonrope/dsl/structure_dsl.rb +1 -1
- data/lib/moonrope/errors.rb +10 -0
- data/lib/moonrope/eval_helpers.rb +22 -6
- data/lib/moonrope/structure.rb +2 -1
- data/lib/moonrope/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03ef56897296df607155e3db243142135a9934bb
|
4
|
+
data.tar.gz: 8d9e84279e48a610c54f791782993a54620eba6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea2654b89ef07c235e91b3c3e39a2333af2ef29dd2751d51518e377812f807adab86fc5844a92aeb9f382370743d7f1ae5f860c1679da5bf91ee4ab9f28e4c1e
|
7
|
+
data.tar.gz: 7f154d360c7da6dfa8fc7b0d246a874d666e9a4587ffb9db120d9edf6abbc0035b16bd7a7acc65237c1584353c5a93657f56bf4352f3c6f62fb38e1754c1e4b7
|
data/lib/moonrope/errors.rb
CHANGED
@@ -7,17 +7,33 @@ module Moonrope
|
|
7
7
|
# @param type [Symbol] the type of error to raise
|
8
8
|
# @param message [String, Hash or Array] options to pass with the error (usually a message)
|
9
9
|
#
|
10
|
-
def error(type, message)
|
10
|
+
def error(type, code_or_message, message = nil)
|
11
11
|
case type
|
12
|
-
when :not_found then raise(Moonrope::Errors::NotFound,
|
13
|
-
when :access_denied then raise(Moonrope::Errors::AccessDenied,
|
14
|
-
when :validation_error then raise(Moonrope::Errors::ValidationError,
|
15
|
-
when :parameter_error then raise(Moonrope::Errors::ParameterError,
|
12
|
+
when :not_found then raise(Moonrope::Errors::NotFound, code_or_message)
|
13
|
+
when :access_denied then raise(Moonrope::Errors::AccessDenied, code_or_message)
|
14
|
+
when :validation_error then raise(Moonrope::Errors::ValidationError, code_or_message)
|
15
|
+
when :parameter_error then raise(Moonrope::Errors::ParameterError, code_or_message)
|
16
|
+
when :structured_error then structured_error(code_or_message, message)
|
16
17
|
else
|
17
|
-
|
18
|
+
if type.is_a?(String)
|
19
|
+
structured_error(type, code_or_message, message.is_a?(Hash) ? message : {})
|
20
|
+
else
|
21
|
+
raise Moonrope::Errors::RequestError, code_or_message
|
22
|
+
end
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
26
|
+
#
|
27
|
+
# Raises a structured error.
|
28
|
+
#
|
29
|
+
# @param code [String] the code to return
|
30
|
+
# @param message [String] explantory text to return
|
31
|
+
# @param additional [Hash] additional data to return with the error
|
32
|
+
#
|
33
|
+
def structured_error(code, message, additional = {})
|
34
|
+
raise Moonrope::Errors::StructuredError, additional.merge(:code => code, :message => message)
|
35
|
+
end
|
36
|
+
|
21
37
|
#
|
22
38
|
# Return paginated information
|
23
39
|
#
|
data/lib/moonrope/structure.rb
CHANGED
@@ -83,7 +83,8 @@ module Moonrope
|
|
83
83
|
# Add the expansions
|
84
84
|
expansions.each do |name, expansion|
|
85
85
|
next if options[:expansions].is_a?(Array) && !options[:expansions].include?(name.to_sym)
|
86
|
-
|
86
|
+
next unless expansion[:conditions].all? { |condition| environment.instance_eval(&condition) }
|
87
|
+
DeepMerge.deep_merge!({name.to_sym => environment.instance_eval(&expansion[:block])}, hash)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
data/lib/moonrope/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moonrope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|