hey_listen 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/app/models/hey_listen/notification.rb +43 -0
- data/lib/generators/hey_listen/install.rb +9 -0
- data/lib/hey_listen/version.rb +1 -1
- metadata +4 -3
- data/app/models/notification.rb +0 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 30e654c58c8e742bfd71a7014c414377dc3507d8
         | 
| 4 | 
            +
              data.tar.gz: 778843f600bbe041f423e59d4617c5963a0a47d1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 592f623274ef3340b5d86102749b0cf88a42f7f4e431ac806cb85b51e463af986df3ed7155a46719ab18a7675b4f0cc9f7b5376a0a989c65643271645091f714
         | 
| 7 | 
            +
              data.tar.gz: 48abf1b30b339dcace2b05fbb163c51e68686a74f8bf66e624983e6fa3625826ea207667a02991afe851068ca211d9ce2184e0e59c125cb8b1e6474dd2304e01
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            module HeyListen
         | 
| 2 | 
            +
              class Notification < ActiveRecord::Base
         | 
| 3 | 
            +
                belongs_to :user
         | 
| 4 | 
            +
                belongs_to :notifiable, polymorphic: true
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                scope :unread, -> { where(read: false) }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                def notification
         | 
| 9 | 
            +
                  "Notifications::#{label}".constantize.new(notifiable, user)
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
                delegate :accepted?, :requires_action?, :image, :text, :content, to: :notification
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def date
         | 
| 14 | 
            +
                  -> (d) {
         | 
| 15 | 
            +
                    [d.year, d.month.pred, d.day]
         | 
| 16 | 
            +
                  }.call(created_at)
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def as_json(options = {})
         | 
| 20 | 
            +
                  {
         | 
| 21 | 
            +
                    id: id,
         | 
| 22 | 
            +
                    image: image,
         | 
| 23 | 
            +
                    text: text,
         | 
| 24 | 
            +
                    content: content,
         | 
| 25 | 
            +
                    accepted: accepted?,
         | 
| 26 | 
            +
                    requires_action: requires_action?,
         | 
| 27 | 
            +
                    actions: actions,
         | 
| 28 | 
            +
                    read: read,
         | 
| 29 | 
            +
                    date: date
         | 
| 30 | 
            +
                  }
         | 
| 31 | 
            +
                rescue Exception => e
         | 
| 32 | 
            +
                  {
         | 
| 33 | 
            +
                    text: "Notification ##{id} couldn't be displayed correctly.",
         | 
| 34 | 
            +
                    content: [{
         | 
| 35 | 
            +
                      type: 'text',
         | 
| 36 | 
            +
                      text: "Notification ##{id} couldn't be displayed correctly."
         | 
| 37 | 
            +
                    }],
         | 
| 38 | 
            +
                    date: date,
         | 
| 39 | 
            +
                    error: e.message
         | 
| 40 | 
            +
                  }
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         | 
    
        data/lib/hey_listen/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: hey_listen
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Erik Escobedo
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-08- | 
| 11 | 
            +
            date: 2014-08-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -52,9 +52,10 @@ files: | |
| 52 52 | 
             
            - app/assets/stylesheets/hey_listen/application.css
         | 
| 53 53 | 
             
            - app/controllers/hey_listen/application_controller.rb
         | 
| 54 54 | 
             
            - app/helpers/hey_listen/application_helper.rb
         | 
| 55 | 
            -
            - app/models/notification.rb
         | 
| 55 | 
            +
            - app/models/hey_listen/notification.rb
         | 
| 56 56 | 
             
            - app/views/layouts/hey_listen/application.html.erb
         | 
| 57 57 | 
             
            - config/routes.rb
         | 
| 58 | 
            +
            - lib/generators/hey_listen/install.rb
         | 
| 58 59 | 
             
            - lib/hey_listen.rb
         | 
| 59 60 | 
             
            - lib/hey_listen/engine.rb
         | 
| 60 61 | 
             
            - lib/hey_listen/version.rb
         | 
    
        data/app/models/notification.rb
    DELETED