schema-inference 1.0.1 → 1.1.0

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: 87db62e086b2960cdd977b7fabf4bec2ed76208c
4
- data.tar.gz: 5608adcf41da8f8f4dff6e5a5cc6a14bc0f0ef86
3
+ metadata.gz: e783c172078cf4000dc5efabd8d5ad85cc3072ff
4
+ data.tar.gz: b84bdc0aa7c1cfaec9e6228f70c60e070fffe30f
5
5
  SHA512:
6
- metadata.gz: 1c8610b4386a6519a3356d2c2364ccf3f29052a76ed664466955f026eb255af8a3525ad26eadc553732e0f686a38b97d2626440d2e2bccfe1818e8e59572f7cd
7
- data.tar.gz: 51e065edbe235b0224e3ed32d362b4d1f7bb5f7d8dc8e21afa620ed291690249cb3a4b2e32e9bfff663f1789c49a8ea5a0b24476a6029a5fce7456172d31253f
6
+ metadata.gz: 9157d2db16ed2b70a6d731f11d363e976a914635dffe32fe1a750576890e3cca675ef844bb34c48ffce19696d7fc7d3826f3e82696a0c5549d5d63176359d950
7
+ data.tar.gz: b97153fe64406c10783f28d90e94e3f66a246138c4abeb2bb002cb359f807a211215ca16f6068d74fc74346c3a801eabb354c21c9f42271dc4c48fadc262845b
@@ -3,8 +3,9 @@ module Schema
3
3
  class SchemaInferrer
4
4
  attr_accessor :separator
5
5
 
6
- def initialize(separator: '.')
6
+ def initialize(separator: '.', convert_types_to_string: false)
7
7
  @separator = separator
8
+ @convert_types_to_string = convert_types_to_string
8
9
  end
9
10
 
10
11
  # Generate a schema based on this collection's records.
@@ -148,7 +149,7 @@ module Schema
148
149
  table_schema[k][:usage] = table_schema[k][:usage_count] / total_count.to_f
149
150
  }
150
151
 
151
- table_schema
152
+ @convert_types_to_string ? convert_types_to_string(table_schema) : table_schema
152
153
  end
153
154
 
154
155
  NumericTypes = [Numeric, Integer].freeze
@@ -232,6 +233,14 @@ module Schema
232
233
  (/^[+-]?[0-9]+$/ =~ value).present?
233
234
  end
234
235
 
236
+ def convert_types_to_string(schema)
237
+ schema.each { |k, v|
238
+ schema[k][:type] = schema[k][:type].to_s.downcase
239
+ schema[k][:types] = schema[k][:types].map { |k1,v1| [k1.to_s.downcase, v1] }.to_h
240
+ }
241
+ schema
242
+ end
243
+
235
244
  def parallel_map(itr, &block)
236
245
  # set to true to debug code in the iteration
237
246
  is_debugging_impl = ENV['DEBUG']
@@ -1,5 +1,5 @@
1
1
  module Schema
2
2
  module Inference
3
- VERSION = '1.0.1'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema-inference
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eurico Doirado
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-05 00:00:00.000000000 Z
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler