Giter Site home page Giter Site logo

master_delivery's Introduction

Gem Version

MasterDelivery

MasterDelivery is a master file manager utility. MasterDelivery delivers all master files managed in a single master snapshot directory into the specified directory while maintaining the hierarchy of the master snapshot directory. If the destination file already exists, back it up first and then deliver the master file.

The difference with rsync is that MasterDelivery creates a symlinks instead of copying the master files. They are symlinks, so you have to keep in mind that you have to keep the master files in the same location, but it also has the advantage that the master file is updated at the same time when you directly make changes to the delivered file.

Do you have any experience that the master file is getting old gradually? MasterDelivery can prevent this.

If the master directory is git or svn managed, you can manage revisions of files that are delivered here and there at once with commands like git diff and git commit.

Example

If you specify command line arguments MASTER_DIR and DELIVERY_ROOT as follows:

$ master_delivery -m ~/master/my_home_setting -d /Users/foo

This means:

(-m) MASTER_DIR:   -m ~/master/my_home_setting
(-d) DELIVER_ROOT: -d /Users/foo

and suppose master files now in MASTER_DIR are as follows:

~/master/my_home_setting/.zshrc
~/master/my_home_setting/work/.rubocop.yml

then these files will be delivered as the following files:

/Users/foo/.zshrc
/Users/foo/work/.rubocop.yml

Installation

Add this line to your application's Gemfile:

gem 'master_delivery'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install master_delivery

Usage

Usage: master_delivery -m <dir> -d <dir> [options]
 Required:
    -m, --master [MASTER_DIR]        Master snapshot directory. All master files in this
                                     directory will be placed in the "delivery root",
                                     maintaining the directory structure.
                                     Only regular files will be delivered. That is,
                                     all symbolic link files and empty directories in
                                     MASTER_DIR are ignored.
    -d, --delivery [DELIVERY_ROOT]   Delivery root, or destination directory. All master
                                     files will be placed in this while maintaining the master
                                     directory structure.

 Optional:
    -t, --type [DELIVERY_TYPE]       Delivery type. "symbolic_link" or "regular_file" is accepted.
                                     Master files will be delivered as symbolic links (ln -s)
                                     or regular files (cp).
                                      (default: symbolic_link)
    -b, --backup [BACKUP_ROOT]       Backup root, or Evacuation destination directory.
                                     All current active files will be moved into this
                                     directory maintaining the directory structure.
                                     Backup root will be created automatically. (mkdir -p)
                                      (defualt: MASTER_DIR/../backup)
    -D, --[no-]dryrun                Instead of actually moving or copying files, display
                                     the commands on stderr.
                                     We strongly recommend "--dryrun" before running.
                                      (default: --no-dryrun)
    -q, --[no-]quiet                 Suppress non-error messages
                                      (default: --no-quiet)
    -v, --[no-]verbose               Process actual commands for file operations, such as
                                     moving files and creating folders, one by one.
                                      (default: --no-verbose)
    -y, --[no-]yes                   Skip confirmation. It is recommended to execute
                                     the command carefully without skipping confirmation.
                                     With the "--yes" option, if you want to change the
                                     command line argument even a little, remove the
                                     "--yes" option once, execute it several times,
                                     and experience confirmation several times.
                                     Also, it's a good idea to add the "--yes" option
                                     only after you start to feel confirmation annoying.
                                      (default: --no-yes)

 Common options:
    -h, --help                       Show this message
    -V, --version                    Show version

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome!

  1. Fork it ( https://github.com/shinyaohtani/master_delivery )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the MasterDelivery project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

master_delivery's People

Contributors

shinyaohtani avatar shinya-ohtani avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar

master_delivery's Issues

v1.0.3 release

  • Option to suppress non-error message
  • Described the difference with rsync on README.md

Avoid slash duplication of delivery_root when -d '/'

(-m) MASTER_DIR:   -m /Users/shinya.ohtani/unix/cloned/work-public/unix-conf (2 master files)
(-d) DELIVER_ROOT: -d /
(-t) DELIVER_TYPE: -t symbolic_link
(-b) BACKUP_ROOT:  -b /Users/shinya.ohtani/unix/cloned/work-public/tmp
(-D) DRYRUN:       --no-dryrun

Sample (from 2 master files):
master:            /Users/shinya.ohtani/unix/cloned/work-public/unix-conf/opt/brew/etc/logrotate.d/screenlog.conf
will be delivered: //opt/brew/etc/logrotate.d/screenlog.conf
 and backup:       /Users/shinya.ohtani/unix/cloned/work-public/tmp/unix-conf-original-XXXX/opt/brew/etc/logrotate.d/screenlog.conf
done!

Option to carefully trace delivery commands one by one

Now in dryrun mode, you can understand what commands are executed and in what order. Even if you actually run it instead of dryrun mode, such a display makes it easier to trace where the problem occurred.

-v, --verbose

v1.0.1 release

  • First release
  • All methods are implemented
  • Tested by hand.

Option to skip confirmation

Checking is tedious if master_delivery is called from another script. There should be an option to skip.

-y, --yes

Option to suppress messages

master_delivery carefully displays the parameters before execution, and also displays the execution image using a sample. In many cases, such kind of support makes it possible to execute commands with peace of mind and feels convenient. However, when it's used by other scripts with the same argument every time, it feels inconvenient because there is too much information.

-q, --quiet

v1.0.6 release

  • Verbose mode has been introduced to trace delivery commands!

Test code should be prepared

Now master_delivery and MasterDelivery doesn't have test code. This is not an appropriate development. Test code should be prepared immediately

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.