be9-dataset 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/CHANGELOG +63 -0
  2. data/LICENSE +19 -0
  3. data/README +111 -0
  4. data/Rakefile +32 -0
  5. data/TODO +15 -0
  6. data/VERSION.yml +5 -0
  7. data/lib/dataset.rb +129 -0
  8. data/lib/dataset/base.rb +157 -0
  9. data/lib/dataset/collection.rb +19 -0
  10. data/lib/dataset/database/base.rb +43 -0
  11. data/lib/dataset/database/mysql.rb +34 -0
  12. data/lib/dataset/database/postgresql.rb +34 -0
  13. data/lib/dataset/database/sqlite3.rb +32 -0
  14. data/lib/dataset/extensions/cucumber.rb +20 -0
  15. data/lib/dataset/extensions/rspec.rb +21 -0
  16. data/lib/dataset/extensions/test_unit.rb +60 -0
  17. data/lib/dataset/instance_methods.rb +10 -0
  18. data/lib/dataset/load.rb +47 -0
  19. data/lib/dataset/record/fixture.rb +73 -0
  20. data/lib/dataset/record/heirarchy.rb +65 -0
  21. data/lib/dataset/record/meta.rb +30 -0
  22. data/lib/dataset/record/model.rb +50 -0
  23. data/lib/dataset/resolver.rb +110 -0
  24. data/lib/dataset/session.rb +51 -0
  25. data/lib/dataset/session_binding.rb +319 -0
  26. data/lib/dataset/version.rb +9 -0
  27. data/plugit/descriptor.rb +25 -0
  28. data/spec/dataset/cucumber_spec.rb +54 -0
  29. data/spec/dataset/database/base_spec.rb +21 -0
  30. data/spec/dataset/record/heirarchy_spec.rb +14 -0
  31. data/spec/dataset/resolver_spec.rb +110 -0
  32. data/spec/dataset/rspec_spec.rb +133 -0
  33. data/spec/dataset/session_binding_spec.rb +203 -0
  34. data/spec/dataset/session_spec.rb +299 -0
  35. data/spec/dataset/test_unit_spec.rb +210 -0
  36. data/spec/fixtures/datasets/constant_not_defined.rb +0 -0
  37. data/spec/fixtures/datasets/ending_with_dataset.rb +2 -0
  38. data/spec/fixtures/datasets/exact_name.rb +2 -0
  39. data/spec/fixtures/datasets/not_a_dataset_base.rb +2 -0
  40. data/spec/fixtures/more_datasets/in_another_directory.rb +2 -0
  41. data/spec/models.rb +18 -0
  42. data/spec/schema.rb +26 -0
  43. data/spec/spec_helper.rb +47 -0
  44. data/spec/stubs/mini_rails.rb +18 -0
  45. data/spec/stubs/test_help.rb +1 -0
  46. data/tasks/dataset.rake +19 -0
  47. metadata +163 -0
@@ -0,0 +1,2 @@
1
+ class EndingWithDataset < Dataset::Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class ExactName < Dataset::Base
2
+ end
@@ -0,0 +1,2 @@
1
+ class NotADatasetBase
2
+ end
@@ -0,0 +1,2 @@
1
+ class InAnotherDirectoryDataset < Dataset::Base
2
+ end
@@ -0,0 +1,18 @@
1
+ class Person < ActiveRecord::Base
2
+ attr_protected :last_name
3
+ end
4
+ class Place < ActiveRecord::Base
5
+ set_table_name 'places_table'
6
+ end
7
+ class Thing < ActiveRecord::Base; end
8
+ class Note < ActiveRecord::Base
9
+ belongs_to :person
10
+ end
11
+ class State < Place; end
12
+ class NorthCarolina < State; end
13
+
14
+ module Nested
15
+ class Place < ActiveRecord::Base
16
+ set_table_name 'places_table'
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ ActiveRecord::Schema.define(:version => 20081126181722) do
2
+ create_table :people, :force => true do |t|
3
+ t.column :first_name, :string
4
+ t.column :last_name, :string
5
+ end
6
+
7
+ create_table :places_table, :force => true do |t|
8
+ t.column :name, :string
9
+ t.column :location, :string
10
+ t.column :type, :string
11
+ end
12
+
13
+ create_table :things, :force => true do |t|
14
+ t.column :name, :string
15
+ t.column :description, :string
16
+ t.column :created_on, :date
17
+ t.column :updated_on, :date
18
+ end
19
+
20
+ create_table :notes, :force => true do |t|
21
+ t.column :person_id, :integer
22
+ t.column :content, :string
23
+ t.column :created_at, :datetime
24
+ t.column :updated_at, :datetime
25
+ end
26
+ end
@@ -0,0 +1,47 @@
1
+ SPEC_ROOT = File.expand_path(File.dirname(__FILE__))
2
+ require "#{SPEC_ROOT}/../plugit/descriptor"
3
+
4
+ # From RSpec's spec_helper.rb. Necessary to run an example group.
5
+ def with_sandboxed_options
6
+ attr_reader :options
7
+
8
+ before(:each) do
9
+ @original_rspec_options = ::Spec::Runner.options
10
+ ::Spec::Runner.use(@options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new))
11
+ end
12
+
13
+ after(:each) do
14
+ ::Spec::Runner.use(@original_rspec_options)
15
+ end
16
+
17
+ yield
18
+ end
19
+
20
+ $LOAD_PATH << SPEC_ROOT
21
+ RAILS_ROOT = "#{SPEC_ROOT}/.."
22
+ $LOAD_PATH << "#{RAILS_ROOT}/lib"
23
+ RAILS_LOG_FILE = "#{RAILS_ROOT}/log/test.log"
24
+ SQLITE_DATABASE = "#{SPEC_ROOT}/sqlite3.db"
25
+
26
+ require 'fileutils'
27
+ FileUtils.mkdir_p(File.dirname(RAILS_LOG_FILE))
28
+ FileUtils.touch(RAILS_LOG_FILE)
29
+ FileUtils.mkdir_p("#{SPEC_ROOT}/tmp")
30
+ FileUtils.rm_rf("#{SPEC_ROOT}/tmp/*")
31
+ FileUtils.rm_f(SQLITE_DATABASE)
32
+
33
+ require 'logger'
34
+ RAILS_DEFAULT_LOGGER = Logger.new(RAILS_LOG_FILE)
35
+ RAILS_DEFAULT_LOGGER.level = Logger::DEBUG
36
+
37
+ ActiveRecord::Base.silence do
38
+ ActiveRecord::Base.configurations = {'test' => {
39
+ 'adapter' => 'sqlite3',
40
+ 'database' => SQLITE_DATABASE
41
+ }}
42
+ ActiveRecord::Base.establish_connection 'test'
43
+ load "#{SPEC_ROOT}/schema.rb"
44
+ end
45
+
46
+ require "models"
47
+ require "dataset"
@@ -0,0 +1,18 @@
1
+ # Define some stubs to fake Rails...
2
+ module ActiveRecord
3
+ class Base
4
+ end
5
+ end
6
+
7
+ module ActionController
8
+ class Dispatcher
9
+ end
10
+
11
+ class Base
12
+ end
13
+
14
+ class IntegrationTest
15
+ def self.use_transactional_fixtures=(x)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ # This file is loaded by rails/world.rb
@@ -0,0 +1,19 @@
1
+ namespace :db do
2
+ namespace :dataset do
3
+ desc "Load one or more datasets into the current environment's database using DATASETS=name,name"
4
+ task :load => :environment do
5
+ require 'dataset'
6
+ dataset_names = (ENV['DATASETS'] || 'default').split(',')
7
+
8
+ context = Class.new do
9
+ extend Dataset::ContextClassMethods
10
+ datasets_directory [
11
+ "#{RAILS_ROOT}/spec/datasets",
12
+ "#{RAILS_ROOT}/test/datasets"
13
+ ].detect {|path| File.directory?(path)}
14
+ add_dataset *dataset_names
15
+ dataset_session.load_datasets_for self
16
+ end
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: be9-dataset
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 3
10
+ version: 1.3.3
11
+ platform: ruby
12
+ authors:
13
+ - Adam Williams
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-02 00:00:00 +07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activesupport
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 2
32
+ - 3
33
+ - 0
34
+ version: 2.3.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: activerecord
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 2
48
+ - 3
49
+ - 0
50
+ version: 2.3.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: A simple API for creating and finding sets of data in your database, built on ActiveRecord.
54
+ email: adam@thewilliams.ws
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - LICENSE
61
+ - README
62
+ - TODO
63
+ files:
64
+ - CHANGELOG
65
+ - LICENSE
66
+ - README
67
+ - Rakefile
68
+ - TODO
69
+ - VERSION.yml
70
+ - lib/dataset.rb
71
+ - lib/dataset/base.rb
72
+ - lib/dataset/collection.rb
73
+ - lib/dataset/database/base.rb
74
+ - lib/dataset/database/mysql.rb
75
+ - lib/dataset/database/postgresql.rb
76
+ - lib/dataset/database/sqlite3.rb
77
+ - lib/dataset/extensions/cucumber.rb
78
+ - lib/dataset/extensions/rspec.rb
79
+ - lib/dataset/extensions/test_unit.rb
80
+ - lib/dataset/instance_methods.rb
81
+ - lib/dataset/load.rb
82
+ - lib/dataset/record/fixture.rb
83
+ - lib/dataset/record/heirarchy.rb
84
+ - lib/dataset/record/meta.rb
85
+ - lib/dataset/record/model.rb
86
+ - lib/dataset/resolver.rb
87
+ - lib/dataset/session.rb
88
+ - lib/dataset/session_binding.rb
89
+ - lib/dataset/version.rb
90
+ - plugit/descriptor.rb
91
+ - tasks/dataset.rake
92
+ - spec/dataset/database/base_spec.rb
93
+ - spec/dataset/rspec_spec.rb
94
+ - spec/dataset/record/heirarchy_spec.rb
95
+ - spec/dataset/cucumber_spec.rb
96
+ - spec/dataset/session_spec.rb
97
+ - spec/dataset/resolver_spec.rb
98
+ - spec/dataset/test_unit_spec.rb
99
+ - spec/dataset/session_binding_spec.rb
100
+ - spec/stubs/test_help.rb
101
+ - spec/stubs/mini_rails.rb
102
+ - spec/spec_helper.rb
103
+ - spec/schema.rb
104
+ - spec/models.rb
105
+ - spec/fixtures/more_datasets/in_another_directory.rb
106
+ - spec/fixtures/datasets/not_a_dataset_base.rb
107
+ - spec/fixtures/datasets/exact_name.rb
108
+ - spec/fixtures/datasets/constant_not_defined.rb
109
+ - spec/fixtures/datasets/ending_with_dataset.rb
110
+ has_rdoc: true
111
+ homepage: http://github.com/aiwilliams/dataset
112
+ licenses: []
113
+
114
+ post_install_message:
115
+ rdoc_options:
116
+ - --charset=UTF-8
117
+ require_paths:
118
+ - lib
119
+ - tasks
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ requirements: []
139
+
140
+ rubyforge_project:
141
+ rubygems_version: 1.3.7
142
+ signing_key:
143
+ specification_version: 3
144
+ summary: A simple API for creating and finding sets of data in your database, built on ActiveRecord.
145
+ test_files:
146
+ - spec/dataset/database/base_spec.rb
147
+ - spec/dataset/rspec_spec.rb
148
+ - spec/dataset/record/heirarchy_spec.rb
149
+ - spec/dataset/cucumber_spec.rb
150
+ - spec/dataset/session_spec.rb
151
+ - spec/dataset/resolver_spec.rb
152
+ - spec/dataset/test_unit_spec.rb
153
+ - spec/dataset/session_binding_spec.rb
154
+ - spec/stubs/test_help.rb
155
+ - spec/stubs/mini_rails.rb
156
+ - spec/spec_helper.rb
157
+ - spec/schema.rb
158
+ - spec/models.rb
159
+ - spec/fixtures/more_datasets/in_another_directory.rb
160
+ - spec/fixtures/datasets/not_a_dataset_base.rb
161
+ - spec/fixtures/datasets/exact_name.rb
162
+ - spec/fixtures/datasets/constant_not_defined.rb
163
+ - spec/fixtures/datasets/ending_with_dataset.rb