Sha256: 8a157eb97f19b36c9d2934833038a7481b80694af49a8380acfb1b404fa2d658

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

# Pycf

Configuration file parser for [Python 2.7 basic configuration file](https://docs.python.org/2.7/library/configparser.html).

see [ConfigParser.py](https://github.com/python/cpython/blob/2.7/Lib/ConfigParser.py).

[![Gem Version](https://badge.fury.io/rb/pycf.svg)](http://badge.fury.io/rb/pycf)
[![Build Status](https://travis-ci.org/winebarrel/pycf.svg?branch=master)](https://travis-ci.org/winebarrel/pycf)
[![Coverage Status](https://coveralls.io/repos/winebarrel/pycf/badge.svg?branch=master)](https://coveralls.io/r/winebarrel/pycf?branch=master)

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'pycf'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install pycf

## Usage

### load

```ruby
require 'pycf'

python_config = <<EOS
[DEFAULT]
ServerAliveInterval = 45
Compression = yes
CompressionLevel = 9
ForwardX11 = yes

[bitbucket.org]
User = hg

[topsecret.server.com]
Port = 50022
ForwardX11 = no
EOS

p Pycf.load(python_config)
# => {"DEFAULT"=>
#      {"serveraliveinterval"=>"45",
#       "compression"=>"yes",
#       "compressionlevel"=>"9",
#       "forwardx11"=>"yes"},
#     "bitbucket.org"=>{"user"=>"hg"},
#     "topsecret.server.com"=>{"port"=>"50022", "forwardx11"=>"no"}}
```

### dump

```ruby
require 'pycf'
require 'pp'

hash = {"DEFAULT"=>
         {"serveraliveinterval"=>"45",
          "compression"=>"yes",
          "compressionlevel"=>"9",
          "forwardx11"=>"yes"},
        "bitbucket.org"=>{"user"=>"hg"},
        "topsecret.server.com"=>{"port"=>"50022", "forwardx11"=>"no"}}

puts Pycf.dump(hash)
# => [DEFAULT]
#    serveraliveinterval = 45
#    compression = yes
#    compressionlevel = 9
#    forwardx11 = yes
#    [bitbucket.org]
#    user = hg
#    [topsecret.server.com]
#    port = 50022
#    forwardx11 = no
```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pycf-0.1.0 README.md