acfs 0.2.0 → 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.
Files changed (45) hide show
  1. data/.gitignore +0 -1
  2. data/.travis.yml +1 -3
  3. data/{LICENSE.txt → LICENSE} +0 -0
  4. data/README.md +45 -7
  5. data/acfs.gemspec +3 -0
  6. data/gemfiles/{Gemfile.rails-3-1 → Gemfile.rails-4-0} +2 -2
  7. data/lib/acfs.rb +49 -5
  8. data/lib/acfs/adapter/typhoeus.rb +42 -0
  9. data/lib/acfs/collection.rb +22 -0
  10. data/lib/acfs/middleware/base.rb +21 -0
  11. data/lib/acfs/middleware/json_decoder.rb +15 -0
  12. data/lib/acfs/middleware/print.rb +23 -0
  13. data/lib/acfs/model.rb +25 -12
  14. data/lib/acfs/{attributes.rb → model/attributes.rb} +36 -40
  15. data/lib/acfs/model/attributes/integer.rb +18 -0
  16. data/lib/acfs/model/attributes/string.rb +18 -0
  17. data/lib/acfs/{initialization.rb → model/initialization.rb} +4 -1
  18. data/lib/acfs/model/loadable.rb +18 -0
  19. data/lib/acfs/model/locatable.rb +24 -0
  20. data/lib/acfs/model/query_methods.rb +66 -0
  21. data/lib/acfs/model/relations.rb +10 -0
  22. data/lib/acfs/model/service.rb +29 -0
  23. data/lib/acfs/request.rb +33 -0
  24. data/lib/acfs/request/callbacks.rb +46 -0
  25. data/lib/acfs/response.rb +21 -0
  26. data/lib/acfs/response/formats.rb +12 -0
  27. data/lib/acfs/service.rb +30 -0
  28. data/lib/acfs/version.rb +1 -1
  29. data/spec/acfs/middleware/json_decoder_spec.rb +45 -0
  30. data/spec/acfs/request/callbacks_spec.rb +34 -0
  31. data/spec/acfs/request_spec.rb +71 -0
  32. data/spec/acfs_spec.rb +69 -0
  33. data/spec/{attributes_spec.rb → model/attributes_spec.rb} +25 -12
  34. data/spec/model/initialization_spec.rb +30 -0
  35. data/spec/model/locatable_spec.rb +15 -0
  36. data/spec/service_spec.rb +37 -0
  37. data/spec/spec_helper.rb +2 -0
  38. data/spec/support/service.rb +24 -0
  39. metadata +89 -23
  40. data/lib/acfs/attributes/integer.rb +0 -15
  41. data/lib/acfs/attributes/string.rb +0 -15
  42. data/lib/acfs/client.rb +0 -15
  43. data/spec/client_spec.rb +0 -12
  44. data/spec/initialization_spec.rb +0 -22
  45. data/spec/support/my_client.rb +0 -12
@@ -1,15 +0,0 @@
1
- module Acfs::Attributes
2
-
3
- # Integer attribute type. Use it in your model as an attribute type:
4
- #
5
- # class User
6
- # attribute :name, :integer
7
- # end
8
- #
9
- module Integer # :nodoc:
10
-
11
- def self.cast(obj)
12
- obj.to_i
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- module Acfs::Attributes
2
-
3
- # String attribute type. Use it in your model as an attribute type:
4
- #
5
- # class User
6
- # attribute :name, :string
7
- # end
8
- #
9
- module String # :nodoc:
10
-
11
- def self.cast(obj)
12
- obj.to_s
13
- end
14
- end
15
- end
data/lib/acfs/client.rb DELETED
@@ -1,15 +0,0 @@
1
- require 'active_support/core_ext/class/attribute_accessors'
2
-
3
- module Acfs
4
- module Client
5
- def self.included(base)
6
- base.class_eval do
7
- cattr_accessor :base_url
8
- end
9
- end
10
-
11
- def initialize
12
-
13
- end
14
- end
15
- end
data/spec/client_spec.rb DELETED
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Acfs::Client do
4
- let(:client) { MyClient }
5
-
6
- it "should have a base_url configuration option" do
7
- client.base_url = 'http://abc.de/api/v1'
8
-
9
- expect(client.base_url).to eq('http://abc.de/api/v1')
10
- end
11
-
12
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Acfs::Initialization do
4
- let(:model) { MyModel }
5
-
6
- describe '#initialize' do
7
- it 'should allow to set attributes with initializer' do
8
- model = MyModel.new(name: "John")
9
- expect(model.name).to be == "John"
10
- end
11
-
12
- it 'should raise error when attributes with private setters are given' do
13
- expect { MyModel.new(age: 25) }.to raise_error(NoMethodError)
14
- end
15
- end
16
-
17
- describe '#persisted?' do
18
- it 'should be false' do
19
- expect(MyModel.new.persisted?).to be_false
20
- end
21
- end
22
- end
@@ -1,12 +0,0 @@
1
-
2
- class MyClient
3
- include Acfs::Client
4
-
5
- end
6
-
7
- class MyModel
8
- include Acfs::Model
9
-
10
- attr_accessor :name, :age
11
- private :age=
12
- end