opener-polarity-tagger 3.2.1 → 3.2.2
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: 27bfb633058aa56d6b5d30fd5557dcfa7e00ecee25005d9258fede4a3544ae47
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8c2877d8c288360c77e64f828587ddd0781cde0171237d85c87dc8a435f0cde8
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9c9c8b158fe73cae1d095cfad59b774eca29e034d635baf6795dd9bc96c63e19cc0cd63fab12fa3c560df75e4451f1bbabcd2814ac92bcfa5e3002a966b0eb56
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: aadffb4278642a1b3e04483a486def241f1be6d2adbce911428588f1962a19fc5392903b805bec04411b128a67f8d6ebca37be285c38b4805617f0f3eb125bae
         
     | 
| 
         @@ -4,6 +4,8 @@ module Opener 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                  include MonitorMixin
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
      
 7 
     | 
    
         
            +
                  UPDATE_INTERVAL = (ENV['CACHE_EXPIRE_MINS']&.to_i || 5).minutes
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       7 
9 
     | 
    
         
             
                  def initialize
         
     | 
| 
       8 
10 
     | 
    
         
             
                    super #MonitorMixin
         
     | 
| 
       9 
11 
     | 
    
         | 
| 
         @@ -14,13 +16,9 @@ module Opener 
     | 
|
| 
       14 
16 
     | 
    
         | 
| 
       15 
17 
     | 
    
         
             
                  def [] **params
         
     | 
| 
       16 
18 
     | 
    
         
             
                    synchronize do
         
     | 
| 
       17 
     | 
    
         
            -
                       
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                        end
         
     | 
| 
       21 
     | 
    
         
            -
                      else
         
     | 
| 
       22 
     | 
    
         
            -
                        @cache[params] = cache_update **params
         
     | 
| 
       23 
     | 
    
         
            -
                      end
         
     | 
| 
      
 19 
     | 
    
         
            +
                      existing = @cache[params]
         
     | 
| 
      
 20 
     | 
    
         
            +
                      break existing if existing and existing.from > UPDATE_INTERVAL.ago
         
     | 
| 
      
 21 
     | 
    
         
            +
                      @cache[params] = cache_update existing, **params
         
     | 
| 
       24 
22 
     | 
    
         
             
                    end
         
     | 
| 
       25 
23 
     | 
    
         
             
                  end
         
     | 
| 
       26 
24 
     | 
    
         
             
                  alias_method :get, :[]
         
     | 
| 
         @@ -29,7 +27,11 @@ module Opener 
     | 
|
| 
       29 
27 
     | 
    
         
             
                    from     = Time.now
         
     | 
| 
       30 
28 
     | 
    
         
             
                    lexicons = load_lexicons cache: existing, **params
         
     | 
| 
       31 
29 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
                     
     | 
| 
      
 30 
     | 
    
         
            +
                    if existing and lexicons.blank?
         
     | 
| 
      
 31 
     | 
    
         
            +
                      existing.from = from
         
     | 
| 
      
 32 
     | 
    
         
            +
                      return existing
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       33 
35 
     | 
    
         
             
                    Hashie::Mash.new(
         
     | 
| 
       34 
36 
     | 
    
         
             
                      lexicons: lexicons,
         
     | 
| 
       35 
37 
     | 
    
         
             
                      from:     from,
         
     | 
| 
         @@ -47,7 +49,7 @@ module Opener 
     | 
|
| 
       47 
49 
     | 
    
         
             
                    url += "&if_updated_since=#{cache.from.iso8601}" if cache
         
     | 
| 
       48 
50 
     | 
    
         
             
                    puts "#{lang}: loading lexicons from url #{url}"
         
     | 
| 
       49 
51 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                    lexicons = JSON.parse  
     | 
| 
      
 52 
     | 
    
         
            +
                    lexicons = JSON.parse http.get(url).body
         
     | 
| 
       51 
53 
     | 
    
         
             
                    lexicons = lexicons['data'].map{ |l| Hashie::Mash.new l }
         
     | 
| 
       52 
54 
     | 
    
         
             
                    lexicons
         
     | 
| 
       53 
55 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -83,6 +85,16 @@ module Opener 
     | 
|
| 
       83 
85 
     | 
    
         
             
                    lexicons
         
     | 
| 
       84 
86 
     | 
    
         
             
                  end
         
     | 
| 
       85 
87 
     | 
    
         | 
| 
      
 88 
     | 
    
         
            +
                  def http
         
     | 
| 
      
 89 
     | 
    
         
            +
                    return @http if @http
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                    @http = HTTPClient.new
         
     | 
| 
      
 92 
     | 
    
         
            +
                    @http.send_timeout    = 120
         
     | 
| 
      
 93 
     | 
    
         
            +
                    @http.receive_timeout = 120
         
     | 
| 
      
 94 
     | 
    
         
            +
                    @http.connect_timeout = 120
         
     | 
| 
      
 95 
     | 
    
         
            +
                    @http
         
     | 
| 
      
 96 
     | 
    
         
            +
                  end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
       86 
98 
     | 
    
         
             
                end
         
     | 
| 
       87 
99 
     | 
    
         
             
              end
         
     | 
| 
       88 
100 
     | 
    
         
             
            end
         
     |