representative 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document CHANGED
@@ -1,5 +1,3 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
1
+ README.markdown
5
2
  LICENSE
3
+ lib/**/*.rb
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.sw?
2
2
  .DS_Store
3
+ .yardoc
3
4
  coverage
4
- rdoc
5
+ doc
5
6
  pkg
data/README.markdown CHANGED
@@ -87,10 +87,17 @@ Notice that:
87
87
 
88
88
  - Representative generates elements for each object-attribute you name (and not the ones you don't).
89
89
  - The structure of the XML mirrors the structure described by the nested Ruby blocks.
90
- - Using **list_of!** for a collection attribute generates an "array" element, which plays nicely
90
+ - Using `list_of!` for a collection attribute generates an "array" element, which plays nicely
91
91
  with most Ruby XML-to-hash converters.
92
92
  - Where a named object-attribute is nil, you get an empty element.
93
93
 
94
+ Installation
95
+ ------------
96
+
97
+ Representative is packaged as a Gem, hosted on [gemcutter](http://gemcutter.org/gems/representative). Install with:
98
+
99
+ sudo gem install representative --source http://gemcutter.org
100
+
94
101
  Copyright
95
102
  ---------
96
103
 
data/Rakefile CHANGED
@@ -2,6 +2,8 @@ require "rubygems"
2
2
  require "rake"
3
3
  require "rake/clean"
4
4
 
5
+ require File.dirname(__FILE__) + "/lib/representative/version.rb"
6
+
5
7
  task :default => :spec
6
8
 
7
9
  def with_gem(gem_name, lib = gem_name)
@@ -18,6 +20,7 @@ with_gem "jeweler" do
18
20
 
19
21
  Jeweler::Tasks.new do |gem|
20
22
  gem.name = "representative"
23
+ gem.version = Representative::VERSION
21
24
  gem.summary = "Builds XML representations of your Ruby objects"
22
25
  gem.email = "mdub@dogbiscuit.org"
23
26
  gem.homepage = "http://github.com/mdub/representative"
@@ -42,11 +45,11 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
42
45
  spec.rcov = true
43
46
  end
44
47
 
45
- # with_gem "yard" do
46
- #
47
- # YARD::Rake::YardocTask.new(:yardoc) do |t|
48
- # t.files = FileList['lib/**/*.rb']
49
- # end
50
- # CLEAN << "doc"
51
- #
52
- # end
48
+ with_gem "yard" do
49
+
50
+ YARD::Rake::YardocTask.new(:yardoc) do |t|
51
+ t.files = FileList['lib/**/*.rb']
52
+ end
53
+ CLEAN << "doc"
54
+
55
+ end
@@ -0,0 +1,5 @@
1
+ module Representative
2
+
3
+ EMPTY = Proc.new {}.freeze
4
+
5
+ end
@@ -0,0 +1,3 @@
1
+ module Representative
2
+ VERSION = "0.1.1"
3
+ end
@@ -1,5 +1,6 @@
1
1
  require "builder"
2
2
  require "active_support"
3
+ require "representative/empty"
3
4
 
4
5
  module Representative
5
6
 
@@ -41,8 +42,10 @@ module Representative
41
42
  def element!(element_name, value, options, &block)
42
43
  text = content_generator = nil
43
44
  if block && value
44
- content_generator = Proc.new do
45
- block.call(Representative::Xml.new(@xml, value))
45
+ unless block == Representative::EMPTY
46
+ content_generator = Proc.new do
47
+ block.call(Representative::Xml.new(@xml, value))
48
+ end
46
49
  end
47
50
  else
48
51
  text = value
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{representative}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mike Williams"]
12
- s.date = %q{2009-10-14}
12
+ s.date = %q{2009-12-02}
13
13
  s.email = %q{mdub@dogbiscuit.org}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -21,10 +21,11 @@ Gem::Specification.new do |s|
21
21
  "LICENSE",
22
22
  "README.markdown",
23
23
  "Rakefile",
24
- "VERSION",
25
24
  "examples/xml_demo.rb",
26
25
  "init.rb",
27
26
  "lib/representative.rb",
27
+ "lib/representative/empty.rb",
28
+ "lib/representative/version.rb",
28
29
  "lib/representative/xml.rb",
29
30
  "representative.gemspec",
30
31
  "spec/representative/xml_spec.rb",
@@ -54,3 +55,4 @@ Gem::Specification.new do |s|
54
55
  s.add_dependency(%q<activesupport>, [">= 2.2.2"])
55
56
  end
56
57
  end
58
+
@@ -138,6 +138,16 @@ describe Representative::Xml do
138
138
  end
139
139
 
140
140
  end
141
+
142
+ describe "with Representative::Empty" do
143
+
144
+ it "generates an empty element" do
145
+ @subject.vehicle = OpenStruct.new(:year => "1959", :make => "Chevrolet")
146
+ represent.vehicle(:year => :year, &Representative::EMPTY)
147
+ resulting_xml.should == %(<vehicle year="1959"/>)
148
+ end
149
+
150
+ end
141
151
 
142
152
  end
143
153
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: representative
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-14 00:00:00 +11:00
12
+ date: 2009-12-02 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -37,10 +37,11 @@ files:
37
37
  - LICENSE
38
38
  - README.markdown
39
39
  - Rakefile
40
- - VERSION
41
40
  - examples/xml_demo.rb
42
41
  - init.rb
43
42
  - lib/representative.rb
43
+ - lib/representative/empty.rb
44
+ - lib/representative/version.rb
44
45
  - lib/representative/xml.rb
45
46
  - representative.gemspec
46
47
  - spec/representative/xml_spec.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.0