rest_dsl 0.1.1 → 0.1.2
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/rest_dsl/dsl.rb +8 -19
- data/lib/rest_dsl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44c4e15596a19b17765538e7c867c8541e499937414adce0e8d9a3877c8bf070
|
4
|
+
data.tar.gz: 6d4c7c10d868dd18cf7c62641762f466dc92a1749878c831bfb5c4cec09db222
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc625f1de6e41dd9349bd5ad7e4014b034ea530bbd709b588f14b8530862477f6c79d08e0675ea7da9fff58c07f0d485adfd842f4b701d485404208b65abcb3e
|
7
|
+
data.tar.gz: d3baa1afa50243b953b78716d23339602ab8767eb78e2ae4e5c153b79ef6e6db625021f5d38b7e8a71a884713be308f493bd9f6fd9eea5e791a1aef2a185ebfc
|
data/lib/rest_dsl/dsl.rb
CHANGED
@@ -13,30 +13,19 @@ module RestDSL
|
|
13
13
|
module DSLExtensions
|
14
14
|
|
15
15
|
##
|
16
|
-
# Adds a DSL method for parsing information from a file, parser list can be overridden by
|
17
|
-
#
|
16
|
+
# Adds a DSL method for parsing information from a file, parser list can be overridden by redefining file_parsers
|
17
|
+
# If no parser is designed, for the file extension, loads the file as plain text
|
18
18
|
module FromFile
|
19
19
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.included(clazz)
|
30
|
-
clazz.instance_eval do
|
31
|
-
@file_parsers = {
|
32
|
-
%w[.json] => JSON,
|
33
|
-
%w[.yml .yaml] => Psych
|
34
|
-
}
|
35
|
-
end
|
20
|
+
def file_parsers
|
21
|
+
{
|
22
|
+
%w[.json] => JSON,
|
23
|
+
%w[.yml .yaml] => Psych
|
24
|
+
}
|
36
25
|
end
|
37
26
|
|
38
27
|
def from_file(file_name)
|
39
|
-
parser =
|
28
|
+
parser = file_parsers.find{|key, _| key.any? {|file_type| file_name.include? file_type}}[1]
|
40
29
|
result = if parser.eql?(Psych)
|
41
30
|
parser.load_file(file_name)
|
42
31
|
else # Most non-yaml parsers in ruby work like the json one so lets make it be the default.
|
data/lib/rest_dsl/version.rb
CHANGED