File: toml.rb

package info (click to toggle)
ruby-asetus 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144 kB
  • sloc: ruby: 237; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 411 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Asetus
  def to_toml(config)
    Adapter::TOML.to config._asetus_to_hash
  end

  def from_toml(toml)
    Adapter::TOML.from toml
  end

  class Adapter
    class TOML
      class << self
        def to(hash)
          require 'toml'
          ::TOML::Generator.new(hash).body
        end

        def from(toml)
          require 'toml'
          ::TOML.load toml
        end
      end
    end
  end
end