ricordami 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.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog #
2
2
 
3
+ ## 0.0.3 (March 12th, 2011)
4
+
5
+ - added serialization (use: "model\_can :be_serialized") to have
6
+ access to Model#to_json and Model#to_xml
7
+
3
8
  ## 0.0.2 (March 5th, 2011)
4
9
 
5
10
  - added examples and fixed README
@@ -0,0 +1,12 @@
1
+ require "active_model"
2
+
3
+ module Ricordami
4
+ module CanBeSerialized
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include ActiveModel::Serializers::JSON
9
+ include ActiveModel::Serializers::Xml
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Ricordami
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+ require "ricordami/can_be_serialized"
3
+
4
+ describe Ricordami::CanBeSerialized do
5
+ uses_constants("User", "Car")
6
+
7
+ it "returns a JSON representation string with #to_json" do
8
+ User.model_can :be_serialized
9
+ User.attribute :name
10
+ User.attribute :age
11
+ zhanna = User.create(:id => "plou", :name => "Zhannulia", :age => 29)
12
+ decoded = ActiveSupport::JSON.decode(zhanna.to_json)
13
+ decoded.should == {"user" => {"id" => "plou", "name" => "Zhannulia", "age" => "29"}}
14
+ end
15
+
16
+ it "returns a XML representation string with #to_xml" do
17
+ Car.model_can :be_serialized
18
+ new_car = Car.create(:id => "prius")
19
+ new_car.to_xml.should ==<<EOS
20
+ <?xml version="1.0" encoding="UTF-8"?>
21
+ <car>
22
+ <id>prius</id>
23
+ </car>
24
+ EOS
25
+ end
26
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ricordami
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mathieu Lajugie
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-05 00:00:00 -08:00
13
+ date: 2011-03-12 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -149,6 +149,7 @@ files:
149
149
  - lib/ricordami.rb
150
150
  - lib/ricordami/attribute.rb
151
151
  - lib/ricordami/can_be_queried.rb
152
+ - lib/ricordami/can_be_serialized.rb
152
153
  - lib/ricordami/can_be_validated.rb
153
154
  - lib/ricordami/can_have_relationships.rb
154
155
  - lib/ricordami/configuration.rb
@@ -173,6 +174,7 @@ files:
173
174
  - spec/acceptance_helper.rb
174
175
  - spec/ricordami/attribute_spec.rb
175
176
  - spec/ricordami/can_be_queried_spec.rb
177
+ - spec/ricordami/can_be_serialized_spec.rb
176
178
  - spec/ricordami/can_be_validated_spec.rb
177
179
  - spec/ricordami/can_have_relationships_spec.rb
178
180
  - spec/ricordami/configuration_spec.rb
@@ -235,6 +237,7 @@ test_files:
235
237
  - spec/acceptance_helper.rb
236
238
  - spec/ricordami/attribute_spec.rb
237
239
  - spec/ricordami/can_be_queried_spec.rb
240
+ - spec/ricordami/can_be_serialized_spec.rb
238
241
  - spec/ricordami/can_be_validated_spec.rb
239
242
  - spec/ricordami/can_have_relationships_spec.rb
240
243
  - spec/ricordami/configuration_spec.rb