dataflow-rb 0.10.0 → 0.10.1

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: 5ccef7eb0d8bf531e4e19c62562763dff31f85f4
4
- data.tar.gz: 9c5e496748df17dcc3fd41ea90c4c3b5dd4df43a
3
+ metadata.gz: 414f1c416fbd86a60fbc37db119f2c34a511486a
4
+ data.tar.gz: 2c63094740e4fcde2dddfdd7344c3fd90b1893b5
5
5
  SHA512:
6
- metadata.gz: 2c62ef0c24df46a551d5a90bd8d7cf4b6b4ece57bbfd3dad720c7399b4b325ae949d10f3f644403413f2534f1ae08ae797dcaf8d925bea28d2da8b23c7ca0b3a
7
- data.tar.gz: 95f0b3764d07d39cb15ef06a5fcea00e71942d02560b0b4e3475adf3a83b8b70d719f42d260decb496ad44668cdc3947fc32567b84b7eb0fd5a35b0e356e97a0
6
+ metadata.gz: '028244e631dd52380ebbe9fc4a3b2c9709ee97e883becbadf07d1cd0142a34de4aacb6e497f5572e04bd41ba9f7b4131134039c8a5c428f499a57690f4e72c76'
7
+ data.tar.gz: 3f22f68c3f703749b0b2d54bb98210081efbcca2c48dd4272f5b08f478c78d504ba97c15a52eca4129e569e03cc8a961fc6d01254dfef135a436c1d9993b5418
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "dataflow"
4
+ require "dataflow-rb"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
data/lib/dataflow-rb.rb CHANGED
@@ -47,7 +47,7 @@ require 'dataflow/nodes/filter/where_node'
47
47
  require 'dataflow/nodes/transformation/to_time_node'
48
48
 
49
49
  unless defined?(Rails) || Mongoid.configured?
50
- env = defined?(RSpec) ? 'test' : 'default'
50
+ env = ENV['MONGOID_ENV'] || 'default'
51
51
  # setup mongoid for stand-alone usage
52
52
  config_file_path = File.join(File.dirname(__FILE__), 'config', 'mongoid.yml')
53
53
  Mongoid.load!(config_file_path, env)
@@ -320,6 +320,8 @@ module Dataflow
320
320
  index['unique'] = true if idx[:unique]
321
321
  index
322
322
  end.compact
323
+ rescue Sequel::DatabaseError
324
+ []
323
325
  end
324
326
 
325
327
  def logger
@@ -16,7 +16,7 @@ module Dataflow
16
16
 
17
17
  delegate :find, :all, :all_paginated, :count, :ordered_system_id_queries,
18
18
  :db_backend, :db_name, :use_symbols?,
19
- :schema, :read_dataset_name, :write_dataset_name,
19
+ :read_dataset_name, :write_dataset_name,
20
20
  to: :data_node
21
21
 
22
22
  #############################################
@@ -300,6 +300,11 @@ module Dataflow
300
300
  release_computing_lock!
301
301
  end
302
302
 
303
+ # Keep a compatible interface with the data node
304
+ def schema
305
+ required_schema
306
+ end
307
+
303
308
  private
304
309
 
305
310
  # Compute implementation:
@@ -390,7 +395,7 @@ module Dataflow
390
395
 
391
396
  # Override to define a required schema.
392
397
  def required_schema
393
- schema
398
+ data_node&.schema
394
399
  end
395
400
 
396
401
  def send_heartbeat
@@ -35,9 +35,9 @@ module Dataflow
35
35
 
36
36
  # merge both dependencies schemas
37
37
  sch1 = dependencies.first.schema || {}
38
- sch1 = sch1.select { |k,v| select_keys1.include?(k) } if select_keys1.present?
38
+ sch1 = sch1.select { |k,v| select_keys1.include?(k.to_s) } if select_keys1.present?
39
39
  sch2 = dependencies.second.schema || {}
40
- sch2 = sch2.select { |k,v| select_keys2.include?(k) } if select_keys2.present?
40
+ sch2 = sch2.select { |k,v| select_keys2.include?(k.to_s) } if select_keys2.present?
41
41
  sch = sch1.merge(sch2)
42
42
 
43
43
  sch
@@ -15,16 +15,15 @@ module Dataflow
15
15
  private
16
16
 
17
17
  def compute_batch(records:)
18
- k = keys
19
- k = k.map(&:to_sym) if dependencies.first.use_symbols?
20
- select_keys(records: records, keys: k)
18
+ keys_tokens = keys.map { |k| [k, record_dig_tokens(key: k, use_sym: dependencies.first.use_symbols?)] }
19
+ select_keys(records: records, keys_tokens: keys_tokens)
21
20
  end
22
21
 
23
- def select_keys(records:, keys:)
22
+ def select_keys(records:, keys_tokens:)
24
23
  records.map do |base_record|
25
24
  new_record = {}
26
- keys.each do |key|
27
- value = record_value(record: base_record, key: key)
25
+ keys_tokens.each do |key, tokens|
26
+ value = base_record.dig(*tokens)
28
27
  next unless value.present?
29
28
 
30
29
  add_value_to_record(record: new_record, key: key, value: value)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Dataflow
3
- VERSION = '0.10.0'
3
+ VERSION = '0.10.1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dataflow-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eurico Doirado
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-03 00:00:00.000000000 Z
11
+ date: 2017-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler