agris 0.3.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64629354ccada6a381efe8aa942ced5079b6ee4d
4
- data.tar.gz: ab9f6e49adf01f310a25d30c2677cd96fb6da522
3
+ metadata.gz: c4a37ad8828bb3a6ac7c28a8e55b4460e0ffc961
4
+ data.tar.gz: '0419d656ee2f4ab40f80ad968315a130d3bbba5c'
5
5
  SHA512:
6
- metadata.gz: 18d1d0e8345d9b2c425a279a3f88e32ada1a3708b10b6d5af134a6699398138b8b7b0e1e23bb176ca8a5b3e824601db4d7a683e8c83d9aec323ee8576275d163
7
- data.tar.gz: 6d4b4e8dc43c3b70975fac6e87e829e350f6df6592fc3d7ad4595753bfabd81feac412665a3d47f4d2130bea212081d8fa5d355f3fc0f3080ee275243e770aba
6
+ metadata.gz: d09c4a8df40edb4aad9328b4fd43adf63368cb77afcf4e22cfed8c376309a17eee5b544be3cabb58977c478043d245d94bc1cfebbcfcdb6abcedbc0c6466d983
7
+ data.tar.gz: 65b76fc1d00b600b79037e4b42e69be9e2f8984f62ef957eedfe5306c9aa1ce4feef94f6960edb524014edde0bb3e67e06f42a365bbb67ca5b1eca30c387a616
@@ -3,7 +3,7 @@ module Agris
3
3
  module Api
4
4
  module Grain
5
5
  module CommodityCodes
6
- def commodity_code(location, code)
6
+ def commodity_code(location = '', code = '')
7
7
  extract = Agris::Api::Grain::SpecificCommodityCodeExtract
8
8
  .new(location, code)
9
9
 
@@ -80,6 +80,18 @@ module Agris
80
80
  end
81
81
  end
82
82
 
83
+ def self.from_json_hash(hash)
84
+ super.tap do |contract|
85
+ if hash['schedules']
86
+ contract.schedules.concat(
87
+ hash['schedules'].map do |schedule|
88
+ Schedule.from_json_hash(schedule)
89
+ end
90
+ )
91
+ end
92
+ end
93
+ end
94
+
83
95
  def initialize(hash = {})
84
96
  super
85
97
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Agris
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
  end
@@ -40,9 +40,12 @@ module Agris
40
40
  end
41
41
 
42
42
  module ClassMethods
43
+ def from_json_hash(hash)
44
+ Object.const_get(name).new(hash)
45
+ end
46
+
43
47
  def from_xml_hash(hash)
44
48
  klass = Object.const_get(name)
45
-
46
49
  attribute_map =
47
50
  klass::ATTRIBUTE_NAMES
48
51
  .each_with_object({}) do |name, new_hash|
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Gray
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-05-24 00:00:00.000000000 Z
12
+ date: 2018-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  version: '0'
227
227
  requirements: []
228
228
  rubyforge_project:
229
- rubygems_version: 2.6.14
229
+ rubygems_version: 2.6.14.1
230
230
  signing_key:
231
231
  specification_version: 4
232
232
  summary: Ruby client library for Agris API