Skip to content

Instantly share code, notes, and snippets.

@bertBruynooghe
Last active December 11, 2015 03:58
Show Gist options
  • Save bertBruynooghe/4541273 to your computer and use it in GitHub Desktop.
Save bertBruynooghe/4541273 to your computer and use it in GitHub Desktop.
# -*- coding: UTF-8 -*-
# RAILS_VERSION 3.2.11
require 'yaml'
require 'json'
config = ::YAML::load <<EOS
---
name: Anthos Invoicing
tasks:
instances:
tasks:
domain: anthos
project: invoicing
controller:
valid:
proceed:
valid: true
invalid:
proceed:
invalid: true
save:
update: params
dispute:
proceed:
reject: true
dispute: params
approve:
proceed:
approved: true
types:
data_validation:
actions:
valid:
call: valid
caption: Valid
style: btn-success
approve_level1:
actions:
approve:
call: approve
caption: Approve
style: btn-success
approve_level2:
actions:
approve:
call: approve
caption: Approve
style: btn-success
approve_customer:
actions:
approve:
call: approve
caption: Approve
style: btn-success
documents:
instances:
archive:
repository_id: anthos
folder_id: fs77wqinrplbn3dhcaifchecptm
document_type_id: factuur
properties:
- leverancier_naam
- leverancier_contactpersoon
- leverancier_btwnummer
- leverancier_adres_straat
- leverancier_adres_gemeente
- leverancier_adres_postcode
- leverancier_adres_landcode
- leverancier_email
- leverancier_telefoonnummer
- leverancier_rekeningnummer
- klant_naam
- klant_contactpersoon
- klant_btwnummer
- klant_adres_straat
- klant_adres_gemeente
- klant_adres_postcode
- klant_adres_landcode
- klant_email
- klant_telefoonnummer
- klant_klantnummer
- document_type
- document_nummer
- document_totaal
- document_netto
- document_btw
- document_po
- document_vervaldatum
- document_betaaltermijn
- document_referentie
- document_naam
- document_scandatum
- document_factuurdatum
- document_valuta
users:
[email protected]:
permissions:
- can_proceed_data_validation
[email protected]:
permissions:
- can_proceed_approve_level1
[email protected]:
permissions:
- can_proceed_approve_level2
[email protected]:
permissions:
- can_proceed_approve_customer
EOS
### Setup ###
prepend_to_file 'Gemfile', "source Bundler.settings['upnxt_gem_server'] if Bundler.settings['upnxt_gem_server']\n"
gem 'upnxt_frontend_rich_modules', path: "../upnxt/frontend/rich/modules"
run 'bundle install'
run "rails generate upnxt_frontend_rich_modules:install '#{config['name']}'"
### Tasks ###
tasks = config['tasks']
generate 'upnxt_frontend_rich_modules:tasks_install'
tasks['instances'].each { |key, i| run "rails generate upnxt_frontend_rich_modules:tasks_instance #{key} #{i['domain']} #{i['project']} '#{i['controller'].to_json}'" }
tasks['types'].each { |type, data| run "rails generate upnxt_frontend_rich_modules:task_type #{type} --config '#{data.to_json}'" }
### Documents ###
documents = config['documents']
generate 'upnxt_frontend_rich_modules:documents_install'
documents['instances'].each do |key, i|
run "rails generate upnxt_frontend_rich_modules:documents_instance #{key} #{i['repository_id']} #{i['folder_id']} #{i['document_type_id']}"
run "rails generate upnxt_frontend_rich_modules:document_properties #{key} #{i['properties'].join(' ')}"
end
### Users ###
config['users'].each { |email, user| run "rails generate upnxt_frontend_rich_modules:create_user #{email} #{user['permissions'].join(' ')}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment