Reflection is designed to keep your development system in sync with your production system’s files and database (by dumping). It uses a shared git repository to store these files, which allows you to mirror your production environment without the need of direct access to your production servers.
It provides two main command modes:
-
Stash: Indented to be run on the server side, adds a specified directory and, optionally, a database dump to a shared Git repository
-
Apply: To be used on a local development machine, gets content from the repository, copies it to a specified directory and optionally loads the database dump into your local database
Reflection is a gem, hosted on Gemcutter:
gem install reflection
$ reflection --stash --directory /path/to/your/assets --repository [email protected]
This will clone [email protected]
and add the directory /path/to/your/assets
to the repository. Reflection keeps a local version of your repository in HOME/.reflection/stash. So the next time you run the command, there is no need of cloning it again.
$ reflection --stash \ --directory /path/to/your/assets \ --repository [email protected] \ --rails /rails/root \ --rails-env production
This does the same as above, but additionally dumps your production database and adds the fresh dump to your repository.
You too, aren’t you? So Reflection allows you to store all command line options in a config file.
$ reflection --stash \ --directory /path/to/your/assets \ --repository [email protected] \ --rails /rails/root \ --rails-env production \ --write /path/to/your/config
The next time you want to run the same command as above (useful for cron), you could simply call Reflection with:
$ reflection /path/to/your/config
This works exactly the same as describe above, but you would use –apply instead of –stash:
$ reflection --apply \ --directory /path/to/your/assets \ --repository [email protected] \ --rails /rails/root \ --rails-env development
This clones or pulls [email protected]
(again, Reflection keeps a version of your Repository in HOME/.reflection/apply), copies the content to the specified directory (e.g. rails/application/public/assets) and optionally loads the dump into your database.
As you may have noticed, the Reflection command above got called with --rails-env development
, which loads the dump in your development database (as defined by /rails/root/config/database.yml).
If you have a reflection.yml
config file in your current application-development-directory, syncing your server-production environment is as easy as running:
$ reflection
$ reflection --help Usage: reflection --COMMAND --repository=GIT_REPO --directory=PATH -or- Usage: reflection /path/to/reflection-config-file.yml On the server side: -s, --stash Store your assets and/or a database dump in a git-repository. On the client side: -a, --apply Apply assets and/or a database dump loaded from a git-repository. Required options for both: -r, --repository GIT_URL A Git repository(url) to be used as storage -d, --directory PATH Path to your asset directory Additional options for both: --rails [RAILS_ROOT] Enable dumping/applying of a Rails managed MySQL database --rails-env [ENV] Rails environment to instrument --write [FILE] Create a configuration FILE from the current commandline options --force Hide tedious warnings -v, --verbose Include debug information in output --version Show version
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add specs for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2009 Andreas Wolff. See LICENSE for details.