nginx-conf 0.0.2 → 0.0.3
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/lib/nginx-conf/compiler.rb +2 -2
 - data/lib/nginx-conf/conf.rb +13 -5
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a99c739bce2eddd662d416c4ce9bd065e823c5cd
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e84d843bff928badb3b8bd14ff7558fa3e685121
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 614222b2838a16aea7654068bfa4811f74a9a6cad46756e08510ac08187b913efc79522c7279b701bb2659f81430310772fa9bacf32fb511f33f1b1ac7157c6e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 41b44d6f134fbaeb47f8a6a28ae90081734879ec4bc02db3acad8b60f444cd048137ab94a00e2226e929141f7af124ed2593c80fdba80e606a341a9692a60bcc
         
     | 
    
        data/lib/nginx-conf/compiler.rb
    CHANGED
    
    | 
         @@ -30,9 +30,9 @@ class Compiler 
     | 
|
| 
       30 
30 
     | 
    
         
             
              def compile_hash_without_brackets hash
         
     | 
| 
       31 
31 
     | 
    
         
             
                hash.map do |key, values|
         
     | 
| 
       32 
32 
     | 
    
         
             
                  case key
         
     | 
| 
       33 
     | 
    
         
            -
                  when : 
     | 
| 
      
 33 
     | 
    
         
            +
                  when :server, :load_module
         
     | 
| 
       34 
34 
     | 
    
         
             
                    values.map do |config|
         
     | 
| 
       35 
     | 
    
         
            -
                      compile_hash_item  
     | 
| 
      
 35 
     | 
    
         
            +
                      compile_hash_item key, [config]
         
     | 
| 
       36 
36 
     | 
    
         
             
                    end.join()
         
     | 
| 
       37 
37 
     | 
    
         
             
                  else
         
     | 
| 
       38 
38 
     | 
    
         
             
                    compile_hash_item key, values
         
     | 
    
        data/lib/nginx-conf/conf.rb
    CHANGED
    
    | 
         @@ -3,15 +3,23 @@ require_relative 'compiler' 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            class NginxConf
         
     | 
| 
       5 
5 
     | 
    
         
             
              def initialize hash
         
     | 
| 
       6 
     | 
    
         
            -
                raise if hash.has_key? 
     | 
| 
       7 
     | 
    
         
            -
                @hash = hash.merge({http: { 
     | 
| 
      
 6 
     | 
    
         
            +
                raise if [:http, :load_module].any? { |k| hash.has_key? k }
         
     | 
| 
      
 7 
     | 
    
         
            +
                @hash = hash.merge({load_module: [], http: {server: []}})
         
     | 
| 
       8 
8 
     | 
    
         
             
              end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
              def  
     | 
| 
       11 
     | 
    
         
            -
                @hash[: 
     | 
| 
      
 10 
     | 
    
         
            +
              def load_module path
         
     | 
| 
      
 11 
     | 
    
         
            +
                @hash[:load_module].push(path)
         
     | 
| 
       12 
12 
     | 
    
         
             
              end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
              def  
     | 
| 
      
 14 
     | 
    
         
            +
              def server hash
         
     | 
| 
      
 15 
     | 
    
         
            +
                @hash[:http][:server].push(hash)
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              def to_s
         
     | 
| 
       15 
19 
     | 
    
         
             
                Compiler.new.compile(@hash)
         
     | 
| 
       16 
20 
     | 
    
         
             
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              def [] key
         
     | 
| 
      
 23 
     | 
    
         
            +
                @hash[key]
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
       17 
25 
     | 
    
         
             
            end
         
     |