figa 0.1.0 → 0.2.1

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.
Files changed (5) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +1 -1
  4. data/lib/figa.rb +17 -7
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6711826553277276616030f1bd03f3661fdb4f2d
4
- data.tar.gz: 839c8010b513be67b475ddc66faab9e046d27b60
2
+ SHA256:
3
+ metadata.gz: 5e6443f0b74492be0f1da32b193a2970ccda2ba5e021c1e246504fc4cba55a54
4
+ data.tar.gz: 8d65147f47ed38ecfd72af3afe3359628bb8ab17d86d188f2b3d104cb7b92c59
5
5
  SHA512:
6
- metadata.gz: 7f5710c727d6a221f0d846574ae75d81fe0d51ad8b690480e9c163025b0cf17c61d6bc4c6519158bc1080dae98170555ee33a263bc3696ff4bb0ecc292936750
7
- data.tar.gz: 1210ffc9cff8af805336b6ec2be04b2c5e2ab2067a1e9369816ed41b25e5720c9d9f1ac17f3c0d576b12a79188a89f2d4f5590aa531d11bf0b8f26f83eb84585
6
+ metadata.gz: 21d756f6efe4a3bc9e22b9bc0fa7bee382419502ca42913b604634a42cbebf82b3181d7d75cfea634a9b29a3bcf5be594b2d637dcd678063ff7f825b21823c02
7
+ data.tar.gz: c5d654fd4c3c01afebdcfc4134def98719731e75b044066d48886bcfeab2a798c19d3439e257f5da5b19bb681dfa8b5f8f2baaac04100e66fec5a68ebb7a26cb
@@ -2,6 +2,17 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## figa 0.2.1 released 2019-08-13
6
+
7
+ * re-release
8
+
9
+
10
+ ## figa 0.2.0 released 2019-08-12
11
+
12
+ * Load enum values at client instantiation
13
+ * Align user agent on avantage
14
+
15
+
5
16
  ## figa 0.1.0 released 2019-06-14
6
17
 
7
18
  * Refine Figa::Client #map and #search
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/figa.svg)](http://badge.fury.io/rb/figa)
5
5
 
6
- A Ruby library to query [OpenFIGI](https://www.openfigi.com/) API v2.
6
+ A Ruby library to query [OpenFIGI](https://www.openfigi.com/) API [v2](https://www.openfigi.com/api#v2).
7
7
 
8
8
 
9
9
  ## usage
@@ -5,17 +5,19 @@ require 'net/http'
5
5
 
6
6
  module Figa
7
7
 
8
- VERSION = '0.1.0'
8
+ VERSION = '0.2.1'
9
9
 
10
- USER_AGENT = "Figa - https://github.com/jmettraux/figa - #{VERSION}"
10
+ USER_AGENT = "figa #{VERSION} - https://github.com/jmettraux/figa"
11
11
  API_ROOT_URI = 'https://api.openfigi.com/v2'
12
12
 
13
13
  class Client
14
14
 
15
+ attr_reader :enum_values
16
+
15
17
  def initialize(api_key=nil)
16
18
 
17
19
  @api_key = api_key
18
- @enum_values = {}
20
+ @enum_values = load_enum_values
19
21
  end
20
22
 
21
23
  def map(array_or_hash)
@@ -43,7 +45,7 @@ module Figa
43
45
 
44
46
  a = aoh.is_a?(Array) ? aoh : [ aoh ]
45
47
 
46
- id_types = enum_values('idType')
48
+ id_types = @enum_values['idType']
47
49
 
48
50
  a.collect do |h|
49
51
 
@@ -72,9 +74,15 @@ module Figa
72
74
  ENUM_KEYS = %w[
73
75
  idType exchCode micCode currency marketSecDes securityType securityType2 ]
74
76
 
75
- def enum_values(key)
77
+ # def enum_values(key)
78
+ #
79
+ # @enum_values[key] ||= get('/mapping/values/' + key)['values']
80
+ # end
81
+
82
+ def load_enum_values
76
83
 
77
- @enum_values[key] ||= get('/mapping/values/' + key)['values']
84
+ ENUM_KEYS
85
+ .inject({}) { |h, k| h[k] = get("/mapping/values/#{k}")['values']; h }
78
86
  end
79
87
 
80
88
  def validate(h)
@@ -88,7 +96,7 @@ module Figa
88
96
 
89
97
  fail ArgumentError.new(
90
98
  "value #{v.inspect} is not a valid value for key #{k.inspect}"
91
- ) unless enum_values(sk).include?(v)
99
+ ) unless @enum_values[sk].include?(v)
92
100
  end
93
101
  end
94
102
 
@@ -122,6 +130,8 @@ module Figa
122
130
  #t.set_debug_output($stdout) if uri.match(/search/)
123
131
 
124
132
  res = t.request(req)
133
+ #p res.class
134
+ #res.each_header { |h| p [ h, res.header[h] ] }
125
135
 
126
136
  j = JSON.parse(res.body)
127
137
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: figa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-14 00:00:00.000000000 Z
11
+ date: 2019-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  version: '0'
63
63
  requirements: []
64
64
  rubyforge_project:
65
- rubygems_version: 2.5.2.3
65
+ rubygems_version: 2.7.6
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: A Ruby client to the OpenFIGI API v2