zilkey-active_api 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -80,7 +80,7 @@ ActiveApi is highly extensible. The general pattern used to extend ActiveApi is
80
80
 
81
81
  For example, if you are working with a database that has audit columns such as timestamps, you might want to do this:
82
82
 
83
- class MyDefinitionClass < Definition
83
+ class MyDefinitionClass < ActiveApi::Definition
84
84
  def timestamps
85
85
  date_time :created_at
86
86
  date_time :updated_at
@@ -158,6 +158,7 @@ While I (Jeff Dean) wrote all of the code in this repo, the code was inspired by
158
158
 
159
159
  * Mike Dalessio
160
160
  * Peter Jaros
161
+ * Ben Woosely
161
162
 
162
163
  == Development
163
164
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/active_api.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{active_api}
5
- s.version = "0.1.0"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeff Dean"]
@@ -95,6 +95,7 @@ module ActiveApi
95
95
  end
96
96
 
97
97
  def formatted_text
98
+ return nil if text.blank?
98
99
  (self.class.format_procs[format] || self.class.default_format_proc).call(text)
99
100
  end
100
101
 
data/spec/api_spec.rb CHANGED
@@ -87,7 +87,19 @@ module ActiveApi
87
87
  doc.xpath("/articles/article/published_on").first.inner_text.should == "1956-03-05"
88
88
  end
89
89
 
90
- it "emits the correctly formatted element" do
90
+ it "emits nil when the value is nil" do
91
+ @schema = Schema.version(:v1) do |xsl|
92
+ xsl.define :article do |t|
93
+ t.date :published_on
94
+ end
95
+ end
96
+ @article.published_on = nil
97
+ element = Collection.new [@article], :node => :article, :schema => @schema
98
+ doc = element.build_xml.doc
99
+ doc.xpath("/articles/article/published_on").first.inner_text.should == ""
100
+ end
101
+
102
+ it "emits the correctly formatted attribute" do
91
103
  @schema = Schema.version(:v1) do |xsl|
92
104
  xsl.define :article do |t|
93
105
  t.attribute :published_on, :type => :date
@@ -97,6 +109,18 @@ module ActiveApi
97
109
  doc = element.build_xml.doc
98
110
  doc.xpath("/articles/article[@published_on=1956-03-05]").should be
99
111
  end
112
+
113
+ it "emits nil when the attribute value is nil" do
114
+ @schema = Schema.version(:v1) do |xsl|
115
+ xsl.define :article do |t|
116
+ t.attribute :published_on, :type => :date
117
+ end
118
+ end
119
+ @article.published_on = nil
120
+ element = Collection.new [@article], :node => :article, :schema => @schema
121
+ doc = element.build_xml.doc
122
+ doc.xpath("/articles/article[@published_on='']").should be
123
+ end
100
124
  end
101
125
 
102
126
  describe "with a has_many element" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zilkey-active_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dean