Skip to content

Generates an ActiveRecord ready object from a yml-mapping base on csv-row data

Notifications You must be signed in to change notification settings

installero/declarative_mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

Install a gem

gem 'declarative_mapper'
bundle install

or

gem install declarative_mapper

Usage

require 'declarative_mapper`
require 'csv'
require 'yaml'

require_relative 'lib/declarative_mapper'

Dir["reliable/**/*.rb"].each { |file| require_relative file }

csv_path = "#{__dir__}/reliable/accounts.csv"
csv_table = CSV.parse(File.read(csv_path), headers: true)
csv_row = csv_table.first

yml_path = "#{__dir__}/reliable/customers.yml"
yml_content = YAML.load_file(yml_path).deep_symbolize_keys

mapper_methods = Reliable::MapperMethods::Customers

customer_attrs = DeclarativeMapper.convert(mapper_methods, yml_content[:mapping], csv_row)

puts customer_attrs.inspect

About

Generates an ActiveRecord ready object from a yml-mapping base on csv-row data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published