alephant-publisher 0.2.9 → 0.3.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/lib/alephant/publisher/sqs_helper/archiver.rb +8 -2
 - data/lib/alephant/publisher/version.rb +1 -1
 - data/spec/archiver_spec.rb +3 -3
 - 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: d93ee0d2aabcb7e27db2aba8fd4c957663e06ffb
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5c2b5aa224c8c762c97b046046d04c9dc4e81add
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e5c98f4c69a8bc5a88ffdaaf7f0c413b57547e2467dfcbdd791b68b371469f5e51bd254232a11fe842252f71ad6833c5ab20376831b649eb995037f35abc2e4e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 394ef826ee1ee022e219f2117d5f7c2ea79f52273ed6b380fbb630cf9ed419fe8adff87ce5227cd20548f08fd01a6d3b114f9b1b9556dc7bf7908e7559e4ff84
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'date'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Alephant
         
     | 
| 
       2 
4 
     | 
    
         
             
              module Publisher
         
     | 
| 
       3 
5 
     | 
    
         
             
                module SQSHelper
         
     | 
| 
         @@ -21,14 +23,18 @@ module Alephant 
     | 
|
| 
       21 
23 
     | 
    
         
             
                    end
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
       23 
25 
     | 
    
         
             
                    def store(m)
         
     | 
| 
       24 
     | 
    
         
            -
                      cache.put("archive/#{m.id}", m.body, meta_for(m))
         
     | 
| 
      
 26 
     | 
    
         
            +
                      cache.put("archive/#{date_key}/#{m.id}", m.body, meta_for(m))
         
     | 
| 
      
 27 
     | 
    
         
            +
                    end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                    def date_key
         
     | 
| 
      
 30 
     | 
    
         
            +
                      DateTime.now.strftime('%d-%m-%Y_%H')
         
     | 
| 
       25 
31 
     | 
    
         
             
                    end
         
     | 
| 
       26 
32 
     | 
    
         | 
| 
       27 
33 
     | 
    
         
             
                    def meta_for(m)
         
     | 
| 
       28 
34 
     | 
    
         
             
                      {
         
     | 
| 
       29 
35 
     | 
    
         
             
                        :id                => m.id,
         
     | 
| 
       30 
36 
     | 
    
         
             
                        :md5               => m.md5,
         
     | 
| 
       31 
     | 
    
         
            -
                        :logged_at         =>  
     | 
| 
      
 37 
     | 
    
         
            +
                        :logged_at         => DateTime.now.to_s,
         
     | 
| 
       32 
38 
     | 
    
         
             
                        :queue             => m.queue.url,
         
     | 
| 
       33 
39 
     | 
    
         
             
                      }
         
     | 
| 
       34 
40 
     | 
    
         
             
                    end
         
     | 
    
        data/spec/archiver_spec.rb
    CHANGED
    
    | 
         @@ -3,8 +3,8 @@ require 'spec_helper' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            describe Alephant::Publisher::SQSHelper::Archiver do
         
     | 
| 
       4 
4 
     | 
    
         
             
              describe "#see" do
         
     | 
| 
       5 
5 
     | 
    
         
             
                it "calls cache put with the correct params" do
         
     | 
| 
       6 
     | 
    
         
            -
                  time_now =  
     | 
| 
       7 
     | 
    
         
            -
                   
     | 
| 
      
 6 
     | 
    
         
            +
                  time_now = DateTime.parse("Feb 24 1981")
         
     | 
| 
      
 7 
     | 
    
         
            +
                  DateTime.stub(:now).and_return(time_now)
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                  q = double("queue").as_null_object
         
     | 
| 
       10 
10 
     | 
    
         
             
                  c = double("cache").as_null_object
         
     | 
| 
         @@ -14,7 +14,7 @@ describe Alephant::Publisher::SQSHelper::Archiver do 
     | 
|
| 
       14 
14 
     | 
    
         
             
                  m = Struct.new(:id, :body, :md5, :queue).new('id', 'body', 'md5', q)
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
                  expect(c).to receive(:put).with(
         
     | 
| 
       17 
     | 
    
         
            -
                    "archive/id",
         
     | 
| 
      
 17 
     | 
    
         
            +
                    "archive/#{time_now.strftime('%d-%m-%Y_%H')}/id",
         
     | 
| 
       18 
18 
     | 
    
         
             
                    "body",
         
     | 
| 
       19 
19 
     | 
    
         
             
                    {
         
     | 
| 
       20 
20 
     | 
    
         
             
                      :id        => "id",
         
     |