badcarl-dm-googlebase 0.0.3 → 0.0.4

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{dm-googlebase}
5
- s.version = "0.0.3"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Carl Porth"]
9
- s.date = %q{2009-07-28}
9
+ s.date = %q{2009-07-29}
10
10
  s.email = %q{badcarl@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  "lib/googlebase.rb",
24
24
  "lib/googlebase/adapter.rb",
25
25
  "lib/googlebase/product.rb",
26
+ "lib/googlebase/product_properties.rb",
26
27
  "spec/googlebase/adapter_spec.rb",
27
28
  "spec/googlebase/product_spec.rb",
28
29
  "spec/spec_helper.rb",
data/lib/googlebase.rb CHANGED
@@ -7,5 +7,6 @@ module GoogleBase
7
7
 
8
8
  require dir / 'adapter'
9
9
 
10
- autoload :Product, dir / 'product'
10
+ autoload :Product, dir / 'product'
11
+ autoload :ProductProperties, dir / 'product_properties'
11
12
  end
@@ -1,41 +1,6 @@
1
- require "dm-types/uri"
2
- require "dm-validations"
3
-
4
1
  module GoogleBase
5
2
  class Product
6
3
  include DataMapper::Resource
7
-
8
- property :id, String, :key => true, :nullable => true, :length => 255, :from_xml => 'xmlns:id'
9
- property :title, String, :from_xml => 'xmlns:title', :length => 70,
10
- :to_xml => lambda { |xml, value| xml.title value }
11
- property :description, Text, :field => 'content', :from_xml => 'xmlns:content', :lazy => false
12
- property :link, URI, :from_xml => "xmlns:link[@rel='alternate']/@href",
13
- :to_xml => lambda { |xml, value| xml.link :href => value, :type => 'text/html', :rel => 'alternate' }
14
- property :condition, String, :field => 'g:condition', :nullable => false # :set => %w[ new used refurbished ], :default => 'new',
15
- property :product_type, String, :field => 'g:product_type', :length => 255
16
- property :image_link, URI, :field => 'g:image_link'
17
- property :product_id, String, :field => 'g:id', :nullable => false
18
- property :price, String, :field => 'g:price', :nullable => false
19
- property :brand, String, :field => 'g:brand'
20
- property :item_type, String, :field => 'g:item_type', :nullable => false, :set => %w[ Products Produkte ], :default => 'Products'
21
-
22
- # optional
23
- property :expires_at, DateTime, :field => 'g:expiration_date',
24
- :to_xml => lambda { |xml, value| xml.tag! 'g:expiration_date', value.strftime('%F') }
25
- property :quantity, Integer, :field => 'g:quantity'
26
- property :payment_accepted, String,
27
- :from_xml => lambda { |entry| entry.xpath('./g:payment').map { |e| e.content }.join(',') },
28
- :to_xml => lambda { |xml, values| values.split(',').each { |value| xml.tag! 'g:payment_accepted', value } }
29
- property :item_language, String, :field => 'g:item_language'
30
- property :target_country, String, :field => 'g:target_country'
31
-
32
- # read only
33
- property :created_at, DateTime, :field => 'xmlns:published', :to_xml => false
34
- property :updated_at, DateTime, :field => 'xmlns:updated', :to_xml => false
35
- property :category, String, :field => 'xmlns:category/@term', :to_xml => false
36
- property :author_name, String, :field => 'xmlns:author/xmlns:name', :to_xml => false
37
- property :author_email, String, :field => 'xmlns:author/xmlns:email', :to_xml => false
38
- property :customer_id, Integer, :field => 'g:customer_id', :to_xml => false
39
- property :feed_link, URI, :field => 'gd:feedLink/@href', :to_xml => false
4
+ include GoogleBase::ProductProperties
40
5
  end
41
6
  end
@@ -0,0 +1,40 @@
1
+ require 'extlib/lazy_module'
2
+ require 'dm-types/uri'
3
+ require 'dm-validations'
4
+
5
+ module GoogleBase
6
+ ProductProperties = LazyModule.new do
7
+ property :id, String, :key => true, :nullable => true, :length => 255, :from_xml => 'xmlns:id'
8
+ property :title, String, :from_xml => 'xmlns:title', :length => 70,
9
+ :to_xml => lambda { |xml, value| xml.title value }
10
+ property :description, DataMapper::Types::Text, :field => 'content', :from_xml => 'xmlns:content', :lazy => false
11
+ property :link, URI, :from_xml => "xmlns:link[@rel='alternate']/@href",
12
+ :to_xml => lambda { |xml, value| xml.link :href => value, :type => 'text/html', :rel => 'alternate' }
13
+ property :condition, String, :field => 'g:condition', :nullable => false # :set => %w[ new used refurbished ], :default => 'new',
14
+ property :product_type, String, :field => 'g:product_type', :length => 255
15
+ property :image_link, URI, :field => 'g:image_link'
16
+ property :product_id, String, :field => 'g:id', :nullable => false
17
+ property :price, String, :field => 'g:price', :nullable => false
18
+ property :brand, String, :field => 'g:brand'
19
+ property :item_type, String, :field => 'g:item_type', :nullable => false, :set => %w[ Products Produkte ], :default => 'Products'
20
+
21
+ # optional
22
+ property :expires_at, DateTime, :field => 'g:expiration_date',
23
+ :to_xml => lambda { |xml, value| xml.tag! 'g:expiration_date', value.strftime('%F') }
24
+ property :quantity, Integer, :field => 'g:quantity'
25
+ property :payment_accepted, String,
26
+ :from_xml => lambda { |entry| entry.xpath('./g:payment').map { |e| e.content }.join(',') },
27
+ :to_xml => lambda { |xml, values| values.split(',').each { |value| xml.tag! 'g:payment_accepted', value } }
28
+ property :item_language, String, :field => 'g:item_language'
29
+ property :target_country, String, :field => 'g:target_country'
30
+
31
+ # read only
32
+ property :created_at, DateTime, :field => 'xmlns:published', :to_xml => false
33
+ property :updated_at, DateTime, :field => 'xmlns:updated', :to_xml => false
34
+ property :category, String, :field => 'xmlns:category/@term', :to_xml => false
35
+ property :author_name, String, :field => 'xmlns:author/xmlns:name', :to_xml => false
36
+ property :author_email, String, :field => 'xmlns:author/xmlns:email', :to_xml => false
37
+ property :customer_id, Integer, :field => 'g:customer_id', :to_xml => false
38
+ property :feed_link, URI, :field => 'gd:feedLink/@href', :to_xml => false
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badcarl-dm-googlebase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Porth
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-28 00:00:00 -07:00
12
+ date: 2009-07-29 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -102,6 +102,7 @@ files:
102
102
  - lib/googlebase.rb
103
103
  - lib/googlebase/adapter.rb
104
104
  - lib/googlebase/product.rb
105
+ - lib/googlebase/product_properties.rb
105
106
  - spec/googlebase/adapter_spec.rb
106
107
  - spec/googlebase/product_spec.rb
107
108
  - spec/spec_helper.rb