skeleton_creator
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Gem used for generating skeleton file and directory structures
= File structure creator

Script to facilitate quick and easy creation of complex directory/file structures.


== YAML config file

Create a YAML directory structure file 
The structure should be similar to the examples in config-files, links.yml shows how to define symbolic links

By default any leaf node results in a File being created. 

root:
  meta: ONLY_DIRS
  a:
    - bee
    - cee

Here a is created as a dir, with bee and cee as empty files 

To override this, postfix entry with DIR, fx
  - my_dir DIR 

Example: DIR
  root:
    a:
      - bee DIR
      - cee

Here a and bee are created as a dirs, while cee is an empty file 

===  Special meta data

If you want all nodes in a tree to be created as dirs, supply a meta: in the root of the tree 

meta: ONLY_DIRS 

This will ensure all the following nodes in the tree are treated as dirs, until a REVERT is encountered (see below)

Example: ONLY_DIRS

root:
  meta: ONLY_DIRS
  a:
    - bee
    - cee

Here bee and cee are created as dirs

Example: 
Using ONLY_DIRS and REVERT

root:
  - ONLY_DIRS
  - bee
  - cee
  - REVERT
  - dee
  - 
    eee:
      meta: ONLY_DIRS
        x:
         - y
         - z

Here bee and cee will be created as dirs while dee and eee become empty files. Later y and x also are dirs because of the meta: ONLY_DIRS

Symbolic links:

apps:
  category: &app-category
    - games ALIAS c-games
    - business
    - utils 
    - other
  all: &app-runtype
    - my_games REF c-games 

Here an alias c-games is created for the entry apps/category/games
Later the symbolic link my-games is created to point at whatever the alias c-games currently points to, in this case apps/category/games
An alias can be overridden later... this is illustrated below.

apps:
  category: &app-category
    - games ALIAS c-games
    - business
    - my_games REF c-games 
    - other
    - cool-games ALIAS c-games
  all: &app-runtype
    - my_cool_games REF c-games 

Results in this:

my_games --> (c-games) --> games
my_cool_games --> (c-games) --> cool-games
    
== Usage

Use the following ruby code as a 'template'. As shown, the options argument is optional
 
  require 'skeleton_creator'

  runner = FileSystem::Runner.new file_name [, options]
  runner.run root_dir [, options]

Fx to generate the skeleton structure inside ~/testing as per the apps.yml file 
  runner = FileSystem::Runner.new 'apps.yml'
  runner.run "~/testing"

OR using fake file and directory creators to simulate first 
  runner = FileSystem::Runner.new 'apps.yml', :fake => true
  runner.run "~/testing"
  runner.run "~/testing2"

OR
  runner = FileSystem::Runner.new 'apps.yml'
  runner.run "~/testing"
  runner.run "~/testing2", :fake => true

The options :fake is false by default. Setting it on the call to run overrides the initial value (set with Runner.new) for that particular run

OR
  runner.run ["testing2", "testing4"], :fake => true, :root => '~'

Creates dirs in '~/testing2' and '~/testing4' 

== Note on Patches/Pull Requests
 
* Fork the project.
* Make your feature addition or bug fix.
* Add tests 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

Copyright (c) 2010 Kristian Mandrup. See LICENSE for details.

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。