cookbook 'xml_file', '~> 0.3.0', :supermarket
xml_file (2) Versions 0.3.0 Follow1
Provides xml_file resource-provider
cookbook 'xml_file', '~> 0.3.0'
knife supermarket install xml_file
knife supermarket download xml_file
xml_file - Cookbook
xml_file
resource-provider to manage XML files.
Description
xml_file
resource allows managing XML files where only parts of the file's
content is controlled. Users can specify XPath
targets and expected content
at those targets.
Usage
xml_file
resource allows different attributes to specify
partial content.
- 'partial' attribute to add a XML fragments. Following example will
insert
part.xml
(present infiles/default
directory of the consumer cookbook) at '/parent/child' XPath target's last element. Content of whole.xmlxml <?xml version="1.0" encoding="UTF-8"?> <project name=""> <repo type="git"></repo> <maintainers> <maintainer>Hendrix</maintainer> <maintainer>Morrison</maintainer> </maintainers> <project>
Content of part.xml
xml
<issuetracker>
<name>Jira</name>
<url>http://example.com</url>
</issuetracker>
xml_file resource declaration:
ruby
xml_file '/opt/whole.xml' do
partial '//project', 'part.xml'
owner 'root'
group 'root'
mode 0644
end
will change whole.xml file to:
xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="">
<repo type="git"></repo>
<maintainers>
<maintainer>Hendrix</maintainer>
<maintainer>Morrison</maintainer>
</maintainers>
<issuetracker>
<name>Jira</name>
<url>http://example.com</url>
</issuetracker>
<project>
before
or after
keys can be specified alongside the XPath values
to insert the elements at certain position with respective to their siblings.
- The 'attribute' method allows setting the value of an XML element's attribute.
Following is an example:
ruby xml_file '/opt/whole.xml' do attribute '//project/repo', 'type', 'svn' owner 'root' group 'root' mode 0644 end
Will result:xml <?xml version="1.0" encoding="UTF-8"?> <project name=""> <repo type="svn"></repo> <maintainers> <maintainer>Hendrix</maintainer> <maintainer>Morrison</maintainer> </maintainers> <project>
- The 'text' method will set the text content of an XML element. Following example:
ruby xml_file '/opt/whole.xml' do text '//maintainer[last()]', 'Ray' owner 'root' group 'root' mode 0644 end
will result:xml <?xml version="1.0" encoding="UTF-8"?> <project name=""> <repo type="svn"></repo> <maintainers> <maintainer>Hendrix</maintainer> <maintainer>Ray</maintainer> </maintainers> <project>
- The 'remove' method will remove all matching xpath elements: Following example:
ruby xml_file '/opt/whole.xml' do remove '//maintainer' end
will result:xml <?xml version="1.0" encoding="UTF-8"?> <project name=""> <repo type="svn"></repo> <maintainers> </maintainers> <project>
All methods can be combined. When used in combination, partials are
processed before text
and attribute
, hence they can refer to XPath introduced by partials.
xml_file
resource only supports :edit action. Its written in
REXML and should be portable across platforms.
License
Contributing
- Fork it ( https://github.com/GoatOS/xml_file/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
Dependent cookbooks
This cookbook has no specified dependencies.
Contingent cookbooks
Collaborator Number Metric
0.3.0 failed this metric
Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.
Contributing File Metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
0.3.0 failed this metric
FC066: Ensure chef_version is set in metadata: xml_file/metadata.rb:1
FC069: Ensure standardized license defined in metadata: xml_file/metadata.rb:1
FC070: Ensure supports metadata defines valid platforms: xml_file/metadata.rb:1
Run with Foodcritic Version 14.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
0.3.0 passed this metric
Publish Metric
0.3.0 passed this metric
Supported Platforms Metric
0.3.0 passed this metric
Testing File Metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
0.3.0 failed this metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file
Foodcritic Metric
0.3.0 failed this metric
FC066: Ensure chef_version is set in metadata: xml_file/metadata.rb:1
FC069: Ensure standardized license defined in metadata: xml_file/metadata.rb:1
FC070: Ensure supports metadata defines valid platforms: xml_file/metadata.rb:1
Run with Foodcritic Version 14.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
0.3.0 passed this metric
Publish Metric
0.3.0 passed this metric
Supported Platforms Metric
0.3.0 passed this metric
Testing File Metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
0.3.0 failed this metric
FC069: Ensure standardized license defined in metadata: xml_file/metadata.rb:1
FC070: Ensure supports metadata defines valid platforms: xml_file/metadata.rb:1
Run with Foodcritic Version 14.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
0.3.0 passed this metric
Publish Metric
0.3.0 passed this metric
Supported Platforms Metric
0.3.0 passed this metric
Testing File Metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
0.3.0 passed this metric
0.3.0 passed this metric
Testing File Metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file
Version Tag Metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number
0.3.0 failed this metric
0.3.0 failed this metric
Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number