dm-core 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.autotest +29 -0
  2. data/.document +5 -0
  3. data/.gitignore +27 -0
  4. data/LICENSE +20 -0
  5. data/{README.txt → README.rdoc} +14 -3
  6. data/Rakefile +23 -22
  7. data/VERSION +1 -0
  8. data/dm-core.gemspec +201 -10
  9. data/lib/dm-core.rb +32 -23
  10. data/lib/dm-core/adapters.rb +0 -1
  11. data/lib/dm-core/adapters/data_objects_adapter.rb +230 -151
  12. data/lib/dm-core/adapters/mysql_adapter.rb +7 -8
  13. data/lib/dm-core/adapters/oracle_adapter.rb +39 -59
  14. data/lib/dm-core/adapters/postgres_adapter.rb +0 -1
  15. data/lib/dm-core/adapters/sqlite3_adapter.rb +5 -0
  16. data/lib/dm-core/adapters/sqlserver_adapter.rb +114 -0
  17. data/lib/dm-core/adapters/yaml_adapter.rb +0 -5
  18. data/lib/dm-core/associations/many_to_many.rb +118 -56
  19. data/lib/dm-core/associations/many_to_one.rb +48 -21
  20. data/lib/dm-core/associations/one_to_many.rb +8 -30
  21. data/lib/dm-core/associations/one_to_one.rb +1 -5
  22. data/lib/dm-core/associations/relationship.rb +89 -97
  23. data/lib/dm-core/collection.rb +299 -184
  24. data/lib/dm-core/core_ext/enumerable.rb +28 -0
  25. data/lib/dm-core/core_ext/kernel.rb +0 -2
  26. data/lib/dm-core/migrations.rb +314 -170
  27. data/lib/dm-core/model.rb +97 -66
  28. data/lib/dm-core/model/descendant_set.rb +1 -1
  29. data/lib/dm-core/model/hook.rb +0 -3
  30. data/lib/dm-core/model/property.rb +7 -10
  31. data/lib/dm-core/model/relationship.rb +79 -26
  32. data/lib/dm-core/model/scope.rb +3 -4
  33. data/lib/dm-core/property.rb +152 -90
  34. data/lib/dm-core/property_set.rb +18 -37
  35. data/lib/dm-core/query.rb +452 -153
  36. data/lib/dm-core/query/conditions/comparison.rb +266 -173
  37. data/lib/dm-core/query/conditions/operation.rb +499 -57
  38. data/lib/dm-core/query/direction.rb +0 -3
  39. data/lib/dm-core/query/operator.rb +0 -4
  40. data/lib/dm-core/query/path.rb +10 -12
  41. data/lib/dm-core/query/sort.rb +4 -10
  42. data/lib/dm-core/repository.rb +10 -6
  43. data/lib/dm-core/resource.rb +343 -148
  44. data/lib/dm-core/spec/adapter_shared_spec.rb +17 -1
  45. data/lib/dm-core/spec/data_objects_adapter_shared_spec.rb +277 -17
  46. data/lib/dm-core/support/chainable.rb +0 -2
  47. data/lib/dm-core/support/equalizer.rb +27 -3
  48. data/lib/dm-core/transaction.rb +75 -75
  49. data/lib/dm-core/type.rb +19 -5
  50. data/lib/dm-core/types/discriminator.rb +4 -4
  51. data/lib/dm-core/types/object.rb +2 -7
  52. data/lib/dm-core/types/paranoid_boolean.rb +8 -2
  53. data/lib/dm-core/types/paranoid_datetime.rb +8 -2
  54. data/lib/dm-core/version.rb +1 -1
  55. data/script/performance.rb +7 -7
  56. data/script/profile.rb +6 -6
  57. data/spec/lib/collection_helpers.rb +2 -2
  58. data/spec/lib/pending_helpers.rb +22 -3
  59. data/spec/lib/rspec_immediate_feedback_formatter.rb +1 -0
  60. data/spec/public/associations/many_to_many_spec.rb +6 -4
  61. data/spec/public/associations/many_to_one_spec.rb +10 -1
  62. data/spec/public/associations/many_to_one_with_boolean_cpk_spec.rb +39 -0
  63. data/spec/public/associations/one_to_many_spec.rb +4 -3
  64. data/spec/public/associations/one_to_one_spec.rb +19 -1
  65. data/spec/public/associations/one_to_one_with_boolean_cpk_spec.rb +45 -0
  66. data/spec/public/collection_spec.rb +4 -3
  67. data/spec/public/migrations_spec.rb +144 -0
  68. data/spec/public/model/relationship_spec.rb +115 -55
  69. data/spec/public/model_spec.rb +13 -13
  70. data/spec/public/property/object_spec.rb +106 -0
  71. data/spec/public/property_spec.rb +18 -14
  72. data/spec/public/resource_spec.rb +10 -1
  73. data/spec/public/sel_spec.rb +16 -49
  74. data/spec/public/setup_spec.rb +1 -1
  75. data/spec/public/shared/association_collection_shared_spec.rb +6 -14
  76. data/spec/public/shared/collection_finder_shared_spec.rb +267 -0
  77. data/spec/public/shared/collection_shared_spec.rb +214 -217
  78. data/spec/public/shared/finder_shared_spec.rb +259 -365
  79. data/spec/public/shared/resource_shared_spec.rb +524 -248
  80. data/spec/public/transaction_spec.rb +27 -3
  81. data/spec/public/types/discriminator_spec.rb +1 -1
  82. data/spec/rcov.opts +6 -0
  83. data/spec/semipublic/adapters/sqlserver_adapter_spec.rb +17 -0
  84. data/spec/semipublic/associations/many_to_one_spec.rb +3 -20
  85. data/spec/semipublic/associations_spec.rb +2 -2
  86. data/spec/semipublic/collection_spec.rb +0 -32
  87. data/spec/semipublic/model_spec.rb +96 -0
  88. data/spec/semipublic/property_spec.rb +3 -3
  89. data/spec/semipublic/query/conditions/comparison_spec.rb +1719 -0
  90. data/spec/semipublic/query/conditions/operation_spec.rb +1292 -0
  91. data/spec/semipublic/query_spec.rb +1285 -144
  92. data/spec/semipublic/resource_spec.rb +0 -24
  93. data/spec/semipublic/shared/resource_shared_spec.rb +103 -38
  94. data/spec/spec.opts +1 -1
  95. data/spec/spec_helper.rb +15 -6
  96. data/tasks/ci.rake +1 -0
  97. data/tasks/metrics.rake +37 -0
  98. data/tasks/spec.rake +41 -0
  99. data/tasks/yard.rake +9 -0
  100. data/tasks/yardstick.rake +19 -0
  101. metadata +99 -29
  102. data/CONTRIBUTING +0 -51
  103. data/FAQ +0 -93
  104. data/History.txt +0 -27
  105. data/MIT-LICENSE +0 -22
  106. data/Manifest.txt +0 -121
  107. data/QUICKLINKS +0 -11
  108. data/SPECS +0 -35
  109. data/TODO +0 -1
  110. data/spec/semipublic/query/conditions_spec.rb +0 -528
  111. data/tasks/ci.rb +0 -24
  112. data/tasks/dm.rb +0 -58
  113. data/tasks/doc.rb +0 -17
  114. data/tasks/gemspec.rb +0 -23
  115. data/tasks/hoe.rb +0 -45
  116. data/tasks/install.rb +0 -18
data/tasks/ci.rb DELETED
@@ -1,24 +0,0 @@
1
- desc 'Run metric_fu'
2
- task :ci do
3
- # sudo gem install jscruggs-metric_fu -s http://gems.github.com
4
- require 'metric_fu'
5
-
6
- MetricFu::Configuration.run do |config|
7
- specs = Pathname.glob(ENV['FILES'] || (ROOT + 'spec/**/*_spec.rb').to_s).sort.map { |file| file.to_s }
8
-
9
- config.rcov = {
10
- :test_files => specs,
11
- :rcov_opts => [
12
- '--sort coverage',
13
- '--no-html',
14
- '--text-coverage',
15
- '--no-color',
16
- '--profile',
17
- '--exclude spec',
18
- "`which spec` -- #{specs.join(' ')}",
19
- ],
20
- }
21
- end
22
-
23
- Rake::Task['metrics:all'].invoke
24
- end
data/tasks/dm.rb DELETED
@@ -1,58 +0,0 @@
1
- require 'spec/rake/spectask'
2
- require 'spec/rake/verify_rcov'
3
-
4
- task :default => 'spec'
5
-
6
- RCov::VerifyTask.new(:verify_rcov => :rcov) do |config|
7
- config.threshold = 88.1 # Make sure you have rcov 0.7 or higher!
8
- end
9
-
10
- def run_spec(name, files, rcov)
11
- Spec::Rake::SpecTask.new(name) do |config|
12
- config.spec_opts << '--options' << ROOT + 'spec/spec.opts'
13
- config.spec_files = Pathname.glob(ENV['FILES'] || files.to_s).map { |file| file.to_s }
14
- config.rcov = rcov
15
- config.rcov_opts << '--exclude' << 'spec'
16
- config.rcov_opts << '--text-summary'
17
- config.rcov_opts << '--sort' << 'coverage'
18
- config.rcov_opts << '--only-uncovered'
19
- config.rcov_opts << '--profile'
20
- #config.rcov_opts << '-w' # TODO: make sure it runs with warnings enabled
21
- end
22
- end
23
-
24
- public_specs = ROOT + 'spec/public/**/*_spec.rb'
25
- semipublic_specs = ROOT + 'spec/semipublic/**/*_spec.rb'
26
- all_specs = ROOT + 'spec/**/*_spec.rb'
27
-
28
- desc 'Run all specifications'
29
- run_spec('spec', all_specs, false)
30
-
31
- desc 'Run all specifications with rcov'
32
- run_spec('rcov', all_specs, true)
33
-
34
- namespace :spec do
35
- desc 'Run public specifications'
36
- run_spec('public', public_specs, false)
37
-
38
- desc 'Run semipublic specifications'
39
- run_spec('semipublic', semipublic_specs, false)
40
- end
41
-
42
- namespace :rcov do
43
- desc 'Run public specifications with rcov'
44
- run_spec('public', public_specs, true)
45
-
46
- desc 'Run semipublic specifications with rcov'
47
- run_spec('semipublic', semipublic_specs, true)
48
- end
49
-
50
- desc 'Run all comparisons with ActiveRecord'
51
- task :perf do
52
- sh ROOT + 'script/performance.rb'
53
- end
54
-
55
- desc 'Profile DataMapper'
56
- task :profile do
57
- sh ROOT + 'script/profile.rb'
58
- end
data/tasks/doc.rb DELETED
@@ -1,17 +0,0 @@
1
- # when yard's ready, it'll have to come back, but for now...
2
- Rake::RDocTask.new('doc') do |config|
3
- config.rdoc_dir = 'doc'
4
- config.title = 'DataMapper - Ruby Object Relational Mapper'
5
- config.options = %w[ --line-numbers --inline-source --all ]
6
- config.rdoc_files.include('README.txt', 'QUICKLINKS', 'FAQ', 'lib/**/**/*.rb')
7
- end
8
-
9
- begin
10
- require 'yard'
11
-
12
- YARD::Rake::YardocTask.new('yardoc') do |config|
13
- config.files << 'lib/**/*.rb'
14
- end
15
- rescue LoadError
16
- # yard not installed
17
- end
data/tasks/gemspec.rb DELETED
@@ -1,23 +0,0 @@
1
- desc 'Generate gemspec'
2
- task :gemspec do
3
- # Clean up extraneous files before checking manifest
4
- %x[rake clean]
5
-
6
- # Check the manifest before generating the gemspec
7
- manifest = %x[rake check_manifest]
8
- manifest.gsub!("(in /usr/local/projects/dm/dm-core)\n", '')
9
-
10
- unless manifest.empty?
11
- print "\n", '#' * 68, "\n"
12
- print <<-EOS
13
- Manifest.txt is not up-to-date. Please review the changes below.
14
- If the changes are correct, run 'rake check_manifest | patch'
15
- and then run this command again.
16
- EOS
17
- print '#' * 68, "\n\n"
18
- puts manifest
19
- else
20
- %x[rake debug_gem > #{GEM_NAME}.gemspec]
21
- puts "Successfully created gemspec for #{GEM_NAME}!"
22
- end
23
- end
data/tasks/hoe.rb DELETED
@@ -1,45 +0,0 @@
1
- require 'hoe'
2
-
3
- @config_file = '~/.rubyforge/user-config.yml'
4
- @config = nil
5
- RUBYFORGE_USERNAME = 'unknown'
6
- def rubyforge_username
7
- unless @config
8
- begin
9
- @config = YAML.load(File.read(File.expand_path(@config_file)))
10
- rescue
11
- puts <<-EOS
12
- ERROR: No rubyforge config file found: #{@config_file}
13
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
14
- - See http://newgem.rubyforge.org/rubyforge.html for more details
15
- EOS
16
- exit
17
- end
18
- end
19
- RUBYFORGE_USERNAME.replace @config['username']
20
- end
21
-
22
- # Remove hoe dependency
23
- class Hoe
24
- def extra_dev_deps
25
- @extra_dev_deps.reject! { |dep| dep[0] == 'hoe' }
26
- @extra_dev_deps
27
- end
28
- end
29
-
30
- # Don't use Hoe's test task
31
- Hoe.plugins.delete(:test)
32
-
33
- hoe = Hoe.spec(GEM_NAME) do
34
- developer(AUTHOR, EMAIL)
35
-
36
- self.version = GEM_VERSION
37
- self.description = PROJECT_DESCRIPTION
38
- self.summary = PROJECT_SUMMARY
39
- self.url = PROJECT_URL
40
-
41
- self.rubyforge_name = PROJECT_NAME
42
-
43
- self.clean_globs |= %w[ {coverage,doc,log,tmp} **/*.{log,db} profile_results.* **/.DS_Store spec/db ]
44
- self.extra_deps |= GEM_DEPENDENCIES
45
- end
data/tasks/install.rb DELETED
@@ -1,18 +0,0 @@
1
- WIN32 = (RUBY_PLATFORM =~ /win32|mingw|bccwin|cygwin/) rescue nil
2
- SUDO = WIN32 ? '' : ('sudo' unless ENV['SUDOLESS'])
3
-
4
- def sudo_gem(cmd)
5
- sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
6
- end
7
-
8
- if WIN32
9
- desc "Install #{GEM_NAME}"
10
- task :install => :gem do
11
- sudo_gem "install --no-rdoc --no-ri pkg/#{GEM_NAME}-#{GEM_VERSION}.gem"
12
- end
13
- else
14
- desc "Install #{GEM_NAME}"
15
- task :install => :package do
16
- sudo_gem "install --no-rdoc --no-ri pkg/#{GEM_NAME}-#{GEM_VERSION}.gem"
17
- end
18
- end