orm_adapter 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orm_adapter (0.2.0)
4
+ orm_adapter (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,3 +1,8 @@
1
+ == 0.3.0
2
+
3
+ * Removes OrmAdapter::Base.model_classes and friends. This is a BC breaking change if you use .model_classes [Ian White]
4
+ * Add note about the scope of ORM Adapter re: model instance methods
5
+
1
6
  == 0.2.0
2
7
 
3
8
  * Normalise :id in find conditions [Tim Galeckas, Ian White]
@@ -2,7 +2,6 @@
2
2
 
3
3
  Provides a single point of entry for popular ruby ORMs. Its target audience is gem authors who want to support more than one ORM.
4
4
 
5
-
6
5
  == Example of use
7
6
 
8
7
  require 'orm_adapter'
@@ -36,20 +35,13 @@ To write an adapter look at <tt>lib/orm_adapter/adapters/active_record.rb</tt> f
36
35
 
37
36
  == Goals
38
37
 
39
- ORM Adapter goal is to support a minimum API used by most of the plugins that needs agnosticism beyond Active Model.
38
+ ORM Adapter's goal is to support a minimum API used by most of the plugins that needs agnosticism beyond Active Model.
40
39
 
41
40
  ORM Adapter will support only basic methods, as +get+, +find_first+, <tt>create!</tt> and so forth. It is not ORM Adapter's goal to support different query constructions, handle table joins, etc.
42
41
 
43
- If you need complex queries, we recommend you to subclass ORM Adapters in your plugin and extend it expressing these query conditions as part of your domain logic.
44
-
45
-
46
- == Projects using orm_adapter
47
-
48
- * {devise}[http://github.com/plataformatec/devise]
49
- * {pickle}[http://github.com/ianwhite/pickle]
50
-
51
- Get in touch if you want your project added to this list
42
+ ORM adapter provides a consistent API for these basic class or 'factory' methods. It does not attempt to unify the behaviour of model instances returned by these methods. This means that unifying the behaviour of methods such as `model.save`, and `model.valid?` is beyond the scope of orm_adapter.
52
43
 
44
+ If you need complex queries, we recommend you to subclass ORM Adapters in your plugin and extend it expressing these query conditions as part of your domain logic.
53
45
 
54
46
  == History
55
47
 
@@ -7,11 +7,6 @@ module OrmAdapter
7
7
  def self.adapters
8
8
  @@adapters ||= []
9
9
  end
10
-
11
- # All model classes from all registered adapters
12
- def self.model_classes
13
- self.adapters.map { |a| a.model_classes }.flatten
14
- end
15
10
  end
16
11
 
17
12
  require 'orm_adapter/adapters/active_record' if defined?(ActiveRecord::Base)
@@ -2,22 +2,6 @@ require 'active_record'
2
2
 
3
3
  module OrmAdapter
4
4
  class ActiveRecord < Base
5
- # Do not consider these to be part of the class list
6
- def self.except_classes
7
- @@except_classes ||= [
8
- "ActiveRecord::SessionStore::Session"
9
- ]
10
- end
11
-
12
- # Gets a list of the available models for this adapter
13
- def self.model_classes
14
- klasses = ::ActiveRecord::Base.__send__(:descendants)
15
-
16
- klasses.select do |klass|
17
- !klass.abstract_class? && !except_classes.include?(klass.name)
18
- end
19
- end
20
-
21
5
  # Return list of column/property names
22
6
  def column_names
23
7
  klass.column_names
@@ -7,17 +7,6 @@ module DataMapper
7
7
 
8
8
  module Resource
9
9
  class OrmAdapter < ::OrmAdapter::Base
10
-
11
- # Do not consider these to be part of the class list
12
- def self.except_classes
13
- @@except_classes ||= []
14
- end
15
-
16
- # Gets a list of the available models for this adapter
17
- def self.model_classes
18
- ::DataMapper::Model.descendants.to_a.select{|k| !except_classes.include?(k.name)}
19
- end
20
-
21
10
  # get a list of column names for a given class
22
11
  def column_names
23
12
  klass.properties.map(&:name)
@@ -7,16 +7,6 @@ module MongoMapper
7
7
  end
8
8
 
9
9
  class OrmAdapter < ::OrmAdapter::Base
10
- # Do not consider these to be part of the class list
11
- def self.except_classes
12
- @@except_classes ||= []
13
- end
14
-
15
- # Gets a list of the available models for this adapter
16
- def self.model_classes
17
- ObjectSpace.each_object(Class).to_a.select {|klass| klass.ancestors.include? MongoMapper::Document}
18
- end
19
-
20
10
  # get a list of column names for a given class
21
11
  def column_names
22
12
  klass.column_names
@@ -7,16 +7,6 @@ module Mongoid
7
7
  end
8
8
 
9
9
  class OrmAdapter < ::OrmAdapter::Base
10
- # Do not consider these to be part of the class list
11
- def self.except_classes
12
- @@except_classes ||= []
13
- end
14
-
15
- # Gets a list of the available models for this adapter
16
- def self.model_classes
17
- ObjectSpace.each_object(Class).to_a.select {|klass| klass.ancestors.include? Mongoid::Document}
18
- end
19
-
20
10
  # get a list of column names for a given class
21
11
  def column_names
22
12
  klass.fields.keys
@@ -14,11 +14,6 @@ module OrmAdapter
14
14
  super
15
15
  end
16
16
 
17
- # Gets a list of the available models for this adapter
18
- def self.model_classes
19
- raise NotImplementedError, "return a list of available models for this adapter"
20
- end
21
-
22
17
  def initialize(klass)
23
18
  @klass = klass
24
19
  end
@@ -1,3 +1,3 @@
1
1
  module OrmAdapter
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -32,18 +32,6 @@ else
32
32
  User.delete_all
33
33
  Note.delete_all
34
34
  end
35
-
36
- describe "the OrmAdapter class" do
37
- subject { ActiveRecord::Base::OrmAdapter }
38
-
39
- specify "#except_classes should return the names of active record session store classes" do
40
- subject.except_classes.should == ["ActiveRecord::SessionStore::Session"]
41
- end
42
-
43
- specify "#model_classes should return all of the non abstract model classes (that are not in except_classes)" do
44
- subject.model_classes.should include(User, Note)
45
- end
46
- end
47
35
 
48
36
  it_should_behave_like "example app with orm_adapter" do
49
37
  let(:user_class) { User }
@@ -33,14 +33,6 @@ else
33
33
  User.destroy
34
34
  Note.destroy
35
35
  end
36
-
37
- describe "the OrmAdapter class" do
38
- subject { DataMapper::Resource::OrmAdapter }
39
-
40
- specify "#model_classes should return all of the non abstract model classes (that are not in except_classes)" do
41
- subject.model_classes.should == [User, Note]
42
- end
43
- end
44
36
 
45
37
  it_should_behave_like "example app with orm_adapter" do
46
38
  let(:user_class) { User }
@@ -31,14 +31,6 @@ else
31
31
  coll.remove
32
32
  end
33
33
  end
34
-
35
- describe "the OrmAdapter class" do
36
- subject { MongoMapper::Document::OrmAdapter }
37
-
38
- specify "#model_classes should return all document classes" do
39
- (subject.model_classes & [User, Note]).to_set.should == [User, Note].to_set
40
- end
41
- end
42
34
 
43
35
  it_should_behave_like "example app with orm_adapter" do
44
36
  let(:user_class) { User }
@@ -29,14 +29,6 @@ else
29
29
  User.delete_all
30
30
  Note.delete_all
31
31
  end
32
-
33
- describe "the OrmAdapter class" do
34
- subject { Mongoid::Document::OrmAdapter }
35
-
36
- specify "#model_classes should return all document classes" do
37
- (subject.model_classes & [User, Note]).to_set.should == [User, Note].to_set
38
- end
39
- end
40
32
 
41
33
  it_should_behave_like "example app with orm_adapter" do
42
34
  let(:user_class) { User }
@@ -91,8 +91,9 @@ shared_examples_for "example app with orm_adapter" do
91
91
  user_adapter.find_first(:name => "Betty").should == nil
92
92
  end
93
93
 
94
- it 'allows no conditions' do
94
+ it 'should return the first model if no conditions passed' do
95
95
  user = create_model(user_class)
96
+ create_model(user_class)
96
97
  user_adapter.find_first.should == user
97
98
  end
98
99
 
@@ -146,13 +147,6 @@ shared_examples_for "example app with orm_adapter" do
146
147
  it "should return empty array if no conditions match" do
147
148
  user_adapter.find_all(:name => "Fred").should == []
148
149
  end
149
-
150
- it 'allows no conditions' do
151
- user1 = create_model(user_class)
152
- user2 = create_model(user_class)
153
- user_adapter.find_all.to_set.should == [user1, user2].to_set
154
- end
155
-
156
150
 
157
151
  it "when conditions contain associated object, should return first model if it exists" do
158
152
  user1, user2 = create_model(user_class), create_model(user_class)
@@ -8,14 +8,6 @@ describe OrmAdapter do
8
8
 
9
9
  its(:adapters) { should include(adapter) }
10
10
 
11
- describe "and the adapter has a model class" do
12
- let(:model) { Class.new }
13
-
14
- before { adapter.stub!(:model_classes).and_return([model]) }
15
-
16
- its(:model_classes) { should include(model) }
17
- end
18
-
19
11
  after { OrmAdapter.adapters.delete(adapter) }
20
12
  end
21
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orm_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2012-06-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
- requirement: &70150855160900 !ruby/object:Gem::Requirement
17
+ requirement: &70282396920860 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 1.0.0
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70150855160900
25
+ version_requirements: *70282396920860
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: git
28
- requirement: &70150855160240 !ruby/object:Gem::Requirement
28
+ requirement: &70282396919960 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.2.5
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70150855160240
36
+ version_requirements: *70282396919960
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: yard
39
- requirement: &70150855159520 !ruby/object:Gem::Requirement
39
+ requirement: &70282396919320 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.6.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70150855159520
47
+ version_requirements: *70282396919320
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
- requirement: &70150855158180 !ruby/object:Gem::Requirement
50
+ requirement: &70282396918380 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.8.7
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70150855158180
58
+ version_requirements: *70282396918380
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: activerecord
61
- requirement: &70150855157580 !ruby/object:Gem::Requirement
61
+ requirement: &70282396917120 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 3.0.0
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70150855157580
69
+ version_requirements: *70282396917120
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: mongoid
72
- requirement: &70150855156740 !ruby/object:Gem::Requirement
72
+ requirement: &70282396916500 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 2.0.0.beta.20
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70150855156740
80
+ version_requirements: *70282396916500
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: mongo_mapper
83
- requirement: &70150855141820 !ruby/object:Gem::Requirement
83
+ requirement: &70282396915800 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 0.9.0
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *70150855141820
91
+ version_requirements: *70282396915800
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: bson_ext
94
- requirement: &70150855139580 !ruby/object:Gem::Requirement
94
+ requirement: &70282396900760 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: 1.3.0
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *70150855139580
102
+ version_requirements: *70282396900760
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rspec
105
- requirement: &70150855138220 !ruby/object:Gem::Requirement
105
+ requirement: &70282396898120 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: 2.4.0
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *70150855138220
113
+ version_requirements: *70282396898120
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: sqlite3
116
- requirement: &70150855137100 !ruby/object:Gem::Requirement
116
+ requirement: &70282396896760 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ! '>='
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: 1.3.2
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *70150855137100
124
+ version_requirements: *70282396896760
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: datamapper
127
- requirement: &70150855136280 !ruby/object:Gem::Requirement
127
+ requirement: &70282396896060 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ! '>='
@@ -132,10 +132,10 @@ dependencies:
132
132
  version: '1.0'
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *70150855136280
135
+ version_requirements: *70282396896060
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: dm-sqlite-adapter
138
- requirement: &70150855135540 !ruby/object:Gem::Requirement
138
+ requirement: &70282396895200 !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
141
  - - ! '>='
@@ -143,10 +143,10 @@ dependencies:
143
143
  version: '1.0'
144
144
  type: :development
145
145
  prerelease: false
146
- version_requirements: *70150855135540
146
+ version_requirements: *70282396895200
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: dm-active_model
149
- requirement: &70150855134420 !ruby/object:Gem::Requirement
149
+ requirement: &70282396894300 !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
152
152
  - - ! '>='
@@ -154,7 +154,7 @@ dependencies:
154
154
  version: '1.0'
155
155
  type: :development
156
156
  prerelease: false
157
- version_requirements: *70150855134420
157
+ version_requirements: *70282396894300
158
158
  description: Provides a single point of entry for using basic features of ruby ORMs
159
159
  email: ian.w.white@gmail.com
160
160
  executables: []
@@ -201,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  segments:
203
203
  - 0
204
- hash: -1006971164339010428
204
+ hash: 3963130271152065035
205
205
  required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  none: false
207
207
  requirements: