api_resource 0.4.0 → 0.4.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.
- metadata +179 -123
- data/.document +0 -5
- data/.rspec +0 -5
- data/.travis.yml +0 -4
- data/Gemfile +0 -37
- data/Gemfile.lock +0 -190
- data/Guardfile +0 -27
- data/Rakefile +0 -49
- data/VERSION +0 -1
- data/api_resource.gemspec +0 -180
- data/lib/api_resource.rb +0 -130
- data/lib/api_resource/association_activation.rb +0 -19
- data/lib/api_resource/associations.rb +0 -218
- data/lib/api_resource/associations/association_proxy.rb +0 -116
- data/lib/api_resource/associations/belongs_to_remote_object_proxy.rb +0 -16
- data/lib/api_resource/associations/dynamic_resource_scope.rb +0 -23
- data/lib/api_resource/associations/generic_scope.rb +0 -68
- data/lib/api_resource/associations/has_many_remote_object_proxy.rb +0 -16
- data/lib/api_resource/associations/has_many_through_remote_object_proxy.rb +0 -13
- data/lib/api_resource/associations/has_one_remote_object_proxy.rb +0 -24
- data/lib/api_resource/associations/multi_argument_resource_scope.rb +0 -15
- data/lib/api_resource/associations/multi_object_proxy.rb +0 -84
- data/lib/api_resource/associations/related_object_hash.rb +0 -12
- data/lib/api_resource/associations/relation_scope.rb +0 -25
- data/lib/api_resource/associations/resource_scope.rb +0 -32
- data/lib/api_resource/associations/scope.rb +0 -132
- data/lib/api_resource/associations/single_object_proxy.rb +0 -82
- data/lib/api_resource/attributes.rb +0 -243
- data/lib/api_resource/base.rb +0 -717
- data/lib/api_resource/callbacks.rb +0 -45
- data/lib/api_resource/connection.rb +0 -195
- data/lib/api_resource/core_extensions.rb +0 -7
- data/lib/api_resource/custom_methods.rb +0 -117
- data/lib/api_resource/decorators.rb +0 -6
- data/lib/api_resource/decorators/caching_decorator.rb +0 -20
- data/lib/api_resource/exceptions.rb +0 -99
- data/lib/api_resource/formats.rb +0 -22
- data/lib/api_resource/formats/json_format.rb +0 -25
- data/lib/api_resource/formats/xml_format.rb +0 -36
- data/lib/api_resource/local.rb +0 -12
- data/lib/api_resource/log_subscriber.rb +0 -15
- data/lib/api_resource/mocks.rb +0 -277
- data/lib/api_resource/model_errors.rb +0 -82
- data/lib/api_resource/observing.rb +0 -27
- data/lib/api_resource/railtie.rb +0 -24
- data/lib/api_resource/scopes.rb +0 -48
- data/nohup.out +0 -63
- data/spec/lib/api_resource_spec.rb +0 -43
- data/spec/lib/associations_spec.rb +0 -751
- data/spec/lib/attributes_spec.rb +0 -191
- data/spec/lib/base_spec.rb +0 -655
- data/spec/lib/callbacks_spec.rb +0 -68
- data/spec/lib/connection_spec.rb +0 -137
- data/spec/lib/local_spec.rb +0 -20
- data/spec/lib/mocks_spec.rb +0 -45
- data/spec/lib/model_errors_spec.rb +0 -29
- data/spec/lib/prefixes_spec.rb +0 -107
- data/spec/spec_helper.rb +0 -82
- data/spec/support/mocks/association_mocks.rb +0 -63
- data/spec/support/mocks/error_resource_mocks.rb +0 -21
- data/spec/support/mocks/prefix_model_mocks.rb +0 -5
- data/spec/support/mocks/test_resource_mocks.rb +0 -44
- data/spec/support/requests/association_requests.rb +0 -31
- data/spec/support/requests/error_resource_requests.rb +0 -25
- data/spec/support/requests/prefix_model_requests.rb +0 -7
- data/spec/support/requests/test_resource_requests.rb +0 -38
- data/spec/support/test_resource.rb +0 -72
- data/spec/tmp/DIR +0 -0
| @@ -1,63 +0,0 @@ | |
| 1 | 
            -
            include ApiResource
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            Mocks.define do
         | 
| 4 | 
            -
              
         | 
| 5 | 
            -
              endpoint('/single_object_association') do
         | 
| 6 | 
            -
                get(HashDealer.roll(:test_association_resource), :params => {})
         | 
| 7 | 
            -
                get(HashDealer.roll(:active_test_association_resource), :params => {:active => true})
         | 
| 8 | 
            -
                get(HashDealer.roll(:active_birthday_test_association_resource), :params => {:active => true, :birthday => true})
         | 
| 9 | 
            -
                get(HashDealer.roll(:inactive_birthday_test_association_resource), :params => {:active => false, :birthday => true})
         | 
| 10 | 
            -
              end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
              endpoint("/mock_with_block/:id") do
         | 
| 13 | 
            -
                get({:abc => 123}, {:params => {:test => "123"}.matcher}) do |params|
         | 
| 14 | 
            -
                  self[:test] = params[:test]
         | 
| 15 | 
            -
                  self[:id] = params[:id]
         | 
| 16 | 
            -
                  self
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
              end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              endpoint('/multi_object_association') do
         | 
| 21 | 
            -
                get((0..4).to_a.collect{HashDealer.roll(:test_association_resource)}, :params => {})
         | 
| 22 | 
            -
                get((0..4).to_a.collect{HashDealer.roll(:active_test_association_resource)}, :params => {:active => true})
         | 
| 23 | 
            -
                get((0..4).to_a.collect{HashDealer.roll(:active_test_association_resource)}, :params => {:active => false})
         | 
| 24 | 
            -
                get((0..4).to_a.collect{HashDealer.roll(:active_birthday_test_association_resource)}, :params => {:active => true, :birthday => true})
         | 
| 25 | 
            -
              end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
              endpoint("/has_one_objects/new") do
         | 
| 28 | 
            -
                get({
         | 
| 29 | 
            -
                  "attributes" => {
         | 
| 30 | 
            -
                    "public" => ["size", "color"]
         | 
| 31 | 
            -
                  }
         | 
| 32 | 
            -
                })
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
              
         | 
| 35 | 
            -
              endpoint("/has_many_objects/new") do
         | 
| 36 | 
            -
                get({
         | 
| 37 | 
            -
                  "attributes" => {
         | 
| 38 | 
            -
                    "public" => ["name"]
         | 
| 39 | 
            -
                  }
         | 
| 40 | 
            -
                })
         | 
| 41 | 
            -
              end
         | 
| 42 | 
            -
              
         | 
| 43 | 
            -
              endpoint("/belongs_to_objects/new") do
         | 
| 44 | 
            -
                get({})
         | 
| 45 | 
            -
              end
         | 
| 46 | 
            -
              
         | 
| 47 | 
            -
              endpoint("/test_associations/new") do
         | 
| 48 | 
            -
                get({})
         | 
| 49 | 
            -
              end
         | 
| 50 | 
            -
              
         | 
| 51 | 
            -
              endpoint("/inner_classes/new") do
         | 
| 52 | 
            -
                get({})
         | 
| 53 | 
            -
              end
         | 
| 54 | 
            -
              
         | 
| 55 | 
            -
              endpoint("/childern/new") do
         | 
| 56 | 
            -
                get({})
         | 
| 57 | 
            -
              end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
              endpoint("/test_throughs/new") do
         | 
| 60 | 
            -
                get({})
         | 
| 61 | 
            -
              end
         | 
| 62 | 
            -
              
         | 
| 63 | 
            -
            end
         | 
| @@ -1,21 +0,0 @@ | |
| 1 | 
            -
            include ApiResource
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            Mocks.define do
         | 
| 4 | 
            -
              
         | 
| 5 | 
            -
              endpoint("/error_resources/new") do
         | 
| 6 | 
            -
                get(HashDealer.roll(:new_error_resource))
         | 
| 7 | 
            -
              end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
              endpoint("/error_resources") do
         | 
| 10 | 
            -
                post(HashDealer.roll(:error_resource_errors), :params => {:error_resource => HashDealer.roll(:error_resource).matcher}, :status_code => 422)
         | 
| 11 | 
            -
              end
         | 
| 12 | 
            -
              
         | 
| 13 | 
            -
              endpoint("/error_full_message_resources/new") do
         | 
| 14 | 
            -
                get(HashDealer.roll(:new_error_resource))
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
              endpoint("/error_full_message_resources") do
         | 
| 18 | 
            -
                post(HashDealer.roll(:error_resource_full_message_errors), :params => {:error_full_message_resource => HashDealer.roll(:error_resource).matcher}, :status_code => 422)
         | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
              
         | 
| 21 | 
            -
            end
         | 
| @@ -1,44 +0,0 @@ | |
| 1 | 
            -
            include ApiResource
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            Mocks.define do
         | 
| 4 | 
            -
              
         | 
| 5 | 
            -
              endpoint("/test_resources/new") do
         | 
| 6 | 
            -
                get(HashDealer.roll(:new_test_object))
         | 
| 7 | 
            -
              end
         | 
| 8 | 
            -
              
         | 
| 9 | 
            -
              endpoint("/test_resources") do
         | 
| 10 | 
            -
                post(HashDealer.roll(:test_resource).merge(:id => 1), :params => {:test_resource => HashDealer.roll(:test_resource).matcher})
         | 
| 11 | 
            -
                post(HashDealer.roll(:test_resource).merge(:id => 1), :params => {:test_resource => HashDealer.roll(:test_resource_with_roles).matcher})
         | 
| 12 | 
            -
                get((0..4).to_a.collect{HashDealer.roll(:test_resource)})
         | 
| 13 | 
            -
                get((0..4).to_a.collect{HashDealer.roll(:test_resource)}, :params => {:active => true})
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
              
         | 
| 16 | 
            -
              endpoint("/test_resources/:id") do
         | 
| 17 | 
            -
                get(HashDealer.roll(:test_resource_with_proxies)) do |params|
         | 
| 18 | 
            -
                  self.merge(params)
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
                delete({})
         | 
| 21 | 
            -
                put({}, :params => {:test_resource => HashDealer.roll(:test_resource).matcher})
         | 
| 22 | 
            -
              end
         | 
| 23 | 
            -
              
         | 
| 24 | 
            -
              endpoint("/child_test_resources/new") do
         | 
| 25 | 
            -
                get({})
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
              
         | 
| 28 | 
            -
              endpoint("/child_test_resource2s/new") do
         | 
| 29 | 
            -
                get({})
         | 
| 30 | 
            -
              end
         | 
| 31 | 
            -
              
         | 
| 32 | 
            -
              endpoint("/another_test_resources/new") do
         | 
| 33 | 
            -
                get({})
         | 
| 34 | 
            -
              end
         | 
| 35 | 
            -
              
         | 
| 36 | 
            -
              endpoint("/test_classes/new") do
         | 
| 37 | 
            -
                get({})
         | 
| 38 | 
            -
              end
         | 
| 39 | 
            -
              
         | 
| 40 | 
            -
              endpoint("/children/new") do
         | 
| 41 | 
            -
                get({})
         | 
| 42 | 
            -
              end
         | 
| 43 | 
            -
              
         | 
| 44 | 
            -
            end
         | 
| @@ -1,31 +0,0 @@ | |
| 1 | 
            -
            HashDealer.define(:test_association_resource) do
         | 
| 2 | 
            -
              id{Kernel.rand(99999)}
         | 
| 3 | 
            -
              name{Faker::Name.first_name}
         | 
| 4 | 
            -
              age{Kernel.rand(99999)}
         | 
| 5 | 
            -
              active(false)
         | 
| 6 | 
            -
            end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            HashDealer.define(:active_test_association_resource, :parent => :test_association_resource) do
         | 
| 9 | 
            -
              active(true)
         | 
| 10 | 
            -
            end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            HashDealer.define(:active_birthday_test_association_resource, :parent => :active_test_association_resource) do
         | 
| 13 | 
            -
              birthday{Date.today}
         | 
| 14 | 
            -
            end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            HashDealer.define(:inactive_test_association_resource, :parent => :test_association_resource) do
         | 
| 17 | 
            -
              active(false)
         | 
| 18 | 
            -
            end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
            HashDealer.define(:inactive_birthday_test_association_resource, :parent => :inactive_test_association_resource) do
         | 
| 21 | 
            -
              birthday{Date.today}
         | 
| 22 | 
            -
            end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
            HashDealer.define(:has_one_object) do
         | 
| 25 | 
            -
              size("large")
         | 
| 26 | 
            -
              color("blue")
         | 
| 27 | 
            -
            end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
            HashDealer.define(:has_many_object) do
         | 
| 30 | 
            -
              name("name")
         | 
| 31 | 
            -
            end
         | 
| @@ -1,25 +0,0 @@ | |
| 1 | 
            -
            HashDealer.define(:new_error_resource) do
         | 
| 2 | 
            -
              attributes({
         | 
| 3 | 
            -
                :protected => [:id],
         | 
| 4 | 
            -
                :public => [:name, :age],
         | 
| 5 | 
            -
              })
         | 
| 6 | 
            -
            end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            HashDealer.define(:error_resource) do
         | 
| 9 | 
            -
              name("Name")
         | 
| 10 | 
            -
              age("age")
         | 
| 11 | 
            -
            end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            HashDealer.define(:error_resource_errors) do
         | 
| 14 | 
            -
              errors({
         | 
| 15 | 
            -
                :name => ["must not be empty"],
         | 
| 16 | 
            -
                :age => ["must be a valid integer"]
         | 
| 17 | 
            -
              })
         | 
| 18 | 
            -
            end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
            HashDealer.define(:error_resource_full_message_errors) do
         | 
| 21 | 
            -
              errors([
         | 
| 22 | 
            -
                "Name cannot be empty",
         | 
| 23 | 
            -
                "Age must be a valid integer"
         | 
| 24 | 
            -
              ])
         | 
| 25 | 
            -
            end
         | 
| @@ -1,38 +0,0 @@ | |
| 1 | 
            -
            HashDealer.define(:new_test_object) do
         | 
| 2 | 
            -
              attributes({
         | 
| 3 | 
            -
                :protected => [:id],
         | 
| 4 | 
            -
                :public => [:name, :age, :is_active, [:bday, :date], [:roles, :array]]
         | 
| 5 | 
            -
              })
         | 
| 6 | 
            -
              scopes({
         | 
| 7 | 
            -
                :active => {:active => :opt},
         | 
| 8 | 
            -
                :paginate => {:per_page => :opt, :current_page => :opt}
         | 
| 9 | 
            -
              })
         | 
| 10 | 
            -
              associations({
         | 
| 11 | 
            -
                :has_many => {:has_many_objects => {}},
         | 
| 12 | 
            -
                :belongs_to => {:belongs_to_object => {}, :custom_name => {:class_name => "BelongsToObject"}},
         | 
| 13 | 
            -
                :has_one => {:has_one_object => {}},
         | 
| 14 | 
            -
              })
         | 
| 15 | 
            -
            end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            HashDealer.define(:test_resource) do
         | 
| 18 | 
            -
              name("name")
         | 
| 19 | 
            -
              age("age")
         | 
| 20 | 
            -
            end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            HashDealer.define(:test_resource_with_roles) do
         | 
| 23 | 
            -
              name("name")
         | 
| 24 | 
            -
              age("age")
         | 
| 25 | 
            -
              roles([])
         | 
| 26 | 
            -
            end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            HashDealer.define(:test_resource_with_proxies, :parent => :test_resource) do
         | 
| 29 | 
            -
              has_one_object{HashDealer.roll(:has_one_object)}
         | 
| 30 | 
            -
              has_many_objects{(0..4).to_a.collect{HashDealer.roll(:has_many_object)}}
         | 
| 31 | 
            -
            end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
            HashDealer.define(:test_resource_errors) do
         | 
| 34 | 
            -
              errors({
         | 
| 35 | 
            -
                :name => ["can't be blank"],
         | 
| 36 | 
            -
                :age => ["must be a valid number"]
         | 
| 37 | 
            -
              })
         | 
| 38 | 
            -
            end
         | 
| @@ -1,72 +0,0 @@ | |
| 1 | 
            -
            class TestResource < ApiResource::Base
         | 
| 2 | 
            -
            end
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            module MyMod
         | 
| 5 | 
            -
              def abc
         | 
| 6 | 
            -
                puts "HI"
         | 
| 7 | 
            -
              end
         | 
| 8 | 
            -
            end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            class LocalResource < ApiResource::Local
         | 
| 11 | 
            -
              include MyMod
         | 
| 12 | 
            -
            end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            class ChildTestResource < TestResource
         | 
| 15 | 
            -
            end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            class AnotherTestResource < ApiResource::Base
         | 
| 18 | 
            -
              
         | 
| 19 | 
            -
            end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
            class HasManyObject < ApiResource::Base
         | 
| 22 | 
            -
            end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
            class BelongsToObject < ApiResource::Base
         | 
| 25 | 
            -
            end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            class HasOneObject < ApiResource::Base
         | 
| 28 | 
            -
            end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            class ErrorResource < ApiResource::Base
         | 
| 31 | 
            -
              
         | 
| 32 | 
            -
            end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            class PrefixModel < ApiResource::Base
         | 
| 35 | 
            -
              self.prefix = "/foreign/:foreign_key_id/"
         | 
| 36 | 
            -
            end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
            class ScopeResource < ApiResource::Base
         | 
| 39 | 
            -
              
         | 
| 40 | 
            -
            end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
            class ErrorFullMessageResource < ApiResource::Base
         | 
| 43 | 
            -
              
         | 
| 44 | 
            -
            end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
            class TestThrough < ApiResource::Base
         | 
| 47 | 
            -
             | 
| 48 | 
            -
            end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
            module TestMod
         | 
| 51 | 
            -
              
         | 
| 52 | 
            -
              module InnerMod
         | 
| 53 | 
            -
                
         | 
| 54 | 
            -
                class InnerClass < ApiResource::Base
         | 
| 55 | 
            -
               
         | 
| 56 | 
            -
                end
         | 
| 57 | 
            -
                
         | 
| 58 | 
            -
              end
         | 
| 59 | 
            -
              
         | 
| 60 | 
            -
              class TestClass < ApiResource::Base
         | 
| 61 | 
            -
                
         | 
| 62 | 
            -
              end
         | 
| 63 | 
            -
              
         | 
| 64 | 
            -
              class TestAssociation < ApiResource::Base
         | 
| 65 | 
            -
                
         | 
| 66 | 
            -
              end
         | 
| 67 | 
            -
              
         | 
| 68 | 
            -
              class TestResource < ApiResource::Base
         | 
| 69 | 
            -
              
         | 
| 70 | 
            -
              end
         | 
| 71 | 
            -
              
         | 
| 72 | 
            -
            end
         | 
    
        data/spec/tmp/DIR
    DELETED
    
    | 
            File without changes
         |