Merge Source Files from Directories in Chain
Concept
Import source files from a chain of application modules.
Synposis
Put a configuration file .app_stack.yml in your application
directory, in format like:
stack_dir: '../'
The directory contains other modules to import.
stack:
- module-1
- module-2: [defaults, tests]
- module-3:
- defaults
- file_a.html: file_a.htm
- file_b.txt: ''
Define three modules to import (in directory ../module-1, ...). Accord to the
above setting, stack_app will copy default set of files exported by module-1,
the default and tests set of files from module-2 (file sets defined as string
in array), and defaults set of files from module-3, plus file_a.html copied
as file_a.htm and file_b.txt copied as it is (single files defined as a hash).
exclude:
- config/*
- filename_2
Do not copy config/* and single file filename_2 from the stack.
export:
- lib/**/*.rb
- app/**/*.rb
- tests:
- spec/**/*.rb
When used as a stack module, export the above files where ruby files under lib/
and app are in the defaults set, besides with the tests set.
attrs:
application_name: App Name
application_code: app_code
database_password: the very secret
gems:
default:
- rspec: '~> 2.0.0'
- ...
development:
attrs can be inserted into .erb files.
stack_dir: '../'
Define directory where the source code of stack modules located. Default is ../
tpl_ext: ['.erb', '.haml', '.liquid']
Default as above (refer to document below).
Then run:
$ stackup [config_file]
Default configuration file is .app_stack.yml
Command line options:
-h, --helpshow help message--verboseshow more informations-s, --simulateonly show the copy list, do not actually copy-f, --forceforce overwrite new files (only import new file and ask for updated files by default)
Copy Precedence
For a module chain a, b, c, ..., files exported by b will over-write
the same files exported by a and so on.
If you want the files defined in a, manually copy it to the local directory
and set it to exclude list.
Note: exclude means 'use local file if exists, otherwise copy it', not
'do not copy it'.
Template
If defined to export, for example Gemfile, and also defined a Gemfile.erb,
the later will be used as a template to render Gemefile.
For a module chain a, b, c, ..., attrs defined in c will merged into
attrs defined in b ... and then assigned into the erb template.
App_stack use tilt to support .erb, .haml and .liquid, if a file have
more than one template defined, the later will silently over-write the former.
You can change the order in tpl_ext setting.