dm-serializer 0.10.2 → 1.0.0.rc1
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/.gitignore +36 -0
- data/Gemfile +146 -0
- data/Rakefile +6 -6
- data/VERSION +1 -1
- data/benchmarks/to_json.rb +1 -1
- data/benchmarks/to_xml.rb +1 -1
- data/dm-serializer.gemspec +33 -18
- data/lib/dm-serializer/common.rb +17 -7
- data/lib/dm-serializer/to_csv.rb +20 -14
- data/lib/dm-serializer/to_json.rb +13 -5
- data/lib/dm-serializer/to_xml.rb +31 -24
- data/lib/dm-serializer/to_yaml.rb +12 -5
- data/lib/dm-serializer.rb +9 -0
- data/spec/fixtures/planet.rb +1 -1
- data/spec/lib/serialization_method_shared_spec.rb +21 -16
- data/spec/public/to_csv_spec.rb +19 -11
- data/spec/spec_helper.rb +11 -36
- data/tasks/local_gemfile.rake +18 -0
- data/tasks/spec.rake +0 -3
- metadata +88 -41
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            ## MAC OS
         | 
| 2 | 
            +
            .DS_Store
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            ## TEXTMATE
         | 
| 5 | 
            +
            *.tmproj
         | 
| 6 | 
            +
            tmtags
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ## EMACS
         | 
| 9 | 
            +
            *~
         | 
| 10 | 
            +
            \#*
         | 
| 11 | 
            +
            .\#*
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ## VIM
         | 
| 14 | 
            +
            *.swp
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            ## Rubinius
         | 
| 17 | 
            +
            *.rbc
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ## PROJECT::GENERAL
         | 
| 20 | 
            +
            *.gem
         | 
| 21 | 
            +
            coverage
         | 
| 22 | 
            +
            rdoc
         | 
| 23 | 
            +
            pkg
         | 
| 24 | 
            +
            tmp
         | 
| 25 | 
            +
            doc
         | 
| 26 | 
            +
            log
         | 
| 27 | 
            +
            .yardoc
         | 
| 28 | 
            +
            measurements
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            ## BUNDLER
         | 
| 31 | 
            +
            .bundle
         | 
| 32 | 
            +
            Gemfile.local
         | 
| 33 | 
            +
            Gemfile.lock
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            ## PROJECT::SPECIFIC
         | 
| 36 | 
            +
            spec/db/
         | 
    
        data/Gemfile
    ADDED
    
    | @@ -0,0 +1,146 @@ | |
| 1 | 
            +
            # If you're working on more than one datamapper gem at a time, then it's
         | 
| 2 | 
            +
            # recommended to create a local Gemfile and use this instead of the git
         | 
| 3 | 
            +
            # sources. This will make sure that you are  developing against your
         | 
| 4 | 
            +
            # other local datamapper sources that you currently work on. Gemfile.local
         | 
| 5 | 
            +
            # will behave identically to the standard Gemfile apart from the fact that
         | 
| 6 | 
            +
            # it fetches the datamapper gems from local paths. This means that you can use
         | 
| 7 | 
            +
            # the same environment variables, like ADAPTER(S) or PLUGIN(S) when running
         | 
| 8 | 
            +
            # bundle commands. Gemfile.local is added to .gitignore, so you don't need to
         | 
| 9 | 
            +
            # worry about accidentally checking local development paths into git.
         | 
| 10 | 
            +
            # In order to create a local Gemfile, all you need to do is run:
         | 
| 11 | 
            +
            #
         | 
| 12 | 
            +
            #   bundle exec rake local_gemfile
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            # This will give you a Gemfile.local file that points to your local clones of
         | 
| 15 | 
            +
            # the various datamapper gems. It's assumed that all datamapper repo clones
         | 
| 16 | 
            +
            # reside in the same directory. You can use the Gemfile.local like so for
         | 
| 17 | 
            +
            # running any bundle command:
         | 
| 18 | 
            +
            #
         | 
| 19 | 
            +
            #   BUNDLE_GEMFILE=Gemfile.local bundle foo
         | 
| 20 | 
            +
            #
         | 
| 21 | 
            +
            # You can also specify which adapter(s) should be part of the bundle by setting
         | 
| 22 | 
            +
            # an environment variable. This of course also works when using the Gemfile.local
         | 
| 23 | 
            +
            #
         | 
| 24 | 
            +
            #   bundle foo                        # dm-sqlite-adapter
         | 
| 25 | 
            +
            #   ADAPTER=mysql bundle foo          # dm-mysql-adapter
         | 
| 26 | 
            +
            #   ADAPTERS=sqlite,mysql bundle foo  # dm-sqlite-adapter and dm-mysql-adapter
         | 
| 27 | 
            +
            #
         | 
| 28 | 
            +
            # Of course you can also use the ADAPTER(S) variable when using the Gemfile.local
         | 
| 29 | 
            +
            # and running specs against selected adapters.
         | 
| 30 | 
            +
            #
         | 
| 31 | 
            +
            # For easily working with adapters supported on your machine, it's recommended
         | 
| 32 | 
            +
            # that you first install all adapters that you are planning to use or work on
         | 
| 33 | 
            +
            # by doing something like
         | 
| 34 | 
            +
            #
         | 
| 35 | 
            +
            #   ADAPTERS=sqlite,mysql,postgres bundle install
         | 
| 36 | 
            +
            #
         | 
| 37 | 
            +
            # This will clone the various repositories and make them available to bundler.
         | 
| 38 | 
            +
            # Once you have them installed you can easily switch between adapters for the
         | 
| 39 | 
            +
            # various development tasks. Running something like
         | 
| 40 | 
            +
            #
         | 
| 41 | 
            +
            #   ADAPTER=mysql bundle exec rake spec
         | 
| 42 | 
            +
            #
         | 
| 43 | 
            +
            # will make sure that the dm-mysql-adapter is part of the bundle, and will be used
         | 
| 44 | 
            +
            # when running the specs.
         | 
| 45 | 
            +
            #
         | 
| 46 | 
            +
            # You can also specify which plugin(s) should be part of the bundle by setting
         | 
| 47 | 
            +
            # an environment variable. This also works when using the Gemfile.local
         | 
| 48 | 
            +
            #
         | 
| 49 | 
            +
            #   bundle foo                                 # dm-migrations
         | 
| 50 | 
            +
            #   PLUGINS=dm-validations bundle foo          # dm-migrations and dm-validations
         | 
| 51 | 
            +
            #   PLUGINS=dm-validations,dm-types bundle foo # dm-migrations, dm-validations and dm-types
         | 
| 52 | 
            +
            #
         | 
| 53 | 
            +
            # Of course you can combine the PLUGIN(S) and ADAPTER(S) env vars to run specs
         | 
| 54 | 
            +
            # for certain adapter/plugin combinations.
         | 
| 55 | 
            +
            #
         | 
| 56 | 
            +
            # Finally, to speed up running specs and other tasks, it's recommended to run
         | 
| 57 | 
            +
            #
         | 
| 58 | 
            +
            #   bundle lock
         | 
| 59 | 
            +
            #
         | 
| 60 | 
            +
            # after running 'bundle install' for the first time. This will make 'bundle exec' run
         | 
| 61 | 
            +
            # a lot faster compared to the unlocked version. With an unlocked bundle you would
         | 
| 62 | 
            +
            # typically just run 'bundle install' from time to time to fetch the latest sources from
         | 
| 63 | 
            +
            # upstream. When you locked your bundle, you need to run
         | 
| 64 | 
            +
            #
         | 
| 65 | 
            +
            #   bundle install --relock
         | 
| 66 | 
            +
            #
         | 
| 67 | 
            +
            # to make sure to fetch the latest updates and then lock the bundle again. Gemfile.lock
         | 
| 68 | 
            +
            # is added to the .gitignore file, so you don't need to worry about accidentally checking
         | 
| 69 | 
            +
            # it into version control.
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            source 'http://rubygems.org'
         | 
| 72 | 
            +
             | 
| 73 | 
            +
            DATAMAPPER = 'git://github.com/datamapper'
         | 
| 74 | 
            +
            DM_VERSION = '~> 1.0.0.rc1'
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            group :runtime do # Runtime dependencies (as in the gemspec)
         | 
| 77 | 
            +
             | 
| 78 | 
            +
              if ENV['EXTLIB']
         | 
| 79 | 
            +
                gem 'extlib',        '~> 0.9.15',      :git => "#{DATAMAPPER}/extlib.git"
         | 
| 80 | 
            +
              else
         | 
| 81 | 
            +
                gem 'activesupport', '~> 3.0.0.beta3', :git => 'git://github.com/rails/rails.git', :require => nil
         | 
| 82 | 
            +
              end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
              gem 'dm-core',   DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
         | 
| 85 | 
            +
              gem 'fastercsv', '~> 1.5.0'
         | 
| 86 | 
            +
              gem 'json_pure', '~> 1.4.3'
         | 
| 87 | 
            +
             | 
| 88 | 
            +
            end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
            group(:development) do # Development dependencies (as in the gemspec)
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              gem 'dm-validations', DM_VERSION, :git => "#{DATAMAPPER}/dm-validations.git"
         | 
| 93 | 
            +
              gem 'nokogiri',       '~> 1.4.1'
         | 
| 94 | 
            +
             | 
| 95 | 
            +
              gem 'rake',           '~> 0.8.7'
         | 
| 96 | 
            +
              gem 'rspec',          '~> 1.3'
         | 
| 97 | 
            +
              gem 'jeweler',        '~> 1.4'
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            group :quality do # These gems contain rake tasks that check the quality of the source code
         | 
| 102 | 
            +
             | 
| 103 | 
            +
              gem 'metric_fu',      '~> 1.3'
         | 
| 104 | 
            +
              gem 'rcov',           '~> 0.9.7'
         | 
| 105 | 
            +
              gem 'reek',           '~> 1.2.7'
         | 
| 106 | 
            +
              gem 'roodi',          '~> 2.1'
         | 
| 107 | 
            +
              gem 'yard',           '~> 0.5'
         | 
| 108 | 
            +
              gem 'yardstick',      '~> 0.1'
         | 
| 109 | 
            +
             | 
| 110 | 
            +
            end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
            group :datamapper do # We need this because we want to pin these dependencies to their git master sources
         | 
| 113 | 
            +
             | 
| 114 | 
            +
              adapters = ENV['ADAPTER'] || ENV['ADAPTERS']
         | 
| 115 | 
            +
              adapters = adapters.to_s.gsub(',',' ').split(' ') - ['in_memory']
         | 
| 116 | 
            +
             | 
| 117 | 
            +
              unless adapters.empty?
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                DO_VERSION     = '~> 0.10.2'
         | 
| 120 | 
            +
                DM_DO_ADAPTERS = %w[sqlite postgres mysql oracle sqlserver]
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                gem 'data_objects',  DO_VERSION, :git => "#{DATAMAPPER}/do.git"
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                adapters.each do |adapter|
         | 
| 125 | 
            +
                  if DM_DO_ADAPTERS.any? { |dm_do_adapter| dm_do_adapter =~ /#{adapter}/  }
         | 
| 126 | 
            +
                    adapter = 'sqlite3' if adapter == 'sqlite'
         | 
| 127 | 
            +
                    gem "do_#{adapter}", DO_VERSION, :git => "#{DATAMAPPER}/do.git"
         | 
| 128 | 
            +
                  end
         | 
| 129 | 
            +
                end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                gem 'dm-do-adapter', DM_VERSION, :git => "#{DATAMAPPER}/dm-do-adapter.git"
         | 
| 132 | 
            +
             | 
| 133 | 
            +
                adapters.each do |adapter|
         | 
| 134 | 
            +
                  gem "dm-#{adapter}-adapter", DM_VERSION, :git => "#{DATAMAPPER}/dm-#{adapter}-adapter.git"
         | 
| 135 | 
            +
                end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
              end
         | 
| 138 | 
            +
             | 
| 139 | 
            +
              plugins = ENV['PLUGINS'] || ENV['PLUGIN']
         | 
| 140 | 
            +
              plugins = (plugins.to_s.gsub(',',' ').split(' ') + ['dm-migrations']).uniq
         | 
| 141 | 
            +
             | 
| 142 | 
            +
              plugins.each do |plugin|
         | 
| 143 | 
            +
                gem plugin, DM_VERSION, :git => "#{DATAMAPPER}/#{plugin}.git"
         | 
| 144 | 
            +
              end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
            end
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -10,19 +10,19 @@ begin | |
| 10 10 | 
             
                gem.summary     = 'DataMapper plugin for serializing Resources and Collections'
         | 
| 11 11 | 
             
                gem.description = gem.summary
         | 
| 12 12 | 
             
                gem.email       = 'vandenberg.guy [a] gmail [d] com'
         | 
| 13 | 
            -
                gem.homepage    = 'http://github.com/datamapper/dm- | 
| 13 | 
            +
                gem.homepage    = 'http://github.com/datamapper/dm-serializer'
         | 
| 14 14 | 
             
                gem.authors     = [ 'Guy van den Berg' ]
         | 
| 15 15 |  | 
| 16 16 | 
             
                gem.rubyforge_project = 'datamapper'
         | 
| 17 17 |  | 
| 18 | 
            -
                gem.add_dependency 'dm-core',   '~> 0. | 
| 18 | 
            +
                gem.add_dependency 'dm-core',   '~> 1.0.0.rc1'
         | 
| 19 19 | 
             
                gem.add_dependency 'fastercsv', '~> 1.5.0'
         | 
| 20 | 
            -
                gem.add_dependency 'json_pure', '~> 1. | 
| 20 | 
            +
                gem.add_dependency 'json_pure', '~> 1.4.3'
         | 
| 21 21 |  | 
| 22 22 | 
             
                #gem.add_development_dependency 'libxml-ruby', '~> 1.1.3'  # not available on JRuby
         | 
| 23 | 
            -
                gem.add_development_dependency ' | 
| 24 | 
            -
                gem.add_development_dependency ' | 
| 25 | 
            -
                gem.add_development_dependency ' | 
| 23 | 
            +
                gem.add_development_dependency 'dm-validations', '~> 1.0.0.rc1'
         | 
| 24 | 
            +
                gem.add_development_dependency 'nokogiri',       '~> 1.4.1'
         | 
| 25 | 
            +
                gem.add_development_dependency 'rspec',          '~> 1.3'
         | 
| 26 26 | 
             
              end
         | 
| 27 27 |  | 
| 28 28 | 
             
              Jeweler::GemcutterTasks.new
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            1.0.0.rc1
         | 
    
        data/benchmarks/to_json.rb
    CHANGED
    
    
    
        data/benchmarks/to_xml.rb
    CHANGED
    
    
    
        data/dm-serializer.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{dm-serializer}
         | 
| 8 | 
            -
              s.version = "0. | 
| 8 | 
            +
              s.version = "1.0.0.rc1"
         | 
| 9 9 |  | 
| 10 | 
            -
              s.required_rubygems_version = Gem::Requirement.new(" | 
| 10 | 
            +
              s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Guy van den Berg"]
         | 
| 12 | 
            -
              s.date = %q{ | 
| 12 | 
            +
              s.date = %q{2010-05-19}
         | 
| 13 13 | 
             
              s.description = %q{DataMapper plugin for serializing Resources and Collections}
         | 
| 14 14 | 
             
              s.email = %q{vandenberg.guy [a] gmail [d] com}
         | 
| 15 15 | 
             
              s.extra_rdoc_files = [
         | 
| @@ -17,7 +17,9 @@ Gem::Specification.new do |s| | |
| 17 17 | 
             
                 "README.rdoc"
         | 
| 18 18 | 
             
              ]
         | 
| 19 19 | 
             
              s.files = [
         | 
| 20 | 
            -
                " | 
| 20 | 
            +
                ".gitignore",
         | 
| 21 | 
            +
                 "Gemfile",
         | 
| 22 | 
            +
                 "LICENSE",
         | 
| 21 23 | 
             
                 "README.rdoc",
         | 
| 22 24 | 
             
                 "Rakefile",
         | 
| 23 25 | 
             
                 "VERSION",
         | 
| @@ -49,44 +51,57 @@ Gem::Specification.new do |s| | |
| 49 51 | 
             
                 "spec/spec.opts",
         | 
| 50 52 | 
             
                 "spec/spec_helper.rb",
         | 
| 51 53 | 
             
                 "tasks/ci.rake",
         | 
| 54 | 
            +
                 "tasks/local_gemfile.rake",
         | 
| 52 55 | 
             
                 "tasks/metrics.rake",
         | 
| 53 56 | 
             
                 "tasks/spec.rake",
         | 
| 54 57 | 
             
                 "tasks/yard.rake",
         | 
| 55 58 | 
             
                 "tasks/yardstick.rake"
         | 
| 56 59 | 
             
              ]
         | 
| 57 | 
            -
              s.homepage = %q{http://github.com/datamapper/dm- | 
| 60 | 
            +
              s.homepage = %q{http://github.com/datamapper/dm-serializer}
         | 
| 58 61 | 
             
              s.rdoc_options = ["--charset=UTF-8"]
         | 
| 59 62 | 
             
              s.require_paths = ["lib"]
         | 
| 60 63 | 
             
              s.rubyforge_project = %q{datamapper}
         | 
| 61 | 
            -
              s.rubygems_version = %q{1.3. | 
| 64 | 
            +
              s.rubygems_version = %q{1.3.6}
         | 
| 62 65 | 
             
              s.summary = %q{DataMapper plugin for serializing Resources and Collections}
         | 
| 66 | 
            +
              s.test_files = [
         | 
| 67 | 
            +
                "spec/fixtures/cow.rb",
         | 
| 68 | 
            +
                 "spec/fixtures/planet.rb",
         | 
| 69 | 
            +
                 "spec/fixtures/quan_tum_cat.rb",
         | 
| 70 | 
            +
                 "spec/lib/serialization_method_shared_spec.rb",
         | 
| 71 | 
            +
                 "spec/public/serializer_spec.rb",
         | 
| 72 | 
            +
                 "spec/public/to_csv_spec.rb",
         | 
| 73 | 
            +
                 "spec/public/to_json_spec.rb",
         | 
| 74 | 
            +
                 "spec/public/to_xml_spec.rb",
         | 
| 75 | 
            +
                 "spec/public/to_yaml_spec.rb",
         | 
| 76 | 
            +
                 "spec/spec_helper.rb"
         | 
| 77 | 
            +
              ]
         | 
| 63 78 |  | 
| 64 79 | 
             
              if s.respond_to? :specification_version then
         | 
| 65 80 | 
             
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 66 81 | 
             
                s.specification_version = 3
         | 
| 67 82 |  | 
| 68 83 | 
             
                if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
         | 
| 69 | 
            -
                  s.add_runtime_dependency(%q<dm-core>, ["~> 0. | 
| 84 | 
            +
                  s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0.rc1"])
         | 
| 70 85 | 
             
                  s.add_runtime_dependency(%q<fastercsv>, ["~> 1.5.0"])
         | 
| 71 | 
            -
                  s.add_runtime_dependency(%q<json_pure>, ["~> 1. | 
| 86 | 
            +
                  s.add_runtime_dependency(%q<json_pure>, ["~> 1.4.3"])
         | 
| 87 | 
            +
                  s.add_development_dependency(%q<dm-validations>, ["~> 1.0.0.rc1"])
         | 
| 72 88 | 
             
                  s.add_development_dependency(%q<nokogiri>, ["~> 1.4.1"])
         | 
| 73 | 
            -
                  s.add_development_dependency(%q<rspec>, ["~> 1. | 
| 74 | 
            -
                  s.add_development_dependency(%q<yard>, ["~> 0.4.0"])
         | 
| 89 | 
            +
                  s.add_development_dependency(%q<rspec>, ["~> 1.3"])
         | 
| 75 90 | 
             
                else
         | 
| 76 | 
            -
                  s.add_dependency(%q<dm-core>, ["~> 0. | 
| 91 | 
            +
                  s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc1"])
         | 
| 77 92 | 
             
                  s.add_dependency(%q<fastercsv>, ["~> 1.5.0"])
         | 
| 78 | 
            -
                  s.add_dependency(%q<json_pure>, ["~> 1. | 
| 93 | 
            +
                  s.add_dependency(%q<json_pure>, ["~> 1.4.3"])
         | 
| 94 | 
            +
                  s.add_dependency(%q<dm-validations>, ["~> 1.0.0.rc1"])
         | 
| 79 95 | 
             
                  s.add_dependency(%q<nokogiri>, ["~> 1.4.1"])
         | 
| 80 | 
            -
                  s.add_dependency(%q<rspec>, ["~> 1. | 
| 81 | 
            -
                  s.add_dependency(%q<yard>, ["~> 0.4.0"])
         | 
| 96 | 
            +
                  s.add_dependency(%q<rspec>, ["~> 1.3"])
         | 
| 82 97 | 
             
                end
         | 
| 83 98 | 
             
              else
         | 
| 84 | 
            -
                s.add_dependency(%q<dm-core>, ["~> 0. | 
| 99 | 
            +
                s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc1"])
         | 
| 85 100 | 
             
                s.add_dependency(%q<fastercsv>, ["~> 1.5.0"])
         | 
| 86 | 
            -
                s.add_dependency(%q<json_pure>, ["~> 1. | 
| 101 | 
            +
                s.add_dependency(%q<json_pure>, ["~> 1.4.3"])
         | 
| 102 | 
            +
                s.add_dependency(%q<dm-validations>, ["~> 1.0.0.rc1"])
         | 
| 87 103 | 
             
                s.add_dependency(%q<nokogiri>, ["~> 1.4.1"])
         | 
| 88 | 
            -
                s.add_dependency(%q<rspec>, ["~> 1. | 
| 89 | 
            -
                s.add_dependency(%q<yard>, ["~> 0.4.0"])
         | 
| 104 | 
            +
                s.add_dependency(%q<rspec>, ["~> 1.3"])
         | 
| 90 105 | 
             
              end
         | 
| 91 106 | 
             
            end
         | 
| 92 107 |  | 
    
        data/lib/dm-serializer/common.rb
    CHANGED
    
    | @@ -1,5 +1,21 @@ | |
| 1 | 
            +
            begin
         | 
| 2 | 
            +
              require 'active_support/ordered_hash'
         | 
| 3 | 
            +
            rescue LoadError
         | 
| 4 | 
            +
              require 'extlib/dictionary'
         | 
| 5 | 
            +
              module ActiveSupport
         | 
| 6 | 
            +
                OrderedHash = Dictionary unless defined?(OrderedHash)
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            require 'dm-core'
         | 
| 11 | 
            +
             | 
| 1 12 | 
             
            module DataMapper
         | 
| 2 13 | 
             
              module Serialize
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def self.dm_validations_loaded?
         | 
| 16 | 
            +
                  DataMapper.const_defined?("Validations")
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 3 19 | 
             
                # Returns propreties to serialize based on :only or :exclude arrays, if provided
         | 
| 4 20 | 
             
                # :only takes precendence over :exclude
         | 
| 5 21 | 
             
                #
         | 
| @@ -17,12 +33,6 @@ module DataMapper | |
| 17 33 | 
             
                  end
         | 
| 18 34 | 
             
                end
         | 
| 19 35 |  | 
| 20 | 
            -
                Model.append_inclusions self
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                class Support
         | 
| 23 | 
            -
                  def self.dm_validations_loaded?
         | 
| 24 | 
            -
                    DataMapper.const_defined?("Validate")
         | 
| 25 | 
            -
                  end
         | 
| 26 | 
            -
                end
         | 
| 27 36 | 
             
              end
         | 
| 37 | 
            +
              Model.append_inclusions(Serialize)
         | 
| 28 38 | 
             
            end
         | 
    
        data/lib/dm-serializer/to_csv.rb
    CHANGED
    
    | @@ -25,6 +25,23 @@ module DataMapper | |
| 25 25 | 
             
                    csv << row
         | 
| 26 26 | 
             
                  end
         | 
| 27 27 | 
             
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                module ValidationErrors
         | 
| 30 | 
            +
                  module ToCsv
         | 
| 31 | 
            +
                    def to_csv(writer = '')
         | 
| 32 | 
            +
                      CSV.generate(writer) do |csv|
         | 
| 33 | 
            +
                        errors.each do |key, value|
         | 
| 34 | 
            +
                          value.each do |error|
         | 
| 35 | 
            +
                            row = []
         | 
| 36 | 
            +
                            row << key.to_s
         | 
| 37 | 
            +
                            row << error.to_s
         | 
| 38 | 
            +
                            csv << row
         | 
| 39 | 
            +
                          end
         | 
| 40 | 
            +
                        end
         | 
| 41 | 
            +
                      end
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                end
         | 
| 28 45 | 
             
              end
         | 
| 29 46 |  | 
| 30 47 | 
             
              class Collection
         | 
| @@ -37,22 +54,11 @@ module DataMapper | |
| 37 54 | 
             
                end
         | 
| 38 55 | 
             
              end
         | 
| 39 56 |  | 
| 40 | 
            -
              if Serialize | 
| 57 | 
            +
              if Serialize.dm_validations_loaded?
         | 
| 41 58 |  | 
| 42 | 
            -
                module  | 
| 59 | 
            +
                module Validations
         | 
| 43 60 | 
             
                  class ValidationErrors
         | 
| 44 | 
            -
                     | 
| 45 | 
            -
                      CSV.generate(writer) do |csv|
         | 
| 46 | 
            -
                        errors.each do |key, value|
         | 
| 47 | 
            -
                          value.each do |error|
         | 
| 48 | 
            -
                            row = []
         | 
| 49 | 
            -
                            row << key.to_s
         | 
| 50 | 
            -
                            row << error.to_s
         | 
| 51 | 
            -
                            csv << row
         | 
| 52 | 
            -
                          end
         | 
| 53 | 
            -
                        end
         | 
| 54 | 
            -
                      end
         | 
| 55 | 
            -
                    end
         | 
| 61 | 
            +
                    include DataMapper::Serialize::ValidationErrors::ToCsv
         | 
| 56 62 | 
             
                  end
         | 
| 57 63 | 
             
                end
         | 
| 58 64 |  | 
| @@ -42,6 +42,15 @@ module DataMapper | |
| 42 42 | 
             
                    result
         | 
| 43 43 | 
             
                  end
         | 
| 44 44 | 
             
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                module ValidationErrors
         | 
| 47 | 
            +
                  module ToJson
         | 
| 48 | 
            +
                    def to_json(*args)
         | 
| 49 | 
            +
                      errors.to_hash.to_json
         | 
| 50 | 
            +
                    end
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 45 54 | 
             
              end
         | 
| 46 55 |  | 
| 47 56 |  | 
| @@ -78,15 +87,14 @@ module DataMapper | |
| 78 87 | 
             
                end
         | 
| 79 88 | 
             
              end
         | 
| 80 89 |  | 
| 81 | 
            -
              if Serialize | 
| 90 | 
            +
              if Serialize.dm_validations_loaded?
         | 
| 82 91 |  | 
| 83 | 
            -
                module  | 
| 92 | 
            +
                module Validations
         | 
| 84 93 | 
             
                  class ValidationErrors
         | 
| 85 | 
            -
                     | 
| 86 | 
            -
                      errors.to_hash.to_json
         | 
| 87 | 
            -
                    end
         | 
| 94 | 
            +
                    include DataMapper::Serialize::ValidationErrors::ToJson
         | 
| 88 95 | 
             
                  end
         | 
| 89 96 | 
             
                end
         | 
| 90 97 |  | 
| 91 98 | 
             
              end
         | 
| 99 | 
            +
             | 
| 92 100 | 
             
            end
         | 
    
        data/lib/dm-serializer/to_xml.rb
    CHANGED
    
    | @@ -21,11 +21,11 @@ module DataMapper | |
| 21 21 | 
             
                def to_xml_document(opts={}, doc = nil)
         | 
| 22 22 | 
             
                  xml = XMLSerializers::SERIALIZER
         | 
| 23 23 | 
             
                  doc ||= xml.new_document
         | 
| 24 | 
            -
                  default_xml_element_name = lambda {  | 
| 24 | 
            +
                  default_xml_element_name = lambda { ActiveSupport::Inflector.underscore(model.name).tr("/", "-") }
         | 
| 25 25 | 
             
                  root = xml.root_node(doc, opts[:element_name] || default_xml_element_name[])
         | 
| 26 26 | 
             
                  properties_to_serialize(opts).each do |property|
         | 
| 27 27 | 
             
                    value = __send__(property.name)
         | 
| 28 | 
            -
                    attrs = (property. | 
| 28 | 
            +
                    attrs = (property.primitive == String) ? {} : {'type' => property.primitive.to_s.downcase}
         | 
| 29 29 | 
             
                    xml.add_node(root, property.name.to_s, value, attrs)
         | 
| 30 30 | 
             
                  end
         | 
| 31 31 |  | 
| @@ -44,29 +44,9 @@ module DataMapper | |
| 44 44 | 
             
                  end
         | 
| 45 45 | 
             
                  doc
         | 
| 46 46 | 
             
                end
         | 
| 47 | 
            -
              end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
              class Collection
         | 
| 50 | 
            -
                def to_xml(opts = {})
         | 
| 51 | 
            -
                  to_xml_document(opts).to_s
         | 
| 52 | 
            -
                end
         | 
| 53 47 |  | 
| 54 | 
            -
                 | 
| 55 | 
            -
                   | 
| 56 | 
            -
                  doc = xml.new_document
         | 
| 57 | 
            -
                  default_collection_element_name = lambda {Extlib::Inflection.pluralize(Extlib::Inflection.underscore(self.model.to_s)).tr("/", "-")}
         | 
| 58 | 
            -
                  root = xml.root_node(doc, opts[:collection_element_name] || default_collection_element_name[], {'type' => 'array'})
         | 
| 59 | 
            -
                  self.each do |item|
         | 
| 60 | 
            -
                    item.to_xml_document(opts, doc)
         | 
| 61 | 
            -
                  end
         | 
| 62 | 
            -
                  doc
         | 
| 63 | 
            -
                end
         | 
| 64 | 
            -
              end
         | 
| 65 | 
            -
             | 
| 66 | 
            -
              if Serialize::Support.dm_validations_loaded?
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                module Validate
         | 
| 69 | 
            -
                  class ValidationErrors
         | 
| 48 | 
            +
                module ValidationErrors
         | 
| 49 | 
            +
                  module ToXml
         | 
| 70 50 | 
             
                    def to_xml(opts = {})
         | 
| 71 51 | 
             
                      to_xml_document(opts).to_s
         | 
| 72 52 | 
             
                    end
         | 
| @@ -90,4 +70,31 @@ module DataMapper | |
| 90 70 | 
             
                end
         | 
| 91 71 |  | 
| 92 72 | 
             
              end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              class Collection
         | 
| 75 | 
            +
                def to_xml(opts = {})
         | 
| 76 | 
            +
                  to_xml_document(opts).to_s
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                def to_xml_document(opts = {})
         | 
| 80 | 
            +
                  xml = DataMapper::Serialize::XMLSerializers::SERIALIZER
         | 
| 81 | 
            +
                  doc = xml.new_document
         | 
| 82 | 
            +
                  default_collection_element_name = lambda {ActiveSupport::Inflector.pluralize(ActiveSupport::Inflector.underscore(self.model.to_s)).tr("/", "-")}
         | 
| 83 | 
            +
                  root = xml.root_node(doc, opts[:collection_element_name] || default_collection_element_name[], {'type' => 'array'})
         | 
| 84 | 
            +
                  self.each do |item|
         | 
| 85 | 
            +
                    item.to_xml_document(opts, doc)
         | 
| 86 | 
            +
                  end
         | 
| 87 | 
            +
                  doc
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
              if Serialize.dm_validations_loaded?
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                module Validations
         | 
| 94 | 
            +
                  class ValidationErrors
         | 
| 95 | 
            +
                    include DataMapper::Serialize::ValidationErrors::ToXml
         | 
| 96 | 
            +
                  end
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
              end
         | 
| 93 100 | 
             
            end
         | 
| @@ -32,6 +32,15 @@ module DataMapper | |
| 32 32 | 
             
                    end
         | 
| 33 33 | 
             
                  end
         | 
| 34 34 | 
             
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                module ValidationErrors
         | 
| 37 | 
            +
                  module ToYaml
         | 
| 38 | 
            +
                    def to_yaml(*args)
         | 
| 39 | 
            +
                      errors.to_hash.to_yaml(*args)
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 35 44 | 
             
              end
         | 
| 36 45 |  | 
| 37 46 | 
             
              class Collection
         | 
| @@ -45,13 +54,11 @@ module DataMapper | |
| 45 54 | 
             
                end
         | 
| 46 55 | 
             
              end
         | 
| 47 56 |  | 
| 48 | 
            -
              if Serialize | 
| 57 | 
            +
              if Serialize.dm_validations_loaded?
         | 
| 49 58 |  | 
| 50 | 
            -
                module  | 
| 59 | 
            +
                module Validations
         | 
| 51 60 | 
             
                  class ValidationErrors
         | 
| 52 | 
            -
                     | 
| 53 | 
            -
                      errors.to_hash.to_yaml(*args)
         | 
| 54 | 
            -
                    end
         | 
| 61 | 
            +
                    include DataMapper::Serialize::ValidationErrors::ToYaml
         | 
| 55 62 | 
             
                  end
         | 
| 56 63 | 
             
                end
         | 
| 57 64 |  | 
    
        data/lib/dm-serializer.rb
    CHANGED
    
    | @@ -1,3 +1,12 @@ | |
| 1 | 
            +
            begin
         | 
| 2 | 
            +
              require 'active_support/ordered_hash'
         | 
| 3 | 
            +
            rescue LoadError
         | 
| 4 | 
            +
              require 'extlib/dictionary'
         | 
| 5 | 
            +
              module ActiveSupport
         | 
| 6 | 
            +
                OrderedHash = Dictionary
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
             | 
| 1 10 | 
             
            require 'dm-serializer/to_json'
         | 
| 2 11 | 
             
            require 'dm-serializer/to_xml'
         | 
| 3 12 | 
             
            require 'dm-serializer/to_yaml'
         | 
    
        data/spec/fixtures/planet.rb
    CHANGED
    
    | @@ -4,7 +4,7 @@ class Planet | |
| 4 4 | 
             
              property :name,     String, :key => true
         | 
| 5 5 | 
             
              property :aphelion, Float
         | 
| 6 6 |  | 
| 7 | 
            -
               | 
| 7 | 
            +
              validates_length_of :name, :min => 2
         | 
| 8 8 |  | 
| 9 9 | 
             
              # Sorry these associations don't make any sense
         | 
| 10 10 | 
             
              # I just needed a many-to-many association to test against
         | 
| @@ -12,9 +12,7 @@ share_examples_for 'A serialization method that also serializes core classes' do | |
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| 14 14 | 
             
              before(:each) do
         | 
| 15 | 
            -
                 | 
| 16 | 
            -
                Planet.all.destroy!
         | 
| 17 | 
            -
                FriendedPlanet.all.destroy!
         | 
| 15 | 
            +
                DataMapper::Model.descendants.each { |model| model.all.destroy! }
         | 
| 18 16 | 
             
              end
         | 
| 19 17 |  | 
| 20 18 | 
             
              it 'serializes an array of extended objects' do
         | 
| @@ -57,9 +55,7 @@ share_examples_for 'A serialization method' do | |
| 57 55 | 
             
              end
         | 
| 58 56 |  | 
| 59 57 | 
             
              before(:each) do
         | 
| 60 | 
            -
                 | 
| 61 | 
            -
                Planet.all.destroy!
         | 
| 62 | 
            -
                FriendedPlanet.all.destroy!
         | 
| 58 | 
            +
                DataMapper::Model.descendants.each { |model| model.all.destroy! }
         | 
| 63 59 | 
             
              end
         | 
| 64 60 |  | 
| 65 61 | 
             
              describe '(serializing single resources)' do
         | 
| @@ -238,18 +234,27 @@ share_examples_for 'A serialization method' do | |
| 238 234 | 
             
                end
         | 
| 239 235 | 
             
              end
         | 
| 240 236 |  | 
| 241 | 
            -
               | 
| 242 | 
            -
             | 
| 243 | 
            -
             | 
| 244 | 
            -
                   | 
| 245 | 
            -
             | 
| 237 | 
            +
              with_alternate_adapter do
         | 
| 238 | 
            +
             | 
| 239 | 
            +
                describe "(multiple repositories)" do
         | 
| 240 | 
            +
                  before(:all) do
         | 
| 241 | 
            +
                    [ :default, :alternate ].each do |repository_name|
         | 
| 242 | 
            +
                      DataMapper.repository(repository_name) do
         | 
| 243 | 
            +
                        QuanTum::Cat.auto_migrate!
         | 
| 244 | 
            +
                        QuanTum::Cat.all.destroy!
         | 
| 245 | 
            +
                      end
         | 
| 246 | 
            +
                    end
         | 
| 247 | 
            +
                  end
         | 
| 246 248 |  | 
| 247 | 
            -
             | 
| 248 | 
            -
             | 
| 249 | 
            -
             | 
| 250 | 
            -
             | 
| 251 | 
            -
             | 
| 249 | 
            +
                  it "should use the repsoitory for the model" do
         | 
| 250 | 
            +
                    alternate_repo = DataMapper::Spec.spec_adapters[:alternate].name
         | 
| 251 | 
            +
                    gerry = QuanTum::Cat.create(:name => "gerry")
         | 
| 252 | 
            +
                    george = DataMapper.repository(alternate_repo){ QuanTum::Cat.create(:name => "george", :is_dead => false) }
         | 
| 253 | 
            +
                    @harness.test(gerry )['is_dead'].should be(nil)
         | 
| 254 | 
            +
                    @harness.test(george)['is_dead'].should be(false)
         | 
| 255 | 
            +
                  end
         | 
| 252 256 | 
             
                end
         | 
| 257 | 
            +
             | 
| 253 258 | 
             
              end
         | 
| 254 259 |  | 
| 255 260 | 
             
              it 'should integrate with dm-validations' do
         | 
    
        data/spec/public/to_csv_spec.rb
    CHANGED
    
    | @@ -35,7 +35,7 @@ if defined?(::CSV) | |
| 35 35 | 
             
                  result.split("\n")[1].split(',')[0..3].should == ['10','20','Berta','Guernsey']
         | 
| 36 36 | 
             
                end
         | 
| 37 37 |  | 
| 38 | 
            -
                it 'should  | 
| 38 | 
            +
                it 'should integrate with dm-validations by providing one line per error' do
         | 
| 39 39 | 
             
                  planet = Planet.create(:name => 'a')
         | 
| 40 40 | 
             
                  result = planet.errors.to_csv.gsub(/[[:space:]]+\n/, "\n").split("\n")
         | 
| 41 41 | 
             
                  result.should include("name,#{planet.errors[:name][0]}")
         | 
| @@ -43,18 +43,26 @@ if defined?(::CSV) | |
| 43 43 | 
             
                  result.length.should == 2
         | 
| 44 44 | 
             
                end
         | 
| 45 45 |  | 
| 46 | 
            -
                 | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
                     | 
| 50 | 
            -
             | 
| 46 | 
            +
                with_alternate_adapter do
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  describe "multiple repositories" do
         | 
| 49 | 
            +
                    before(:all) do
         | 
| 50 | 
            +
                      [ :default, :alternate ].each do |repository_name|
         | 
| 51 | 
            +
                        DataMapper.repository(repository_name) do
         | 
| 52 | 
            +
                          QuanTum::Cat.auto_migrate!
         | 
| 53 | 
            +
                          QuanTum::Cat.all.destroy!
         | 
| 54 | 
            +
                        end
         | 
| 55 | 
            +
                      end
         | 
| 56 | 
            +
                    end
         | 
| 51 57 |  | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 58 | 
            +
                    it "should use the repsoitory for the model" do
         | 
| 59 | 
            +
                      gerry = QuanTum::Cat.create(:name => "gerry")
         | 
| 60 | 
            +
                      george = DataMapper.repository(:alternate){ QuanTum::Cat.create(:name => "george", :is_dead => false) }
         | 
| 61 | 
            +
                      gerry.to_csv.should_not match(/false/)
         | 
| 62 | 
            +
                      george.to_csv.should match(/false/)
         | 
| 63 | 
            +
                    end
         | 
| 57 64 | 
             
                  end
         | 
| 65 | 
            +
             | 
| 58 66 | 
             
                end
         | 
| 59 67 | 
             
              end
         | 
| 60 68 | 
             
            else
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,39 +1,15 @@ | |
| 1 | 
            -
            require ' | 
| 2 | 
            -
             | 
| 3 | 
            -
            # use local dm-core if running from a typical dev checkout.
         | 
| 4 | 
            -
            lib = File.join('..', '..', 'dm-core', 'lib')
         | 
| 5 | 
            -
            $LOAD_PATH.unshift(lib) if File.directory?(lib)
         | 
| 6 | 
            -
            require 'dm-core'
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            # use local dm-validations if running from dm-more directly
         | 
| 9 | 
            -
            lib = File.join('..', 'dm-validations', 'lib')
         | 
| 10 | 
            -
            $LOAD_PATH.unshift(lib) if File.directory?(lib)
         | 
| 11 | 
            -
            require 'dm-validations'
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            # Support running specs with 'rake spec' and 'spec'
         | 
| 14 | 
            -
            $LOAD_PATH.unshift('lib') unless $LOAD_PATH.include?('lib')
         | 
| 1 | 
            +
            require 'dm-core/spec/setup'
         | 
| 2 | 
            +
            require 'dm-core/spec/lib/adapter_helpers'
         | 
| 15 3 |  | 
| 4 | 
            +
            require 'dm-validations' # FIXME: must be required before dm-serializer
         | 
| 16 5 | 
             
            require 'dm-serializer'
         | 
| 6 | 
            +
            require 'dm-migrations'
         | 
| 17 7 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
              return false if ENV['ADAPTER'] != name.to_s
         | 
| 8 | 
            +
            require 'spec/lib/serialization_method_shared_spec'
         | 
| 20 9 |  | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
                DataMapper::Repository.adapters[:alternate] = DataMapper::Repository.adapters[name]
         | 
| 25 | 
            -
                true
         | 
| 26 | 
            -
              rescue LoadError => e
         | 
| 27 | 
            -
                warn "Could not load do_#{name}: #{e}"
         | 
| 28 | 
            -
                false
         | 
| 29 | 
            -
              end
         | 
| 30 | 
            -
            end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
            ENV['ADAPTER'] ||= 'sqlite3'
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            HAS_SQLITE3  = load_driver(:sqlite3,  'sqlite3::memory:')
         | 
| 35 | 
            -
            HAS_MYSQL    = load_driver(:mysql,    'mysql://localhost/dm_core_test')
         | 
| 36 | 
            -
            HAS_POSTGRES = load_driver(:postgres, 'postgres://postgres@localhost/dm_core_test')
         | 
| 10 | 
            +
            # require fixture resources
         | 
| 11 | 
            +
            SPEC_ROOT = Pathname(__FILE__).dirname.expand_path
         | 
| 12 | 
            +
            Pathname.glob((SPEC_ROOT + 'fixtures/**/*.rb').to_s).each { |file| require file }
         | 
| 37 13 |  | 
| 38 14 | 
             
            class SerializerTestHarness
         | 
| 39 15 | 
             
              def test(object, *args)
         | 
| @@ -41,9 +17,8 @@ class SerializerTestHarness | |
| 41 17 | 
             
              end
         | 
| 42 18 | 
             
            end
         | 
| 43 19 |  | 
| 44 | 
            -
             | 
| 20 | 
            +
            DataMapper::Spec.setup
         | 
| 45 21 |  | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
              require fixture_file
         | 
| 22 | 
            +
            Spec::Runner.configure do |config|
         | 
| 23 | 
            +
              config.extend(DataMapper::Spec::Adapters::Helpers)
         | 
| 49 24 | 
             
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            desc "Support bundling from local source code (allows BUNDLE_GEMFILE=Gemfile.local bundle foo)"
         | 
| 2 | 
            +
            task :local_gemfile do |t|
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              root              = Pathname(__FILE__).dirname.parent
         | 
| 5 | 
            +
              datamapper        = root.parent
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              source_regex     = /DATAMAPPER = 'git:\/\/github.com\/datamapper'/
         | 
| 8 | 
            +
              gem_source_regex = /:git => \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              root.join('Gemfile.local').open('w') do |f|
         | 
| 11 | 
            +
                root.join('Gemfile').open.each do |line|
         | 
| 12 | 
            +
                  line.sub!(source_regex,     "DATAMAPPER = '#{datamapper}'")
         | 
| 13 | 
            +
                  line.sub!(gem_source_regex, ':path => "#{DATAMAPPER}/\1"')
         | 
| 14 | 
            +
                  f.puts line
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            end
         | 
    
        data/tasks/spec.rake
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: dm-serializer
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
               | 
| 4 | 
            +
              prerelease: true
         | 
| 5 | 
            +
              segments: 
         | 
| 6 | 
            +
              - 1
         | 
| 7 | 
            +
              - 0
         | 
| 8 | 
            +
              - 0
         | 
| 9 | 
            +
              - rc1
         | 
| 10 | 
            +
              version: 1.0.0.rc1
         | 
| 5 11 | 
             
            platform: ruby
         | 
| 6 12 | 
             
            authors: 
         | 
| 7 13 | 
             
            - Guy van den Berg
         | 
| @@ -9,69 +15,94 @@ autorequire: | |
| 9 15 | 
             
            bindir: bin
         | 
| 10 16 | 
             
            cert_chain: []
         | 
| 11 17 |  | 
| 12 | 
            -
            date:  | 
| 18 | 
            +
            date: 2010-05-19 00:00:00 -07:00
         | 
| 13 19 | 
             
            default_executable: 
         | 
| 14 20 | 
             
            dependencies: 
         | 
| 15 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 16 22 | 
             
              name: dm-core
         | 
| 17 | 
            -
               | 
| 18 | 
            -
               | 
| 19 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 20 25 | 
             
                requirements: 
         | 
| 21 26 | 
             
                - - ~>
         | 
| 22 27 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 23 | 
            -
                     | 
| 24 | 
            -
             | 
| 28 | 
            +
                    segments: 
         | 
| 29 | 
            +
                    - 1
         | 
| 30 | 
            +
                    - 0
         | 
| 31 | 
            +
                    - 0
         | 
| 32 | 
            +
                    - rc1
         | 
| 33 | 
            +
                    version: 1.0.0.rc1
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              version_requirements: *id001
         | 
| 25 36 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 26 37 | 
             
              name: fastercsv
         | 
| 27 | 
            -
               | 
| 28 | 
            -
               | 
| 29 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 38 | 
            +
              prerelease: false
         | 
| 39 | 
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 30 40 | 
             
                requirements: 
         | 
| 31 41 | 
             
                - - ~>
         | 
| 32 42 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 43 | 
            +
                    segments: 
         | 
| 44 | 
            +
                    - 1
         | 
| 45 | 
            +
                    - 5
         | 
| 46 | 
            +
                    - 0
         | 
| 33 47 | 
             
                    version: 1.5.0
         | 
| 34 | 
            -
             | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              version_requirements: *id002
         | 
| 35 50 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 36 51 | 
             
              name: json_pure
         | 
| 52 | 
            +
              prerelease: false
         | 
| 53 | 
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 54 | 
            +
                requirements: 
         | 
| 55 | 
            +
                - - ~>
         | 
| 56 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 57 | 
            +
                    segments: 
         | 
| 58 | 
            +
                    - 1
         | 
| 59 | 
            +
                    - 4
         | 
| 60 | 
            +
                    - 3
         | 
| 61 | 
            +
                    version: 1.4.3
         | 
| 37 62 | 
             
              type: :runtime
         | 
| 38 | 
            -
               | 
| 39 | 
            -
             | 
| 63 | 
            +
              version_requirements: *id003
         | 
| 64 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 65 | 
            +
              name: dm-validations
         | 
| 66 | 
            +
              prerelease: false
         | 
| 67 | 
            +
              requirement: &id004 !ruby/object:Gem::Requirement 
         | 
| 40 68 | 
             
                requirements: 
         | 
| 41 69 | 
             
                - - ~>
         | 
| 42 70 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 43 | 
            -
                     | 
| 44 | 
            -
             | 
| 71 | 
            +
                    segments: 
         | 
| 72 | 
            +
                    - 1
         | 
| 73 | 
            +
                    - 0
         | 
| 74 | 
            +
                    - 0
         | 
| 75 | 
            +
                    - rc1
         | 
| 76 | 
            +
                    version: 1.0.0.rc1
         | 
| 77 | 
            +
              type: :development
         | 
| 78 | 
            +
              version_requirements: *id004
         | 
| 45 79 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 46 80 | 
             
              name: nokogiri
         | 
| 47 | 
            -
               | 
| 48 | 
            -
               | 
| 49 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 81 | 
            +
              prerelease: false
         | 
| 82 | 
            +
              requirement: &id005 !ruby/object:Gem::Requirement 
         | 
| 50 83 | 
             
                requirements: 
         | 
| 51 84 | 
             
                - - ~>
         | 
| 52 85 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 86 | 
            +
                    segments: 
         | 
| 87 | 
            +
                    - 1
         | 
| 88 | 
            +
                    - 4
         | 
| 89 | 
            +
                    - 1
         | 
| 53 90 | 
             
                    version: 1.4.1
         | 
| 54 | 
            -
             | 
| 91 | 
            +
              type: :development
         | 
| 92 | 
            +
              version_requirements: *id005
         | 
| 55 93 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 56 94 | 
             
              name: rspec
         | 
| 57 | 
            -
               | 
| 58 | 
            -
               | 
| 59 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 95 | 
            +
              prerelease: false
         | 
| 96 | 
            +
              requirement: &id006 !ruby/object:Gem::Requirement 
         | 
| 60 97 | 
             
                requirements: 
         | 
| 61 98 | 
             
                - - ~>
         | 
| 62 99 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 63 | 
            -
                     | 
| 64 | 
            -
             | 
| 65 | 
            -
            -  | 
| 66 | 
            -
             | 
| 100 | 
            +
                    segments: 
         | 
| 101 | 
            +
                    - 1
         | 
| 102 | 
            +
                    - 3
         | 
| 103 | 
            +
                    version: "1.3"
         | 
| 67 104 | 
             
              type: :development
         | 
| 68 | 
            -
               | 
| 69 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 70 | 
            -
                requirements: 
         | 
| 71 | 
            -
                - - ~>
         | 
| 72 | 
            -
                  - !ruby/object:Gem::Version 
         | 
| 73 | 
            -
                    version: 0.4.0
         | 
| 74 | 
            -
                version: 
         | 
| 105 | 
            +
              version_requirements: *id006
         | 
| 75 106 | 
             
            description: DataMapper plugin for serializing Resources and Collections
         | 
| 76 107 | 
             
            email: vandenberg.guy [a] gmail [d] com
         | 
| 77 108 | 
             
            executables: []
         | 
| @@ -82,6 +113,8 @@ extra_rdoc_files: | |
| 82 113 | 
             
            - LICENSE
         | 
| 83 114 | 
             
            - README.rdoc
         | 
| 84 115 | 
             
            files: 
         | 
| 116 | 
            +
            - .gitignore
         | 
| 117 | 
            +
            - Gemfile
         | 
| 85 118 | 
             
            - LICENSE
         | 
| 86 119 | 
             
            - README.rdoc
         | 
| 87 120 | 
             
            - Rakefile
         | 
| @@ -114,12 +147,13 @@ files: | |
| 114 147 | 
             
            - spec/spec.opts
         | 
| 115 148 | 
             
            - spec/spec_helper.rb
         | 
| 116 149 | 
             
            - tasks/ci.rake
         | 
| 150 | 
            +
            - tasks/local_gemfile.rake
         | 
| 117 151 | 
             
            - tasks/metrics.rake
         | 
| 118 152 | 
             
            - tasks/spec.rake
         | 
| 119 153 | 
             
            - tasks/yard.rake
         | 
| 120 154 | 
             
            - tasks/yardstick.rake
         | 
| 121 155 | 
             
            has_rdoc: true
         | 
| 122 | 
            -
            homepage: http://github.com/datamapper/dm- | 
| 156 | 
            +
            homepage: http://github.com/datamapper/dm-serializer
         | 
| 123 157 | 
             
            licenses: []
         | 
| 124 158 |  | 
| 125 159 | 
             
            post_install_message: 
         | 
| @@ -131,20 +165,33 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 131 165 | 
             
              requirements: 
         | 
| 132 166 | 
             
              - - ">="
         | 
| 133 167 | 
             
                - !ruby/object:Gem::Version 
         | 
| 168 | 
            +
                  segments: 
         | 
| 169 | 
            +
                  - 0
         | 
| 134 170 | 
             
                  version: "0"
         | 
| 135 | 
            -
              version: 
         | 
| 136 171 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 137 172 | 
             
              requirements: 
         | 
| 138 | 
            -
              - - " | 
| 173 | 
            +
              - - ">"
         | 
| 139 174 | 
             
                - !ruby/object:Gem::Version 
         | 
| 140 | 
            -
                   | 
| 141 | 
            -
             | 
| 175 | 
            +
                  segments: 
         | 
| 176 | 
            +
                  - 1
         | 
| 177 | 
            +
                  - 3
         | 
| 178 | 
            +
                  - 1
         | 
| 179 | 
            +
                  version: 1.3.1
         | 
| 142 180 | 
             
            requirements: []
         | 
| 143 181 |  | 
| 144 182 | 
             
            rubyforge_project: datamapper
         | 
| 145 | 
            -
            rubygems_version: 1.3. | 
| 183 | 
            +
            rubygems_version: 1.3.6
         | 
| 146 184 | 
             
            signing_key: 
         | 
| 147 185 | 
             
            specification_version: 3
         | 
| 148 186 | 
             
            summary: DataMapper plugin for serializing Resources and Collections
         | 
| 149 | 
            -
            test_files:  | 
| 150 | 
            -
             | 
| 187 | 
            +
            test_files: 
         | 
| 188 | 
            +
            - spec/fixtures/cow.rb
         | 
| 189 | 
            +
            - spec/fixtures/planet.rb
         | 
| 190 | 
            +
            - spec/fixtures/quan_tum_cat.rb
         | 
| 191 | 
            +
            - spec/lib/serialization_method_shared_spec.rb
         | 
| 192 | 
            +
            - spec/public/serializer_spec.rb
         | 
| 193 | 
            +
            - spec/public/to_csv_spec.rb
         | 
| 194 | 
            +
            - spec/public/to_json_spec.rb
         | 
| 195 | 
            +
            - spec/public/to_xml_spec.rb
         | 
| 196 | 
            +
            - spec/public/to_yaml_spec.rb
         | 
| 197 | 
            +
            - spec/spec_helper.rb
         |