asetus 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +1 -1
 - data/asetus.gemspec +2 -2
 - data/lib/asetus/adapter/toml.rb +27 -0
 - data/lib/asetus.rb +2 -1
 - metadata +4 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 618b53db8015a756a96a2124fab7f5e396c4e0b6
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a1629c5542af8474466df4dc82e195ee3f8e743f
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a5097f86b83858a1094de6aa5be95a4337cf395c39a4f103f49821e478ec3f4f3e94e9921421e75627d9cf846afc76b27ecda001e0e442ced70ecd7db64d0d26
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 480a2a7f5afbe0c7284ae2bb8d1acba54decb08bcd69fec5e8ffdc670ee43b8d56286201de95a76a0cb8c5786f6c7fe500bb2ef6e28458ba5ab65bf994c80279
         
     | 
    
        data/README.md
    CHANGED
    
    
    
        data/asetus.gemspec
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       2 
2 
     | 
    
         
             
              s.name              = 'asetus'
         
     | 
| 
       3 
     | 
    
         
            -
              s.version           = '0. 
     | 
| 
      
 3 
     | 
    
         
            +
              s.version           = '0.2.0'
         
     | 
| 
       4 
4 
     | 
    
         
             
              s.licenses          = ['Apache-2.0']
         
     | 
| 
       5 
5 
     | 
    
         
             
              s.platform          = Gem::Platform::RUBY
         
     | 
| 
       6 
6 
     | 
    
         
             
              s.authors           = [ 'Saku Ytti' ]
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.email             = %w( saku@ytti.fi )
         
     | 
| 
       8 
8 
     | 
    
         
             
              s.homepage          = 'http://github.com/ytti/asetus'
         
     | 
| 
       9 
9 
     | 
    
         
             
              s.summary           = 'configuration library'
         
     | 
| 
       10 
     | 
    
         
            -
              s.description       = 'configuration library with object access to YAML/JSON/ 
     | 
| 
      
 10 
     | 
    
         
            +
              s.description       = 'configuration library with object access to YAML/JSON/TOML backends'
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.rubyforge_project = s.name
         
     | 
| 
       12 
12 
     | 
    
         
             
              s.files             = `git ls-files`.split("\n")
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.executables       = %w(  )
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Asetus
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              def to_toml config
         
     | 
| 
      
 4 
     | 
    
         
            +
                Adapter::TOML.to config._asetus_to_hash
         
     | 
| 
      
 5 
     | 
    
         
            +
              end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              def from_toml toml
         
     | 
| 
      
 8 
     | 
    
         
            +
                Adapter::TOML.from toml
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              class Adapter
         
     | 
| 
      
 12 
     | 
    
         
            +
                class TOML
         
     | 
| 
      
 13 
     | 
    
         
            +
                  class << self
         
     | 
| 
      
 14 
     | 
    
         
            +
                    def to hash
         
     | 
| 
      
 15 
     | 
    
         
            +
                      require 'toml'
         
     | 
| 
      
 16 
     | 
    
         
            +
                      ::TOML::Generator.new(hash).body
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    def from toml
         
     | 
| 
      
 20 
     | 
    
         
            +
                      require 'toml'
         
     | 
| 
      
 21 
     | 
    
         
            +
                      ::TOML.load toml
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/asetus.rb
    CHANGED
    
    | 
         @@ -1,6 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require_relative 'asetus/configstruct'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require_relative 'asetus/adapter/yaml'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require_relative 'asetus/adapter/json'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative 'asetus/adapter/toml'
         
     | 
| 
       4 
5 
     | 
    
         
             
            require 'fileutils'
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            class AsetusError < StandardError; end
         
     | 
| 
         @@ -89,7 +90,7 @@ class Asetus 
     | 
|
| 
       89 
90 
     | 
    
         | 
| 
       90 
91 
     | 
    
         
             
              # @param [Hash] opts options for Asetus.new
         
     | 
| 
       91 
92 
     | 
    
         
             
              # @option opts [String]  :name     name to use for asetus (/etc/name/, ~/.config/name/) - autodetected if not defined
         
     | 
| 
       92 
     | 
    
         
            -
              # @option opts [String]  :adapter  adapter to use 'yaml' or ' 
     | 
| 
      
 93 
     | 
    
         
            +
              # @option opts [String]  :adapter  adapter to use 'yaml', 'json' or 'toml' for now
         
     | 
| 
       93 
94 
     | 
    
         
             
              # @option opts [String]  :usrdir   directory for storing user config ~/.config/name/ by default
         
     | 
| 
       94 
95 
     | 
    
         
             
              # @option opts [String]  :sysdir   directory for storing system config /etc/name/ by default
         
     | 
| 
       95 
96 
     | 
    
         
             
              # @option opts [String]  :cfgfile  configuration filename by default CONFIG_FILE
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,16 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: asetus
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Saku Ytti
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-12-15 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
     | 
    
         
            -
            description: configuration library with object access to YAML/JSON/ 
     | 
| 
      
 13 
     | 
    
         
            +
            description: configuration library with object access to YAML/JSON/TOML backends
         
     | 
| 
       14 
14 
     | 
    
         
             
            email:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - saku@ytti.fi
         
     | 
| 
       16 
16 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -24,6 +24,7 @@ files: 
     | 
|
| 
       24 
24 
     | 
    
         
             
            - asetus.gemspec
         
     | 
| 
       25 
25 
     | 
    
         
             
            - lib/asetus.rb
         
     | 
| 
       26 
26 
     | 
    
         
             
            - lib/asetus/adapter/json.rb
         
     | 
| 
      
 27 
     | 
    
         
            +
            - lib/asetus/adapter/toml.rb
         
     | 
| 
       27 
28 
     | 
    
         
             
            - lib/asetus/adapter/yaml.rb
         
     | 
| 
       28 
29 
     | 
    
         
             
            - lib/asetus/configstruct.rb
         
     | 
| 
       29 
30 
     | 
    
         
             
            homepage: http://github.com/ytti/asetus
         
     |