casual-api 3.0.4 → 3.0.5
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/casual.rb +5 -2
- data/lib/dsl.rb +19 -2
- 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: 27624cbb80045ccfb0314a36d4219020df61eb69
|
4
|
+
data.tar.gz: 8d3589a94eaa990792dd309cdc68589d391b9031
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 073ebb071c6a17fa68ef6df11a358dd9b013e1eb8be506f2cf7907b3c3ff064128309ec7696722a66e3ae1089a88714466d18b7455096fce768e5d86428c7e77
|
7
|
+
data.tar.gz: b401e0577583eb7ce467781a5046ab38efb89b5ef893a86b8e345be047a6968415067df2dadbbca835fd1c9fc3ced04f63004edbdfe29adda59506d95759cf03
|
data/lib/casual.rb
CHANGED
@@ -33,8 +33,11 @@ module CasualAPI
|
|
33
33
|
end
|
34
34
|
def check_upload_file
|
35
35
|
unless @action[:parameters].all?{|k,v|
|
36
|
-
next false if v[:is_file] ^
|
37
|
-
next false if v[:as_file] &&
|
36
|
+
next false if v[:is_file] ^Action.is_file?(Hash)
|
37
|
+
next false if v[:as_file] && Action.is_file?(Hash)
|
38
|
+
next false if v[:is_array] ^ @params[k].is_a?(Array)
|
39
|
+
next false if v[:is_hash] && !Action.is_file?(@params[k]) && !@params[k].is_a?(Hash)
|
40
|
+
next false if !v[:is_hash] && !Action.is_file?(@params[k]) && @params[k].is_a?(Hash)
|
38
41
|
true
|
39
42
|
}
|
40
43
|
raise InvalidParameterError, "Invalid parameter(s)"
|
data/lib/dsl.rb
CHANGED
@@ -50,7 +50,7 @@ module CasualAPI
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def file? file
|
53
|
-
|
53
|
+
Action.is_file? file
|
54
54
|
end
|
55
55
|
|
56
56
|
def tempfile file
|
@@ -85,6 +85,11 @@ module CasualAPI
|
|
85
85
|
obj
|
86
86
|
end
|
87
87
|
|
88
|
+
def self.is_file? param
|
89
|
+
param.is_a?(Hash) && param[:tempfile] && param[:tempfile].is_a?(Tempfile)
|
90
|
+
end
|
91
|
+
|
92
|
+
|
88
93
|
private
|
89
94
|
def self.execute(obj, ps, action)
|
90
95
|
ps = to_as_file(obj, ps, action)
|
@@ -111,7 +116,7 @@ module CasualAPI
|
|
111
116
|
ps
|
112
117
|
end
|
113
118
|
def self.tempfile(obj,file)
|
114
|
-
if
|
119
|
+
if Action.is_file? file
|
115
120
|
file[:tempfile].path
|
116
121
|
else
|
117
122
|
f = Tempfile.open(SecureRandom.hex(4))
|
@@ -138,6 +143,14 @@ module CasualAPI
|
|
138
143
|
@context_stack.last[:tempfile] ||= []
|
139
144
|
@context_stack.last[:tempfile].push(*files)
|
140
145
|
end
|
146
|
+
def is_array *params
|
147
|
+
@context_stack.last[:is_array] ||= []
|
148
|
+
@context_stack.last[:is_array].push(*params)
|
149
|
+
end
|
150
|
+
def is_hash *params
|
151
|
+
@context_stack.last[:is_hash] ||= []
|
152
|
+
@context_stack.last[:is_hash].push(*params)
|
153
|
+
end
|
141
154
|
|
142
155
|
def description(param1, param2=nil)
|
143
156
|
@context_stack.last[:description] ||= {}
|
@@ -152,6 +165,8 @@ module CasualAPI
|
|
152
165
|
@context_stack.last.delete(:is_file)
|
153
166
|
@context_stack.last.delete(:as_file)
|
154
167
|
@context_stack.last.delete(:tempfile)
|
168
|
+
@context_stack.last.delete(:is_array)
|
169
|
+
@context_stack.last.delete(:is_hash)
|
155
170
|
@context_stack.last.delete(:description)
|
156
171
|
end
|
157
172
|
end
|
@@ -261,6 +276,8 @@ PROC
|
|
261
276
|
is_file: (hs[:is_file]||[]).include?(n),
|
262
277
|
as_file: (hs[:as_file]||[]).include?(n),
|
263
278
|
tempfile: (hs[:tempfile]||[]).include?(n),
|
279
|
+
is_array: (hs[:is_array]||[]).include?(n),
|
280
|
+
is_hash: (hs[:is_hash]||[]).include?(n),
|
264
281
|
}
|
265
282
|
}
|
266
283
|
}.inject({}, :merge)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: casual-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takeshi Kojima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|