glib-web 0.3.8 → 0.3.9
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
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b13a0d5398903f6b1e6795d7a34dce9c064dd05a7df740d47cd15690fdd906eb
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4195513ba393a6d4f0fff811f01355b2aef1793caf3c3fb7d609d3df3d31cfc2
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7162957076123f6f803f6c854f1099bf1e44f1ff27c7900d24ef3eb3ab259491459c3071a343683d800cab007d744d7ddfe0fba31e47c4b09fd8e32abcbb0e1e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 816b64172b98f4e1907894b93265adad533d319b0561fe2f73439d0c47c7e9da52a67d0bf6eb7a94a5d54ca50755e88ae2a6f143e6bc08324b2e486f5c981d1e
         
     | 
| 
         @@ -1,12 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Glib
         
     | 
| 
       2 
2 
     | 
    
         
             
              module DynamicTextsHelper
         
     | 
| 
       3 
     | 
    
         
            -
                def dt(key, default_value = '', scope  
     | 
| 
      
 3 
     | 
    
         
            +
                def dt(key, default_value = '', options: { scope: 'itinerarybuilder', lang: 'en' })
         
     | 
| 
       4 
4 
     | 
    
         
             
                  new_key = key
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       5 
6 
     | 
    
         
             
                  if key.starts_with?('.')
         
     | 
| 
       6 
7 
     | 
    
         
             
                    new_key = "#{controller_name}.#{action_name}#{key}"
         
     | 
| 
       7 
8 
     | 
    
         
             
                  end
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                  Glib::Text.get_content( 
     | 
| 
      
 10 
     | 
    
         
            +
                  Glib::Text.get_content(new_key, default_value, options: options)
         
     | 
| 
       10 
11 
     | 
    
         
             
                end
         
     | 
| 
       11 
12 
     | 
    
         
             
              end
         
     | 
| 
       12 
13 
     | 
    
         
             
            end
         
     | 
    
        data/app/models/glib/text.rb
    CHANGED
    
    | 
         @@ -1,20 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Glib
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Text < Glib::DynamicTextRecord
         
     | 
| 
       3 
3 
     | 
    
         
             
                validates :scope, presence: true
         
     | 
| 
       4 
     | 
    
         
            -
                validates : 
     | 
| 
      
 4 
     | 
    
         
            +
                validates :lang, presence: true
         
     | 
| 
      
 5 
     | 
    
         
            +
                validates :key, presence: true, uniqueness: { scope: [:scope, :lang] }
         
     | 
| 
       5 
6 
     | 
    
         
             
                validates :content, presence: true
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
                after_save :update_to_redis
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                def self.get_content( 
     | 
| 
       10 
     | 
    
         
            -
                  scope_key = "#{scope}.#{key}"
         
     | 
| 
      
 10 
     | 
    
         
            +
                def self.get_content(key, default_value, options:)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  scope_key = "#{options[:scope]}.#{options[:lang]}.#{key}"
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
                  unless content = $dt_redis.get(scope_key)
         
     | 
| 
       13 
     | 
    
         
            -
                    if text = find_by(scope: scope, key: key)
         
     | 
| 
      
 14 
     | 
    
         
            +
                    if text = find_by(scope: options[:scope], lang: options[:lang], key: key)
         
     | 
| 
       14 
15 
     | 
    
         
             
                      update_content(scope_key, text.content)
         
     | 
| 
       15 
16 
     | 
    
         
             
                      content = text.content
         
     | 
| 
       16 
17 
     | 
    
         
             
                    else
         
     | 
| 
       17 
     | 
    
         
            -
                      create(scope: scope, key: key, content: default_value)
         
     | 
| 
      
 18 
     | 
    
         
            +
                      create(scope: options[:scope], lang: options[:lang], key: key, content: default_value)
         
     | 
| 
       18 
19 
     | 
    
         
             
                      update_content(scope_key, default_value)
         
     | 
| 
       19 
20 
     | 
    
         
             
                      content = default_value
         
     | 
| 
       20 
21 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -29,7 +30,7 @@ module Glib 
     | 
|
| 
       29 
30 
     | 
    
         
             
                  end
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
32 
     | 
    
         
             
                  def update_to_redis
         
     | 
| 
       32 
     | 
    
         
            -
                    Glib::Text.update_content("#{scope}.#{key}", content)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    Glib::Text.update_content("#{scope}.#{lang}.#{key}", content)
         
     | 
| 
       33 
34 
     | 
    
         
             
                  end
         
     | 
| 
       34 
35 
     | 
    
         
             
              end
         
     | 
| 
       35 
36 
     | 
    
         
             
            end
         
     | 
| 
         @@ -10,6 +10,7 @@ module Glib 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  def copy_initializer
         
     | 
| 
       11 
11 
     | 
    
         
             
                    template '20191017062519_create_texts.rb', 'db/dynamic_text_migrate/20191017062519_create_texts.rb'
         
     | 
| 
       12 
12 
     | 
    
         
             
                    template '20191024063257_add_scope_to_texts.rb', 'db/dynamic_text_migrate/20191024063257_add_scope_to_texts.rb'
         
     | 
| 
      
 13 
     | 
    
         
            +
                    template '20191112095018_add_lang_to_texts.rb', 'db/dynamic_text_migrate/20191112095018_add_lang_to_texts.rb'
         
     | 
| 
       13 
14 
     | 
    
         
             
                    template 'dynamic_text.rb', 'config/initializers/dynamic_text.rb'
         
     | 
| 
       14 
15 
     | 
    
         
             
                    template 'database.yml', 'config/database.yml'
         
     | 
| 
       15 
16 
     | 
    
         
             
                  end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: glib-web
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.3. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - ''
         
     | 
| 
         @@ -117,6 +117,7 @@ files: 
     | 
|
| 
       117 
117 
     | 
    
         
             
            - lib/generators/glib/install_generator.rb
         
     | 
| 
       118 
118 
     | 
    
         
             
            - lib/generators/templates/20191017062519_create_texts.rb
         
     | 
| 
       119 
119 
     | 
    
         
             
            - lib/generators/templates/20191024063257_add_scope_to_texts.rb
         
     | 
| 
      
 120 
     | 
    
         
            +
            - lib/generators/templates/20191112095018_add_lang_to_texts.rb
         
     | 
| 
       120 
121 
     | 
    
         
             
            - lib/generators/templates/database.yml
         
     | 
| 
       121 
122 
     | 
    
         
             
            - lib/generators/templates/dynamic_text.rb
         
     | 
| 
       122 
123 
     | 
    
         
             
            - lib/glib-web.rb
         
     |