fastly-rails 0.1.0 → 0.1.1
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/fastly-rails.rb +10 -11
- data/lib/fastly-rails/action_controller/cache_control_headers.rb +0 -4
- data/lib/fastly-rails/action_controller/surrogate_control_headers.rb +1 -6
- data/lib/fastly-rails/active_record/surrogate_key.rb +12 -20
- data/lib/fastly-rails/client.rb +1 -8
- data/lib/fastly-rails/configuration.rb +10 -31
- data/lib/fastly-rails/version.rb +1 -1
- data/test/dummy/app/controllers/books_controller.rb +1 -0
- data/test/dummy/app/models/book.rb +0 -10
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +1419 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/fastly-rails/configuration_test.rb +0 -13
- metadata +18 -3
- data/lib/fastly/purgeable.rb +0 -55
| @@ -1,7 +1,6 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe FastlyRails::Configuration do
         | 
| 4 | 
            -
             | 
| 5 4 | 
             
              let(:configuration) { FastlyRails::Configuration.new }
         | 
| 6 5 |  | 
| 7 6 | 
             
              it 'should create a fastly rails client' do
         | 
| @@ -9,7 +8,6 @@ describe FastlyRails::Configuration do | |
| 9 8 | 
             
              end
         | 
| 10 9 |  | 
| 11 10 | 
             
              it 'should have configuration attributes' do
         | 
| 12 | 
            -
             | 
| 13 11 | 
             
                methods = [
         | 
| 14 12 | 
             
                  :api_key,
         | 
| 15 13 | 
             
                  :user,
         | 
| @@ -20,11 +18,9 @@ describe FastlyRails::Configuration do | |
| 20 18 | 
             
                methods.each do |method|
         | 
| 21 19 | 
             
                  assert_respond_to configuration, method
         | 
| 22 20 | 
             
                end
         | 
| 23 | 
            -
             | 
| 24 21 | 
             
              end
         | 
| 25 22 |  | 
| 26 23 | 
             
              describe 'max_age_default' do
         | 
| 27 | 
            -
             | 
| 28 24 | 
             
                it 'should be a class method' do
         | 
| 29 25 | 
             
                  assert_respond_to FastlyRails::Configuration, :max_age_default
         | 
| 30 26 | 
             
                end
         | 
| @@ -32,11 +28,9 @@ describe FastlyRails::Configuration do | |
| 32 28 | 
             
                it 'should return the value of a constant MAX_AGE_DEFAULT' do
         | 
| 33 29 | 
             
                  assert_equal FastlyRails::Configuration::MAX_AGE_DEFAULT, FastlyRails::Configuration.max_age_default
         | 
| 34 30 | 
             
                end
         | 
| 35 | 
            -
             | 
| 36 31 | 
             
              end
         | 
| 37 32 |  | 
| 38 33 | 
             
              describe 'authenticatable?' do
         | 
| 39 | 
            -
             | 
| 40 34 | 
             
                before do
         | 
| 41 35 | 
             
                  configuration.api_key = nil
         | 
| 42 36 | 
             
                  configuration.user = nil
         | 
| @@ -52,33 +46,26 @@ describe FastlyRails::Configuration do | |
| 52 46 | 
             
                end
         | 
| 53 47 |  | 
| 54 48 | 
             
                it 'should return false if only user is not nil' do
         | 
| 55 | 
            -
             | 
| 56 49 | 
             
                  configuration.user = 'user'
         | 
| 57 50 |  | 
| 58 51 | 
             
                  assert_equal false, configuration.authenticatable?
         | 
| 59 | 
            -
             | 
| 60 52 | 
             
                end
         | 
| 61 53 |  | 
| 62 54 | 
             
                it 'should return true if only api_key is not nil' do
         | 
| 63 | 
            -
             | 
| 64 55 | 
             
                  configuration.api_key = 'key'
         | 
| 65 56 |  | 
| 66 57 | 
             
                  assert_equal true, configuration.authenticatable?
         | 
| 67 | 
            -
             | 
| 68 58 | 
             
                end
         | 
| 69 59 |  | 
| 70 60 | 
             
                it 'should return true if if user and password are not nil' do
         | 
| 71 | 
            -
             | 
| 72 61 | 
             
                  configuration.user      = 'user'
         | 
| 73 62 | 
             
                  configuration.password  = 'password'
         | 
| 74 63 |  | 
| 75 64 | 
             
                  assert_equal true, configuration.authenticatable?
         | 
| 76 | 
            -
             | 
| 77 65 | 
             
                end
         | 
| 78 66 | 
             
              end
         | 
| 79 67 |  | 
| 80 68 | 
             
              it 'should have a default value for max_age since none was provided' do
         | 
| 81 69 | 
             
                assert_equal FastlyRails::Configuration.max_age_default, configuration.max_age
         | 
| 82 70 | 
             
              end
         | 
| 83 | 
            -
             | 
| 84 71 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fastly-rails
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Michael May
         | 
| @@ -11,7 +11,7 @@ authors: | |
| 11 11 | 
             
            autorequire: 
         | 
| 12 12 | 
             
            bindir: bin
         | 
| 13 13 | 
             
            cert_chain: []
         | 
| 14 | 
            -
            date: 2014-04- | 
| 14 | 
            +
            date: 2014-04-28 00:00:00.000000000 Z
         | 
| 15 15 | 
             
            dependencies:
         | 
| 16 16 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 17 17 | 
             
              name: rails
         | 
| @@ -147,7 +147,6 @@ files: | |
| 147 147 | 
             
            - lib/fastly-rails/engine.rb
         | 
| 148 148 | 
             
            - lib/fastly-rails/errors.rb
         | 
| 149 149 | 
             
            - lib/fastly-rails/version.rb
         | 
| 150 | 
            -
            - lib/fastly/purgeable.rb
         | 
| 151 150 | 
             
            - test/dummy/README.rdoc
         | 
| 152 151 | 
             
            - test/dummy/Rakefile
         | 
| 153 152 | 
             
            - test/dummy/app/assets/javascripts/application.js
         | 
| @@ -182,6 +181,8 @@ files: | |
| 182 181 | 
             
            - test/dummy/config/routes.rb
         | 
| 183 182 | 
             
            - test/dummy/db/migrate/20140407202136_create_books.rb
         | 
| 184 183 | 
             
            - test/dummy/db/schema.rb
         | 
| 184 | 
            +
            - test/dummy/db/test.sqlite3
         | 
| 185 | 
            +
            - test/dummy/log/test.log
         | 
| 185 186 | 
             
            - test/dummy/public/404.html
         | 
| 186 187 | 
             
            - test/dummy/public/422.html
         | 
| 187 188 | 
             
            - test/dummy/public/500.html
         | 
| @@ -191,6 +192,12 @@ files: | |
| 191 192 | 
             
            - test/dummy/test/fixtures/books.yml
         | 
| 192 193 | 
             
            - test/dummy/test/integration/fastly_headers_test.rb
         | 
| 193 194 | 
             
            - test/dummy/test/models/book_test.rb
         | 
| 195 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
         | 
| 196 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
         | 
| 197 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
         | 
| 198 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
         | 
| 199 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
         | 
| 200 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
         | 
| 194 201 | 
             
            - test/fastly-rails/cache_control_headers_test.rb
         | 
| 195 202 | 
             
            - test/fastly-rails/client_test.rb
         | 
| 196 203 | 
             
            - test/fastly-rails/configuration_test.rb
         | 
| @@ -252,6 +259,8 @@ test_files: | |
| 252 259 | 
             
            - test/dummy/config.ru
         | 
| 253 260 | 
             
            - test/dummy/db/migrate/20140407202136_create_books.rb
         | 
| 254 261 | 
             
            - test/dummy/db/schema.rb
         | 
| 262 | 
            +
            - test/dummy/db/test.sqlite3
         | 
| 263 | 
            +
            - test/dummy/log/test.log
         | 
| 255 264 | 
             
            - test/dummy/public/404.html
         | 
| 256 265 | 
             
            - test/dummy/public/422.html
         | 
| 257 266 | 
             
            - test/dummy/public/500.html
         | 
| @@ -263,6 +272,12 @@ test_files: | |
| 263 272 | 
             
            - test/dummy/test/fixtures/books.yml
         | 
| 264 273 | 
             
            - test/dummy/test/integration/fastly_headers_test.rb
         | 
| 265 274 | 
             
            - test/dummy/test/models/book_test.rb
         | 
| 275 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
         | 
| 276 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
         | 
| 277 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
         | 
| 278 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
         | 
| 279 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
         | 
| 280 | 
            +
            - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
         | 
| 266 281 | 
             
            - test/fastly-rails/cache_control_headers_test.rb
         | 
| 267 282 | 
             
            - test/fastly-rails/client_test.rb
         | 
| 268 283 | 
             
            - test/fastly-rails/configuration_test.rb
         | 
    
        data/lib/fastly/purgeable.rb
    DELETED
    
    | @@ -1,55 +0,0 @@ | |
| 1 | 
            -
            # Object that follows the observer pattern
         | 
| 2 | 
            -
            # usage:
         | 
| 3 | 
            -
            # Fastly::Purgeable.new(@article).save!
         | 
| 4 | 
            -
            # Fastly::Purgeable.new(@article).destroy!
         | 
| 5 | 
            -
            # This calls save on the @article and then makes a call to fastly to purge from cache
         | 
| 6 | 
            -
            module Fastly
         | 
| 7 | 
            -
              class Purgeable
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                def self.initialize()
         | 
| 10 | 
            -
                end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
                # These methods need to hook into activerecord
         | 
| 14 | 
            -
                # Calls super
         | 
| 15 | 
            -
                # Purges the object from the fastly cache
         | 
| 16 | 
            -
                def destroy
         | 
| 17 | 
            -
                  super
         | 
| 18 | 
            -
                  @queue << self.resource_key
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                def destroy!
         | 
| 22 | 
            -
                  super
         | 
| 23 | 
            -
                  Fastly.purge(self.resource_key)
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                def save
         | 
| 27 | 
            -
                  super
         | 
| 28 | 
            -
                  Fastly.purge(self.resource_key)
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                def save!
         | 
| 32 | 
            -
                  super
         | 
| 33 | 
            -
                  Fastly.purge(self.resource_key)
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                def update
         | 
| 37 | 
            -
                  super
         | 
| 38 | 
            -
                  Fastly.purge(self.resource_key)
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
                # updates all records in the table
         | 
| 42 | 
            -
                # purge table key
         | 
| 43 | 
            -
                def update_all
         | 
| 44 | 
            -
                  super
         | 
| 45 | 
            -
                  Fastly.purge(self.table_key)
         | 
| 46 | 
            -
                end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                def update_attribute
         | 
| 49 | 
            -
                end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                def update_attributes
         | 
| 52 | 
            -
                end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
              end
         | 
| 55 | 
            -
            end
         |