dslh 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90335d30a0a8550fac463effc4ae103bbc97ab2b
4
- data.tar.gz: a2baa307388a8d6bfdcafd7ef6be5c6b2990b7e7
3
+ metadata.gz: ba8a8dcc743beceda02fefe5c864909276880831
4
+ data.tar.gz: 60551002e3cc93d2d0e1a5ccc620a9ee722019ae
5
5
  SHA512:
6
- metadata.gz: b934b99328c9e461c3483cc24bbdf33e075709565ef87cfd0094c6b2a628fbe618e82623e28cadd5eb7e46e7ce64128a77578e053411e1c7067cc7f79c3098e7
7
- data.tar.gz: 0f8755ccfe03468c91243ecfc1c8edca6d8ad8f17e3aea5274579bd6e41faf93c0bebf7df995771fcde52be7322c843f36703f7dade283c1f82a3eb57f1a48ec
6
+ metadata.gz: 839419e273e655b10f0df3ba24470fdc16461e2605549d1f805a8a0b723e58c6db6f193815ee7d2f13b2d1f5bc57c000a0c2ab97c2f800efd85c5b4de5ad421f
7
+ data.tar.gz: 03421bff73686c0d7d6e176f28295d1727333bf031965ae4454f57ed2fe3218e279c52f8bccd3718b3c9d175622c423ce866dc424aeb6b88c14cbf9e7bfdf811
data/lib/dslh.rb CHANGED
@@ -145,6 +145,19 @@ class Dslh
145
145
  end
146
146
 
147
147
  errors = validator.validate(new_retval)
148
+
149
+ errors.each do |e|
150
+ path = e.path.split('/', 4)[1..-1]
151
+ root_key = path.shift
152
+ _id = path.shift.to_i
153
+
154
+ if _id_orig = new_retval.fetch(root_key, {})[_id]
155
+ _id = _id_orig['_id'] || _id
156
+ end
157
+
158
+ path = '/' + ([root_key, _id] + path).join('/')
159
+ e.path.replace(path)
160
+ end
148
161
  else
149
162
  errors = validator.validate(retval)
150
163
  end
data/lib/dslh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Dslh
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.3'
3
3
  end
data/spec/dslh_spec.rb CHANGED
@@ -3098,38 +3098,38 @@ mapping:
3098
3098
  sequence:
3099
3099
  - type: map
3100
3100
  mapping:
3101
- "_id":
3102
- type: str
3103
- required: yes
3104
- "code":
3105
- type: int
3106
- required: yes
3107
- "email":
3108
- type: str
3101
+ "_id":
3102
+ type: str
3103
+ required: yes
3104
+ "code":
3105
+ type: int
3106
+ required: yes
3107
+ "email":
3108
+ type: str
3109
3109
  "employees2":
3110
3110
  type: seq
3111
3111
  sequence:
3112
3112
  - type: map
3113
3113
  mapping:
3114
- "_id":
3115
- type: str
3116
- required: yes
3117
- "code":
3118
- type: int
3119
- required: yes
3120
- "email":
3121
- type: str
3114
+ "_id":
3115
+ type: str
3116
+ required: yes
3117
+ "code":
3118
+ type: int
3119
+ required: yes
3120
+ "email":
3121
+ type: str
3122
3122
  EOS
3123
3123
  end
3124
3124
 
3125
3125
  let(:expected_errmsg) do
3126
3126
  <<-EOS.chomp
3127
- [/employees/0/_id] '123': not a string.
3128
- [/employees/1/email] '100': not a string.
3129
- [/employees2/0] key 'code:' is required.
3130
- [/employees2/0/code1] key 'code1:' is undefined.
3131
- [/employees2/0/email1] key 'email1:' is undefined.
3132
- [/employees3] key 'employees3:' is undefined.
3127
+ [/employees/123/_id] '123': not a string.
3128
+ [/employees/bar/email] '100': not a string.
3129
+ [/employees2/foo2] key 'code:' is required.
3130
+ [/employees2/foo2/code1] key 'code1:' is undefined.
3131
+ [/employees2/foo2/email1] key 'email1:' is undefined.
3132
+ [/employees3/bar2] key 'employees3:' is undefined.
3133
3133
  EOS
3134
3134
  end
3135
3135
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dslh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara