LVS-JSONService 0.4.1 → 0.4.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.
- data/.specification +1 -1
- data/LVS-JSONService.gemspec +1 -1
- data/VERSION +1 -1
- data/lib/lvs/json_service/base.rb +50 -1
- metadata +2 -2
data/.specification
CHANGED
data/LVS-JSONService.gemspec
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
@@ -97,7 +97,7 @@ module LVS
|
|
97
97
|
options[:auth_key] = @auth_key if @auth_key
|
98
98
|
options[:auth_key_pass] = @auth_key_pass if @auth_key_pass
|
99
99
|
|
100
|
-
(class<<self;self;end).send :define_method, service_name do
|
100
|
+
(class<<self;self;end).send :define_method, service_name do |*args|
|
101
101
|
method_params, flags = args
|
102
102
|
|
103
103
|
method_params ||= {}
|
@@ -171,11 +171,60 @@ module LVS
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
+
def to_s
|
175
|
+
str = ""
|
176
|
+
str << self.class.name + " 0x#{object_id.to_s(16)}\n"
|
177
|
+
@data.each do |key,value|
|
178
|
+
str << data_to_s(key, value, 2)
|
179
|
+
end
|
180
|
+
str
|
181
|
+
end
|
182
|
+
|
183
|
+
def data_to_s(key, value, indent=2, lead=nil)
|
184
|
+
method = key.underscore
|
185
|
+
if method[/date$/]
|
186
|
+
(" " * indent) + "#{lead}#{method}: #{self.send(method.to_sym)}\n"
|
187
|
+
elsif value.is_a?(Fixnum) || value.is_a?(Float)
|
188
|
+
(" " * indent) + "#{lead}#{method}: #{value}\n"
|
189
|
+
elsif value.is_a?(String)
|
190
|
+
(" " * indent) + "#{lead}#{method}: \"#{value}\"\n"
|
191
|
+
elsif value.is_a?(Hash)
|
192
|
+
sub_data = ""
|
193
|
+
subindent = indent + 2
|
194
|
+
value.each do |key, value|
|
195
|
+
sub_data << data_to_s(key, value, subindent)
|
196
|
+
unless lead.blank?
|
197
|
+
subindent += lead.length
|
198
|
+
lead = nil
|
199
|
+
end
|
200
|
+
end
|
201
|
+
(" " * indent) + "#{lead}#{method}:\n#{sub_data}"
|
202
|
+
elsif value.is_a?(Array)
|
203
|
+
sub_data = ""
|
204
|
+
value.each_with_index do |subvalue, index|
|
205
|
+
subindent = indent + 2
|
206
|
+
sub_data << data_to_s("#{index}", subvalue, subindent)
|
207
|
+
unless lead.blank?
|
208
|
+
subindent += lead.length
|
209
|
+
lead = nil
|
210
|
+
end
|
211
|
+
end
|
212
|
+
(" " * indent) + "#{lead}#{method}: [\n#{sub_data}" + (" " * indent) + "]\n"
|
213
|
+
elsif method[/^has_/]
|
214
|
+
(" " * indent) + "#{lead}#{method}: \"#{value ? 'true' : 'false'}\"\n"
|
215
|
+
else
|
216
|
+
(" " * indent) + "#{lead}#{method}: \"#{value.inspect}\"\n"
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
174
220
|
def method_missing(name, *args)
|
175
221
|
name = name.to_s
|
176
222
|
if name == "respond_to?" # don't know why this hack is necessary, but it is at the moment...
|
177
223
|
return respond_to?(args[0])
|
178
224
|
end
|
225
|
+
if name == "to_s" # don't know why this hack is necessary, but it is at the moment...
|
226
|
+
return to_s
|
227
|
+
end
|
179
228
|
key = name_to_key(name)
|
180
229
|
value = value_for_key(key)
|
181
230
|
if name =~ /=$/
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: LVS-JSONService
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LVS
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-08-06 00:00:00 +
|
13
|
+
date: 2009-08-06 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|