cjheath / activefacts-compositions Goto Github PK
View Code? Open in Web Editor NEWCreate and represent composite schemas, schema transforms and data transforms over a fact-based model
License: MIT License
Create and represent composite schemas, schema transforms and data transforms over a fact-based model
License: MIT License
Consider allowing JSON v2
Running schema_compositor
does nothing (appears to be a synonym for /bin/true
).
A usage message / suggestion to try --help
would probably be better.
Running schema_compositor --help
tells me there are a variety of compositors and generators, but not how to invoke them.
It would aid usage if the help message started with something like:
Usage: schema_compositor --<compositor> --<generator> [cql file]
Currently files get # Auto-generated from CQL, edits will be lost
prepended to them.
I propose starting them with:
# Auto-generated from 'bundle exec schema_compositor --relational=surrogates --rails/models=concern=Relations,output=app/models/relations warehouse.cql', edits will be lost
.
My repo: https://gist.github.com/DanielHeath/eba77378b400ebc876e24625e0c661cf
This contains the latest released version of activefacts-compositions and dependencies, and the CinemaTickets model.
$ schema_compositor --binary --rails/models CinemaTickets.cql
gems/activefacts-compositions-1.9.19/lib/activefacts/generator/rails/models.rb:129:in `model_key': undefined method `all_index_field' for nil:NilClass (NoMethodError)
from gems/activefacts-compositions-1.9.19/lib/activefacts/generator/rails/models.rb:143:in `model_body'
from gems/activefacts-compositions-1.9.19/lib/activefacts/generator/rails/models.rb:106:in `generate_composite'
from gems/activefacts-compositions-1.9.19/lib/activefacts/generator/rails/models.rb:47:in `block in generate'
from gems/activefacts-compositions-1.9.19/lib/activefacts/generator/rails/models.rb:47:in `map'
from gems/activefacts-compositions-1.9.19/lib/activefacts/generator/rails/models.rb:47:in `generate'
from gems/activefacts-compositions-1.9.19/bin/schema_compositor:129:in `block (2 levels) in process_files'
from gems/activefacts-compositions-1.9.19/bin/schema_compositor:128:in `each'
from gems/activefacts-compositions-1.9.19/bin/schema_compositor:128:in `block in process_files'
from gems/activefacts-compositions-1.9.19/bin/schema_compositor:85:in `each'
from gems/activefacts-compositions-1.9.19/bin/schema_compositor:85:in `process_files'
from gems/activefacts-compositions-1.9.19/bin/schema_compositor:195:in `<top (required)>'
from bin/schema_compositor:23:in `load'
from bin/schema_compositor:23:in `<main>'
Steps to reproduce:
bundle exec schema_compositor
Steps to reproduce
afgen # in enviroment with no byebug installed
LoadError: cannot load such file -- byebug
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/activefacts-compositions-1.9.18/lib/activefacts/generator/doc/glossary.rb:11:in `require'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/activefacts-compositions-1.9.18/lib/activefacts/generator/doc/glossary.rb:11:in `<top (required)>'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/activefacts-compositions-1.9.18/bin/afcomp:41:in `require'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/activefacts-compositions-1.9.18/bin/afcomp:41:in `block (2 levels) in enumerate_available'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/activefacts-compositions-1.9.18/bin/afcomp:39:in `select'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/activefacts-compositions-1.9.18/bin/afcomp:39:in `block in enumerate_available'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/tracing-2.0.8/lib/tracing.rb:292:in `trace'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/activefacts-compositions-1.9.18/bin/afcomp:36:in `enumerate_available'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/activefacts-compositions-1.9.18/bin/afcomp:183:in `<top (required)>'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/bin/afcomp:23:in `load'
/kita/world/ruby-2.5.0/lib/ruby/gems/2.5.0/bin/afcomp:23:in `<top (required)>'
its a trivial fix, but I've noticed that glossary generator requires byebug, but its never listed as a dependecy.
Further more there are 2 references to "debugger" in code also with no mention of which debugger is being used
example cql
vocabulary Warehousing;
Transfer Request ID is written as Auto Counter;
Warehouse ID is written as Auto Counter;
Transfer Request is identified by its ID;
Warehouse is identified by its ID;
Transfer Request is from one Warehouse (as Origin);
Transfer Request is to one Warehouse (as Destination);
running
schema_compositor --relational --rails/models Warehousing.cql
results in following
module TransferRequest
extend ActiveSupport::Concern
included do
self.primary_key = 'transfer_request_id'
# Transfer Request is to Destination
belongs_to :destination, :class_name => 'Warehouse', :foreign_key => :destination_warehouse_id
# Transfer Request is from Origin
belongs_to :origin, :class_name => 'Warehouse', :foreign_key => :origin_warehouse_id
end
end
module Warehouse
extend ActiveSupport::Concern
included do
self.primary_key = 'warehouse_id'
# Transfer Request is to Destination
has_many :transfer_requests, :class_name => 'TransferRequest', :foreign_key => :destination_warehouse_id, :dependent => :destroy
# Transfer Request is from Origin
has_many :transfer_requests, :class_name => 'TransferRequest', :foreign_key => :origin_warehouse_id, :dependent => :destroy
end
end
there are two has many transport_requests relationships being generated.
could we use roles ( i think they are called roles )
eg transfer_requests_as_origin and transfer_requests_as_destinations
it doesnt sound good from english point of view, perhaps this has_many relationship is not useful, but
has_many :destinations, :through => :transfer_requests_as_destinations, :source => :destination
( i might have got names wrong ( need cofee ))
but basic idea, for a given warehouse, give me all warehouses that I sent stuff to as relationship 1, and give me all warehouses that sent stuff to us as relationship 2.
Hope this makes sense
It'd be good to generate all these things to separate files in a sensible directory, so the rails autoloader could find it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.