DiffResource
Installation
Add this line to your application's Gemfile:
gem 'diff_resource'
And then execute:
$ bundle
Or install it yourself as:
$ gem install diff_resource
Usage
To output your resource file's diff list, you run under command.
Usage:
diff_resource create <directory> <comparison> <file> <type> [<options>]
Options:
- -o, [--output=OUTPUT] : output file path.
- -c, [--compare=COMPARE] : comparison target type. other directory or git object
- -s, [--setting=SETTING] : setting file path
Arguments:
- directory: resource file root path
- comparison: compare directory path or git hash
- file: resource file name format ex) test.resource, *.resource, *-en.resource
- type: resource file type. you can set custom type in .diffresource.yml
You should run on git root directory when using git mode.
To show detail, you run under command.
diff_resource help create
Settings File Format
To create custom resource type and set custom default option value, you create ".diffresource.yml" as the following.
types:
custom-resource : # custom resource type name
format: "xml" # file format. xml, json, yaml are enable value
root : "data" # resources object name. if object is nested, you set path split "."
key : "key" # resource name. * means resources object is hash
value : "value" # resource value
comparison: "dir" # custom comparison value
output: "./dir" # custom output value
It is enable to parse like these format resources.
<?xml version="1.0" encoding="utf-8"?>
<root>
<data key="string1">
<value>hello</value>
</data>
<data key="string2">
<value>hello hello</value>
</data>
</root>
Case resources object is nested, you should set path split "." as the following.
types:
custom-resource :
format: "json"
root : "root.data"
key : "key"
value : "value"
It is enable to parse like these format resources.
{
"root" :{
"data" : [
{
"key" : "string1",
"value" : "hello"
},
{
"key" : "string2",
"value" : "hello hello"
}
]
}
}
Case resources object is hash, you should set "*" to key as the following.
types:
custom-resource :
format: "yaml"
root : "root.data"
key : "*"
It is enable to parse like these format resources.
root:
data:
string1: "hello"
string2: "hello hello"
Contributing
- Fork it ( https://github.com/katsugeneration/diff-resource/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request