agris 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/.hound-rubocop.yml +0 -76
- data/.rubocop.yml +0 -2
- data/Rakefile +3 -1
- data/agris.gemspec +0 -1
- data/lib/agris.rb +1 -2
- data/lib/agris/api/document_query_response.rb +0 -1
- data/lib/agris/api/support.rb +0 -1
- data/lib/agris/process_message_response.rb +2 -2
- data/lib/agris/version.rb +1 -1
- data/lib/agris/xml_model.rb +2 -1
- data/lib/hash.rb +65 -0
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4d090ac08f37e8b68e3c5573667111b9f42f1b7
|
4
|
+
data.tar.gz: 2bb7298c5c672b810b2c35c50c0be3dd205660dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21762b562cff9392c8976854e4b3c52dab34b00f2900ac764b93dddd16f38a585baba01e6f11c0b8466a84ec1e90bf4a83fc4d259ac59078ec34b77e0bdb2b4c
|
7
|
+
data.tar.gz: 2dce9ba1d5a2f50502c091da42a3372c8c4593b5165681c45d5aca1dec5a08ce91b826562ddac2c0a9d571857d3567fd87975333b4d4db9b5e0a89928d98826c
|
data/.hound-rubocop.yml
CHANGED
@@ -241,79 +241,3 @@ Lint/LiteralInCondition:
|
|
241
241
|
Lint/LiteralInInterpolation:
|
242
242
|
Description: Checks for literals used in interpolation.
|
243
243
|
Enabled: false
|
244
|
-
|
245
|
-
##################### Rails ##################################
|
246
|
-
|
247
|
-
Rails/ActionFilter:
|
248
|
-
Description: 'Enforces consistent use of action filter methods.'
|
249
|
-
Enabled: true
|
250
|
-
Rails/Date:
|
251
|
-
Description: >-
|
252
|
-
Checks the correct usage of date aware methods,
|
253
|
-
such as Date.today, Date.current etc.
|
254
|
-
Enabled: true
|
255
|
-
Rails/Delegate:
|
256
|
-
Description: 'Prefer delegate method for delegations.'
|
257
|
-
Enabled: true
|
258
|
-
Rails/Exit:
|
259
|
-
Description: >-
|
260
|
-
Favor `fail`, `break`, `return`, etc. over `exit` in
|
261
|
-
application or library code outside of Rake files to avoid
|
262
|
-
exits during unit testing or running in production.
|
263
|
-
Enabled: true
|
264
|
-
Rails/FindBy:
|
265
|
-
Description: 'Prefer find_by over where.first.'
|
266
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
|
267
|
-
Enabled: true
|
268
|
-
Rails/FindEach:
|
269
|
-
Description: 'Prefer all.find_each over all.find.'
|
270
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find-each'
|
271
|
-
Enabled: true
|
272
|
-
Rails/HasAndBelongsToMany:
|
273
|
-
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
274
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
|
275
|
-
Enabled: true
|
276
|
-
Rails/HttpPositionalArguments:
|
277
|
-
Description: 'Rails 5 only, disabled to keep Hound quiet'
|
278
|
-
Enabled: false
|
279
|
-
Rails/NotNullColumn:
|
280
|
-
Description: 'Do not add a NOT NULL column without a default value'
|
281
|
-
Enabled: false
|
282
|
-
Rails/Output:
|
283
|
-
Description: 'Checks for calls to puts, print, etc.'
|
284
|
-
Enabled: true
|
285
|
-
Rails/OutputSafety:
|
286
|
-
Description: 'The use of `html_safe` or `raw` may be a security risk.'
|
287
|
-
Enabled: true
|
288
|
-
Rails/PluralizationGrammar:
|
289
|
-
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
|
290
|
-
Enabled: true
|
291
|
-
Rails/ReadWriteAttribute:
|
292
|
-
Description: >-
|
293
|
-
Checks for read_attribute(:attr) and
|
294
|
-
write_attribute(:attr, val).
|
295
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#read-attribute'
|
296
|
-
Enabled: true
|
297
|
-
Rails/RequestReferer:
|
298
|
-
Description: 'Use consistent syntax for request.referer.'
|
299
|
-
Enabled: true
|
300
|
-
Rails/SafeNavigation:
|
301
|
-
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
|
302
|
-
Enabled: true
|
303
|
-
Rails/ScopeArgs:
|
304
|
-
Description: 'Checks the arguments of ActiveRecord scopes.'
|
305
|
-
Enabled: true
|
306
|
-
Rails/TimeZone:
|
307
|
-
Description: 'Checks the correct usage of time zone aware methods.'
|
308
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
|
309
|
-
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
310
|
-
Enabled: true
|
311
|
-
Rails/UniqBeforePluck:
|
312
|
-
Description: 'Prefer the use of uniq or distinct before pluck.'
|
313
|
-
Enabled: true
|
314
|
-
Rails/Validation:
|
315
|
-
Description: 'Use validates :attribute, hash of validations.'
|
316
|
-
Enabled: true
|
317
|
-
Security/JSONLoad:
|
318
|
-
Description : 'Prefer usage of JSON.parse'
|
319
|
-
Enabled: true
|
data/.rubocop.yml
CHANGED
data/Rakefile
CHANGED
data/agris.gemspec
CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_dependency 'activesupport', '~> 5.0'
|
25
24
|
spec.add_dependency 'savon', '~> 2.11'
|
26
25
|
|
27
26
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
data/lib/agris.rb
CHANGED
data/lib/agris/api/support.rb
CHANGED
@@ -10,7 +10,7 @@ module Agris
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def error?
|
13
|
-
ag_error_str_p.
|
13
|
+
!ag_error_str_p.to_s.strip.empty?
|
14
14
|
end
|
15
15
|
|
16
16
|
def error_info
|
@@ -18,7 +18,7 @@ module Agris
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def error_hash
|
21
|
-
@error_hash ||= Hash.from_xml(ag_error_str_p)
|
21
|
+
@error_hash ||= error? ? Hash.from_xml(ag_error_str_p) : {}
|
22
22
|
end
|
23
23
|
|
24
24
|
def output_hash
|
data/lib/agris/version.rb
CHANGED
data/lib/agris/xml_model.rb
CHANGED
@@ -25,8 +25,9 @@ module Agris
|
|
25
25
|
|
26
26
|
def to_xml_hash
|
27
27
|
ignore_attributes = (xml_ignore_attributes + [:hash]).map(&:to_s)
|
28
|
+
match_attributes = attributes.keys - ignore_attributes
|
28
29
|
attributes
|
29
|
-
.
|
30
|
+
.select { |key, _value| match_attributes.include?(key) }
|
30
31
|
.each_with_object({}) do |(name, value), new_hash|
|
31
32
|
new_hash["@#{name.delete('_')}".to_sym] = value
|
32
33
|
new_hash
|
data/lib/hash.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
class Hash
|
6
|
+
class << self
|
7
|
+
def from_xml(xml_io)
|
8
|
+
result = Nokogiri::XML(xml_io)
|
9
|
+
|
10
|
+
{ key_value(result.root) => xml_node_to_hash(result.root) }
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def xml_node_to_hash(node)
|
16
|
+
# If we are at the root of the document, start the hash
|
17
|
+
return node.content.to_s unless node.element?
|
18
|
+
|
19
|
+
result_hash = {}
|
20
|
+
if node.attributes != {}
|
21
|
+
attributes = {}
|
22
|
+
node.attributes.each_key do |key|
|
23
|
+
attributes[
|
24
|
+
key_value(node.attributes[key])
|
25
|
+
] = node.attributes[key].value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
return attributes if node.children.empty?
|
30
|
+
|
31
|
+
node.children.each do |child|
|
32
|
+
result = xml_node_to_hash(child)
|
33
|
+
|
34
|
+
if child.name == 'text'
|
35
|
+
unless child.next_sibling || child.previous_sibling
|
36
|
+
return result unless attributes
|
37
|
+
result_hash[key_value(child)] = result
|
38
|
+
end
|
39
|
+
elsif result_hash[key_value(child)]
|
40
|
+
|
41
|
+
if result_hash[key_value(child)].is_a?(Object::Array)
|
42
|
+
result_hash[key_value(child)] << result
|
43
|
+
else
|
44
|
+
result_hash[key_value(child)] = [
|
45
|
+
result_hash[key_value(child)]
|
46
|
+
] << result
|
47
|
+
end
|
48
|
+
else
|
49
|
+
result_hash[key_value(child)] = result
|
50
|
+
end
|
51
|
+
end
|
52
|
+
if attributes
|
53
|
+
# Add code to remove non-data attributes e.g. xml schema, namespace
|
54
|
+
# here, if there is a collision then node content supersets
|
55
|
+
# attributes
|
56
|
+
result_hash = attributes.merge(result_hash)
|
57
|
+
end
|
58
|
+
result_hash
|
59
|
+
end
|
60
|
+
|
61
|
+
def key_value(node)
|
62
|
+
node.name
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agris
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Gray
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: activesupport
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '5.0'
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '5.0'
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: savon
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,6 +180,7 @@ files:
|
|
194
180
|
- lib/agris/user_agent.rb
|
195
181
|
- lib/agris/version.rb
|
196
182
|
- lib/agris/xml_model.rb
|
183
|
+
- lib/hash.rb
|
197
184
|
homepage: https://github.com/westernmilling/agris.rb
|
198
185
|
licenses:
|
199
186
|
- MIT
|