happymapper 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ == 0.1.6 2009-01-17
2
+ * 1 minor enhancement:
3
+ * added support for nested collection elements (Justin Marney)
4
+
5
+ == 0.1.5 2009-01-05
6
+ * 1 major enhancement:
7
+ * Updated to latest version of libxml-ruby (lightningdb)
8
+
1
9
  == 0.1.4 2009-01-05
2
10
  * 1 major enhancement:
3
11
  * Fixed parsing when the object is the root node. (Garret Alfert)
File without changes
@@ -1,32 +1,23 @@
1
- History.txt
2
- License.txt
3
- Manifest.txt
4
- PostInstall.txt
5
- README.txt
6
- Rakefile
7
- TODO.txt
8
- config/hoe.rb
9
- config/requirements.rb
10
1
  examples/amazon.rb
11
2
  examples/current_weather.rb
12
3
  examples/post.rb
13
4
  examples/twitter.rb
14
- happymapper.gemspec
15
- lib/happymapper.rb
5
+ History
16
6
  lib/happymapper/attribute.rb
17
7
  lib/happymapper/element.rb
18
8
  lib/happymapper/item.rb
19
9
  lib/happymapper/version.rb
10
+ lib/happymapper.rb
20
11
  lib/libxml_ext/libxml_helper.rb
21
- script/console
22
- script/destroy
23
- script/generate
24
- script/txt2html
25
- setup.rb
12
+ License
13
+ Manifest
14
+ Rakefile
15
+ README
26
16
  spec/fixtures/address.xml
27
17
  spec/fixtures/current_weather.xml
28
18
  spec/fixtures/pita.xml
29
19
  spec/fixtures/posts.xml
20
+ spec/fixtures/radar.xml
30
21
  spec/fixtures/statuses.xml
31
22
  spec/happymapper_attribute_spec.rb
32
23
  spec/happymapper_element_spec.rb
@@ -34,9 +25,6 @@ spec/happymapper_item_spec.rb
34
25
  spec/happymapper_spec.rb
35
26
  spec/spec.opts
36
27
  spec/spec_helper.rb
37
- tasks/deployment.rake
38
- tasks/environment.rake
39
- tasks/rspec.rake
40
- tasks/website.rake
28
+ TODO
41
29
  website/css/common.css
42
30
  website/index.html
File without changes
data/Rakefile CHANGED
@@ -1,4 +1,43 @@
1
- require 'config/requirements'
2
- require 'config/hoe' # setup Hoe + all gem configuration
1
+ ProjectName = 'happymapper'
2
+ WebsitePath = "jnunemaker@rubyforge.org:/var/www/gforge-projects/#{ProjectName}"
3
3
 
4
- Dir['tasks/**/*.rake'].each { |rake| load rake }
4
+ require 'rubygems'
5
+ require 'rake'
6
+ require 'echoe'
7
+ require 'spec/rake/spectask'
8
+ require "lib/#{ProjectName}/version"
9
+
10
+ Echoe.new(ProjectName, HappyMapper::Version) do |p|
11
+ p.description = "object to xml mapping library"
12
+ p.install_message = "May you have many happy mappings!"
13
+ p.url = "http://#{ProjectName}.rubyforge.org"
14
+ p.author = "John Nunemaker"
15
+ p.email = "nunemaker@gmail.com"
16
+ p.extra_deps = [['libxml-ruby', '>= 0.9.7']]
17
+ p.need_tar_gz = false
18
+ p.docs_host = WebsitePath
19
+ end
20
+
21
+ desc 'Upload website files to rubyforge'
22
+ task :website do
23
+ sh %{rsync -av website/ #{WebsitePath}}
24
+ Rake::Task['website_docs'].invoke
25
+ end
26
+
27
+ task :website_docs do
28
+ Rake::Task['redocs'].invoke
29
+ sh %{rsync -av doc/ #{WebsitePath}/docs}
30
+ end
31
+
32
+ desc 'Preps the gem for a new release'
33
+ task :prepare do
34
+ %w[manifest build_gemspec].each do |task|
35
+ Rake::Task[task].invoke
36
+ end
37
+ end
38
+
39
+ Rake::Task[:default].prerequisites.clear
40
+ task :default => :spec
41
+ Spec::Rake::SpecTask.new do |t|
42
+ t.spec_files = FileList["spec/**/*_spec.rb"]
43
+ end
File without changes
@@ -2,19 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{happymapper}
5
- s.version = "0.1.4"
5
+ s.version = "0.1.6"
6
6
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Nunemaker"]
9
- s.date = %q{2009-01-04}
9
+ s.date = %q{2009-01-17}
10
10
  s.description = %q{object to xml mapping library}
11
- s.email = ["nunemaker@gmail.com"]
12
- s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "TODO.txt"]
13
- s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "TODO.txt", "config/hoe.rb", "config/requirements.rb", "examples/amazon.rb", "examples/current_weather.rb", "examples/post.rb", "examples/twitter.rb", "happymapper.gemspec", "lib/happymapper.rb", "lib/happymapper/attribute.rb", "lib/happymapper/element.rb", "lib/happymapper/item.rb", "lib/happymapper/version.rb", "lib/libxml_ext/libxml_helper.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/fixtures/address.xml", "spec/fixtures/current_weather.xml", "spec/fixtures/pita.xml", "spec/fixtures/posts.xml", "spec/fixtures/statuses.xml", "spec/happymapper_attribute_spec.rb", "spec/happymapper_element_spec.rb", "spec/happymapper_item_spec.rb", "spec/happymapper_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake", "tasks/website.rake", "website/css/common.css", "website/index.html"]
11
+ s.email = %q{nunemaker@gmail.com}
12
+ s.extra_rdoc_files = ["lib/happymapper/attribute.rb", "lib/happymapper/element.rb", "lib/happymapper/item.rb", "lib/happymapper/version.rb", "lib/happymapper.rb", "lib/libxml_ext/libxml_helper.rb", "README", "TODO"]
13
+ s.files = ["examples/amazon.rb", "examples/current_weather.rb", "examples/post.rb", "examples/twitter.rb", "History", "lib/happymapper/attribute.rb", "lib/happymapper/element.rb", "lib/happymapper/item.rb", "lib/happymapper/version.rb", "lib/happymapper.rb", "lib/libxml_ext/libxml_helper.rb", "License", "Manifest", "Rakefile", "README", "spec/fixtures/address.xml", "spec/fixtures/current_weather.xml", "spec/fixtures/pita.xml", "spec/fixtures/posts.xml", "spec/fixtures/radar.xml", "spec/fixtures/statuses.xml", "spec/happymapper_attribute_spec.rb", "spec/happymapper_element_spec.rb", "spec/happymapper_item_spec.rb", "spec/happymapper_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "TODO", "website/css/common.css", "website/index.html", "happymapper.gemspec"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://happymapper.rubyforge.org}
16
- s.post_install_message = %q{}
17
- s.rdoc_options = ["--main", "README.txt"]
16
+ s.post_install_message = %q{May you have many happy mappings!}
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Happymapper", "--main", "README"]
18
18
  s.require_paths = ["lib"]
19
19
  s.rubyforge_project = %q{happymapper}
20
20
  s.rubygems_version = %q{1.3.1}
@@ -25,11 +25,14 @@ Gem::Specification.new do |s|
25
25
  s.specification_version = 2
26
26
 
27
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
- s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
28
+ s.add_runtime_dependency(%q<libxml-ruby>, [">= 0.9.7"])
29
+ s.add_development_dependency(%q<echoe>, [">= 0"])
29
30
  else
30
- s.add_dependency(%q<hoe>, [">= 1.8.0"])
31
+ s.add_dependency(%q<libxml-ruby>, [">= 0.9.7"])
32
+ s.add_dependency(%q<echoe>, [">= 0"])
31
33
  end
32
34
  else
33
- s.add_dependency(%q<hoe>, [">= 1.8.0"])
35
+ s.add_dependency(%q<libxml-ruby>, [">= 0.9.7"])
36
+ s.add_dependency(%q<echoe>, [">= 0"])
34
37
  end
35
- end
38
+ end
@@ -5,7 +5,7 @@ require 'date'
5
5
  require 'time'
6
6
  require 'rubygems'
7
7
 
8
- gem 'libxml-ruby', '>= 0.8.3'
8
+ gem 'libxml-ruby', '>= 0.9.7'
9
9
  require 'xml'
10
10
  require 'libxml_ext/libxml_helper'
11
11
 
@@ -75,7 +75,17 @@ module HappyMapper
75
75
  else
76
76
  doc.find("//#{get_tag_name}")
77
77
  end
78
-
78
+
79
+ nodes = if namespace
80
+ node = doc.respond_to?(:root) ? doc.root : doc
81
+ node.register_default_namespace(namespace.chop)
82
+ node.find("#{namespace}#{get_tag_name}")
83
+ else
84
+ nested = '.' unless doc.respond_to?(:root)
85
+ path = "#{nested}//#{get_tag_name}"
86
+ doc.find(path)
87
+ end
88
+
79
89
  collection = create_collection(nodes, namespace)
80
90
 
81
91
  # per http://libxml.rubyforge.org/rdoc/classes/LibXML/XML/Document.html#M000354
@@ -120,4 +130,4 @@ end
120
130
 
121
131
  require 'happymapper/item'
122
132
  require 'happymapper/attribute'
123
- require 'happymapper/element'
133
+ require 'happymapper/element'
@@ -1,9 +1,3 @@
1
1
  module HappyMapper
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 1
5
- TINY = 4
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
2
+ Version = '0.1.6'
9
3
  end
@@ -54,7 +54,7 @@ class XML::Node
54
54
 
55
55
  # provide a name for the default namespace
56
56
  def register_default_namespace(name)
57
- default_namespace = namespace.detect { |n| n.to_s == nil }
57
+ default_namespace = namespaces.default
58
58
 
59
59
  if default_namespace
60
60
  register_namespace("#{name}:#{default_namespace.href}")
@@ -90,4 +90,4 @@ class String
90
90
  xp.string = self
91
91
  return xp.parse
92
92
  end
93
- end
93
+ end
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <radars>
3
+ <radar>
4
+ <places>
5
+ <place>
6
+ <name>Store</name>
7
+ </place>
8
+ </places>
9
+ </radar>
10
+ <radar></radar>
11
+ <radar>
12
+ <places>
13
+ <place>
14
+ <name>Work</name>
15
+ </place>
16
+ <place>
17
+ <name>Home</name>
18
+ </place>
19
+ </places>
20
+ </radar>
21
+ </radars>
@@ -1,5 +1,16 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
+ class Place
4
+ include HappyMapper
5
+
6
+ element :name, String
7
+ end
8
+
9
+ class Radar
10
+ include HappyMapper
11
+ has_many :places, Place
12
+ end
13
+
3
14
  class Post
4
15
  include HappyMapper
5
16
 
@@ -261,4 +272,23 @@ describe HappyMapper do
261
272
  @first.current_condition.icon.should == 'http://deskwx.weatherbug.com/images/Forecast/icons/cond007.gif'
262
273
  end
263
274
  end
275
+
276
+ describe "#parse (with xml that has nested elements)" do
277
+ before do
278
+ file_contents = File.read(File.dirname(__FILE__) + '/fixtures/radar.xml')
279
+ @radars = Radar.parse(file_contents)
280
+ end
281
+
282
+ it "should properly create objects" do
283
+ @first = @radars[0]
284
+ @first.places.size.should == 1
285
+ @first.places[0].name.should == 'Store'
286
+ @second = @radars[1]
287
+ @second.places.size.should == 0
288
+ @third = @radars[2]
289
+ @third.places.size.should == 2
290
+ @third.places[0].name.should == 'Work'
291
+ @third.places[1].name.should == 'Home'
292
+ end
293
+ end
264
294
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happymapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,63 +9,65 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-04 00:00:00 -05:00
12
+ date: 2009-01-17 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: hoe
16
+ name: libxml-ruby
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.7
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: echoe
17
27
  type: :development
18
28
  version_requirement:
19
29
  version_requirements: !ruby/object:Gem::Requirement
20
30
  requirements:
21
31
  - - ">="
22
32
  - !ruby/object:Gem::Version
23
- version: 1.8.0
33
+ version: "0"
24
34
  version:
25
35
  description: object to xml mapping library
26
- email:
27
- - nunemaker@gmail.com
36
+ email: nunemaker@gmail.com
28
37
  executables: []
29
38
 
30
39
  extensions: []
31
40
 
32
41
  extra_rdoc_files:
33
- - History.txt
34
- - License.txt
35
- - Manifest.txt
36
- - PostInstall.txt
37
- - README.txt
38
- - TODO.txt
42
+ - lib/happymapper/attribute.rb
43
+ - lib/happymapper/element.rb
44
+ - lib/happymapper/item.rb
45
+ - lib/happymapper/version.rb
46
+ - lib/happymapper.rb
47
+ - lib/libxml_ext/libxml_helper.rb
48
+ - README
49
+ - TODO
39
50
  files:
40
- - History.txt
41
- - License.txt
42
- - Manifest.txt
43
- - PostInstall.txt
44
- - README.txt
45
- - Rakefile
46
- - TODO.txt
47
- - config/hoe.rb
48
- - config/requirements.rb
49
51
  - examples/amazon.rb
50
52
  - examples/current_weather.rb
51
53
  - examples/post.rb
52
54
  - examples/twitter.rb
53
- - happymapper.gemspec
54
- - lib/happymapper.rb
55
+ - History
55
56
  - lib/happymapper/attribute.rb
56
57
  - lib/happymapper/element.rb
57
58
  - lib/happymapper/item.rb
58
59
  - lib/happymapper/version.rb
60
+ - lib/happymapper.rb
59
61
  - lib/libxml_ext/libxml_helper.rb
60
- - script/console
61
- - script/destroy
62
- - script/generate
63
- - script/txt2html
64
- - setup.rb
62
+ - License
63
+ - Manifest
64
+ - Rakefile
65
+ - README
65
66
  - spec/fixtures/address.xml
66
67
  - spec/fixtures/current_weather.xml
67
68
  - spec/fixtures/pita.xml
68
69
  - spec/fixtures/posts.xml
70
+ - spec/fixtures/radar.xml
69
71
  - spec/fixtures/statuses.xml
70
72
  - spec/happymapper_attribute_spec.rb
71
73
  - spec/happymapper_element_spec.rb
@@ -73,18 +75,20 @@ files:
73
75
  - spec/happymapper_spec.rb
74
76
  - spec/spec.opts
75
77
  - spec/spec_helper.rb
76
- - tasks/deployment.rake
77
- - tasks/environment.rake
78
- - tasks/rspec.rake
79
- - tasks/website.rake
78
+ - TODO
80
79
  - website/css/common.css
81
80
  - website/index.html
81
+ - happymapper.gemspec
82
82
  has_rdoc: true
83
83
  homepage: http://happymapper.rubyforge.org
84
- post_install_message: ""
84
+ post_install_message: May you have many happy mappings!
85
85
  rdoc_options:
86
+ - --line-numbers
87
+ - --inline-source
88
+ - --title
89
+ - Happymapper
86
90
  - --main
87
- - README.txt
91
+ - README
88
92
  require_paths:
89
93
  - lib
90
94
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -97,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
101
  requirements:
98
102
  - - ">="
99
103
  - !ruby/object:Gem::Version
100
- version: "0"
104
+ version: "1.2"
101
105
  version:
102
106
  requirements: []
103
107
 
File without changes
@@ -1,73 +0,0 @@
1
- require 'happymapper/version'
2
-
3
- AUTHOR = 'John Nunemaker' # can also be an array of Authors
4
- EMAIL = "nunemaker@gmail.com"
5
- DESCRIPTION = "object to xml mapping library"
6
- GEM_NAME = 'happymapper' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'happymapper' # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
- EXTRA_DEPENDENCIES = [
11
- ['libxml-ruby', '>= 0.8.3']
12
- ]
13
-
14
- @config_file = "~/.rubyforge/user-config.yml"
15
- @config = nil
16
- RUBYFORGE_USERNAME = "unknown"
17
- def rubyforge_username
18
- unless @config
19
- begin
20
- @config = YAML.load(File.read(File.expand_path(@config_file)))
21
- rescue
22
- puts <<-EOS
23
- ERROR: No rubyforge config file found: #{@config_file}
24
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
- - See http://newgem.rubyforge.org/rubyforge.html for more details
26
- EOS
27
- exit
28
- end
29
- end
30
- RUBYFORGE_USERNAME.replace @config["username"]
31
- end
32
-
33
-
34
- REV = nil
35
- # UNCOMMENT IF REQUIRED:
36
- # REV = YAML.load(`svn info`)['Revision']
37
- VERS = HappyMapper::VERSION::STRING + (REV ? ".#{REV}" : "")
38
- RDOC_OPTS = ['--quiet', '--title', 'happymapper documentation',
39
- "--opname", "index.html",
40
- "--line-numbers",
41
- "--main", "README",
42
- "--inline-source"]
43
-
44
- class Hoe
45
- def extra_deps
46
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
- @extra_deps
48
- end
49
- end
50
-
51
- # Generate all the Rake tasks
52
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
- $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
- p.developer(AUTHOR, EMAIL)
55
- p.description = DESCRIPTION
56
- p.summary = DESCRIPTION
57
- p.url = HOMEPATH
58
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
- p.test_globs = ["test/**/test_*.rb"]
60
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
-
62
- # == Optional
63
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
- #p.extra_deps = EXTRA_DEPENDENCIES
65
-
66
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
- end
68
-
69
- CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
- $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
- $hoe.rsync_args = '-av --delete --ignore-errors'
73
- $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""