veneer 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/..gemspec +21 -0
  2. data/.gitignore +2 -5
  3. data/Gemfile +4 -0
  4. data/README.md +171 -0
  5. data/Rakefile +3 -36
  6. data/lib/..rb +3 -0
  7. data/lib/veneer/adapters/active_record.rb +1 -1
  8. data/lib/veneer/adapters/activerecord/class_wrapper.rb +11 -79
  9. data/lib/veneer/adapters/activerecord/instance_wrapper.rb +3 -11
  10. data/lib/veneer/adapters/activerecord/pre_3.0_class_wrapper.rb +24 -0
  11. data/lib/veneer/adapters/activerecord/pre_3.0_instance_wrapper.rb +15 -0
  12. data/lib/veneer/adapters/activerecord.rb +9 -2
  13. data/lib/veneer/adapters/data_mapper.rb +1 -1
  14. data/lib/veneer/adapters/datamapper/class_wrapper.rb +29 -50
  15. data/lib/veneer/adapters/datamapper/instance_wrapper.rb +3 -14
  16. data/lib/veneer/adapters/mongomapper/class_wrapper.rb +2 -56
  17. data/lib/veneer/adapters/mongomapper.rb +2 -2
  18. data/lib/veneer/base/class_wrapper.rb +46 -11
  19. data/lib/veneer/base/instance_wrapper.rb +12 -14
  20. data/lib/veneer/core_ext/kernel.rb +0 -1
  21. data/lib/veneer/errors.rb +0 -1
  22. data/lib/veneer/lint.rb +183 -0
  23. data/lib/veneer/version.rb +3 -0
  24. data/lib/veneer.rb +1 -4
  25. data/test/test_helper.rb +4 -3
  26. data/test/veneer/adapters/{active_record/active_record_setup.rb → test_active_record.rb} +23 -1
  27. data/test/veneer/adapters/test_datamapper.rb +56 -0
  28. data/test/veneer/adapters/test_mongomapper.rb +49 -0
  29. data/test/veneer/proxy_test.rb +20 -45
  30. data/veneer.gemspec +15 -108
  31. metadata +40 -60
  32. data/README.textile +0 -142
  33. data/VERSION +0 -1
  34. data/datamapper_setup.rb +0 -2
  35. data/lib/veneer/base/conditional.rb +0 -77
  36. data/test/macros/class_wrapper/create_macro.rb +0 -54
  37. data/test/macros/class_wrapper/delete_macro.rb +0 -31
  38. data/test/macros/class_wrapper/find_macro.rb +0 -119
  39. data/test/macros/class_wrapper/hooks.rb +0 -41
  40. data/test/macros/class_wrapper/validations.rb +0 -91
  41. data/test/macros/instance_wrapper/destroy_macro.rb +0 -36
  42. data/test/macros/instance_wrapper/new_record_macro.rb +0 -39
  43. data/test/macros/instance_wrapper/save_macro.rb +0 -55
  44. data/test/macros/veneer_constants_interface.rb +0 -26
  45. data/test/support/before_save_mixin.rb +0 -14
  46. data/test/support/valiations_method_method.rb +0 -0
  47. data/test/veneer/adapters/active_record/class_wrapper_test.rb +0 -23
  48. data/test/veneer/adapters/active_record/instance_wrapper_test.rb +0 -21
  49. data/test/veneer/adapters/datamapper/class_wrapper_test.rb +0 -24
  50. data/test/veneer/adapters/datamapper/datamapper_setup.rb +0 -34
  51. data/test/veneer/adapters/datamapper/instance_wrapper_test.rb +0 -21
  52. data/test/veneer/adapters/mongomapper/class_wrapper_test.rb +0 -24
  53. data/test/veneer/adapters/mongomapper/instance_wrapper_test.rb +0 -21
  54. data/test/veneer/adapters/mongomapper/mongomapper_setup.rb +0 -25
  55. data/test/veneer/base/conditonal_test.rb +0 -118
data/veneer.gemspec CHANGED
@@ -1,114 +1,21 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "veneer/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{veneer}
8
- s.version = "0.1.3"
6
+ s.name = "veneer"
7
+ s.version = Veneer::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Daniel Neighman"]
10
+ s.email = ["has.sox@gmail.com"]
11
+ s.homepage = ""
12
+ s.description = %q{Veneer provides basic querying, saving, deleteing and creating interface for data stores.}
13
+ s.summary = %q{Basic query interface for persistant data stores}
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Daniel Neighman"]
12
- s.date = %q{2009-12-06}
13
- s.description = %q{Veneer provides basic querying, saving, deleteing and creating of data stores.}
14
- s.email = %q{has.sox@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.textile"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.textile",
24
- "Rakefile",
25
- "VERSION",
26
- "datamapper_setup.rb",
27
- "lib/veneer.rb",
28
- "lib/veneer/adapters/active_record.rb",
29
- "lib/veneer/adapters/activerecord.rb",
30
- "lib/veneer/adapters/activerecord/class_wrapper.rb",
31
- "lib/veneer/adapters/activerecord/instance_wrapper.rb",
32
- "lib/veneer/adapters/data_mapper.rb",
33
- "lib/veneer/adapters/datamapper.rb",
34
- "lib/veneer/adapters/datamapper/class_wrapper.rb",
35
- "lib/veneer/adapters/datamapper/instance_wrapper.rb",
36
- "lib/veneer/adapters/mongomapper.rb",
37
- "lib/veneer/adapters/mongomapper/class_wrapper.rb",
38
- "lib/veneer/adapters/mongomapper/instance_wrapper.rb",
39
- "lib/veneer/base/class_wrapper.rb",
40
- "lib/veneer/base/conditional.rb",
41
- "lib/veneer/base/instance_wrapper.rb",
42
- "lib/veneer/core_ext/kernel.rb",
43
- "lib/veneer/errors.rb",
44
- "lib/veneer/proxy.rb",
45
- "test/macros/class_wrapper/create_macro.rb",
46
- "test/macros/class_wrapper/delete_macro.rb",
47
- "test/macros/class_wrapper/find_macro.rb",
48
- "test/macros/class_wrapper/hooks.rb",
49
- "test/macros/class_wrapper/validations.rb",
50
- "test/macros/instance_wrapper/destroy_macro.rb",
51
- "test/macros/instance_wrapper/new_record_macro.rb",
52
- "test/macros/instance_wrapper/save_macro.rb",
53
- "test/macros/veneer_constants_interface.rb",
54
- "test/support/before_save_mixin.rb",
55
- "test/support/helpers.rb",
56
- "test/support/valiations_method_method.rb",
57
- "test/test_helper.rb",
58
- "test/veneer/adapters/active_record/active_record_setup.rb",
59
- "test/veneer/adapters/active_record/class_wrapper_test.rb",
60
- "test/veneer/adapters/active_record/instance_wrapper_test.rb",
61
- "test/veneer/adapters/datamapper/class_wrapper_test.rb",
62
- "test/veneer/adapters/datamapper/datamapper_setup.rb",
63
- "test/veneer/adapters/datamapper/instance_wrapper_test.rb",
64
- "test/veneer/adapters/mongomapper/class_wrapper_test.rb",
65
- "test/veneer/adapters/mongomapper/instance_wrapper_test.rb",
66
- "test/veneer/adapters/mongomapper/mongomapper_setup.rb",
67
- "test/veneer/base/conditonal_test.rb",
68
- "test/veneer/proxy_test.rb",
69
- "veneer.gemspec"
70
- ]
71
- s.homepage = %q{http://github.com/hassox/veneer}
72
- s.rdoc_options = ["--charset=UTF-8"]
73
- s.require_paths = ["lib"]
74
- s.rubyforge_project = %q{veneer}
75
- s.rubygems_version = %q{1.3.5}
76
- s.summary = %q{A thin veneer over data stores}
77
- s.test_files = [
78
- "test/macros/class_wrapper/create_macro.rb",
79
- "test/macros/class_wrapper/delete_macro.rb",
80
- "test/macros/class_wrapper/find_macro.rb",
81
- "test/macros/class_wrapper/hooks.rb",
82
- "test/macros/class_wrapper/validations.rb",
83
- "test/macros/instance_wrapper/destroy_macro.rb",
84
- "test/macros/instance_wrapper/new_record_macro.rb",
85
- "test/macros/instance_wrapper/save_macro.rb",
86
- "test/macros/veneer_constants_interface.rb",
87
- "test/support/before_save_mixin.rb",
88
- "test/support/helpers.rb",
89
- "test/support/valiations_method_method.rb",
90
- "test/test_helper.rb",
91
- "test/veneer/adapters/active_record/active_record_setup.rb",
92
- "test/veneer/adapters/active_record/class_wrapper_test.rb",
93
- "test/veneer/adapters/active_record/instance_wrapper_test.rb",
94
- "test/veneer/adapters/datamapper/class_wrapper_test.rb",
95
- "test/veneer/adapters/datamapper/datamapper_setup.rb",
96
- "test/veneer/adapters/datamapper/instance_wrapper_test.rb",
97
- "test/veneer/adapters/mongomapper/class_wrapper_test.rb",
98
- "test/veneer/adapters/mongomapper/instance_wrapper_test.rb",
99
- "test/veneer/adapters/mongomapper/mongomapper_setup.rb",
100
- "test/veneer/base/conditonal_test.rb",
101
- "test/veneer/proxy_test.rb"
102
- ]
103
-
104
- if s.respond_to? :specification_version then
105
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
106
- s.specification_version = 3
15
+ s.rubyforge_project = "veneer"
107
16
 
108
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
109
- else
110
- end
111
- else
112
- end
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
113
21
  end
114
-
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: veneer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Daniel Neighman
@@ -9,32 +15,35 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-06 00:00:00 +11:00
18
+ date: 2011-01-08 00:00:00 +11:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
16
- description: Veneer provides basic querying, saving, deleteing and creating of data stores.
17
- email: has.sox@gmail.com
22
+ description: Veneer provides basic querying, saving, deleteing and creating interface for data stores.
23
+ email:
24
+ - has.sox@gmail.com
18
25
  executables: []
19
26
 
20
27
  extensions: []
21
28
 
22
- extra_rdoc_files:
23
- - LICENSE
24
- - README.textile
29
+ extra_rdoc_files: []
30
+
25
31
  files:
32
+ - ..gemspec
26
33
  - .document
27
34
  - .gitignore
35
+ - Gemfile
28
36
  - LICENSE
29
- - README.textile
37
+ - README.md
30
38
  - Rakefile
31
- - VERSION
32
- - datamapper_setup.rb
39
+ - lib/..rb
33
40
  - lib/veneer.rb
34
41
  - lib/veneer/adapters/active_record.rb
35
42
  - lib/veneer/adapters/activerecord.rb
36
43
  - lib/veneer/adapters/activerecord/class_wrapper.rb
37
44
  - lib/veneer/adapters/activerecord/instance_wrapper.rb
45
+ - lib/veneer/adapters/activerecord/pre_3.0_class_wrapper.rb
46
+ - lib/veneer/adapters/activerecord/pre_3.0_instance_wrapper.rb
38
47
  - lib/veneer/adapters/data_mapper.rb
39
48
  - lib/veneer/adapters/datamapper.rb
40
49
  - lib/veneer/adapters/datamapper/class_wrapper.rb
@@ -43,86 +52,57 @@ files:
43
52
  - lib/veneer/adapters/mongomapper/class_wrapper.rb
44
53
  - lib/veneer/adapters/mongomapper/instance_wrapper.rb
45
54
  - lib/veneer/base/class_wrapper.rb
46
- - lib/veneer/base/conditional.rb
47
55
  - lib/veneer/base/instance_wrapper.rb
48
56
  - lib/veneer/core_ext/kernel.rb
49
57
  - lib/veneer/errors.rb
58
+ - lib/veneer/lint.rb
50
59
  - lib/veneer/proxy.rb
51
- - test/macros/class_wrapper/create_macro.rb
52
- - test/macros/class_wrapper/delete_macro.rb
53
- - test/macros/class_wrapper/find_macro.rb
54
- - test/macros/class_wrapper/hooks.rb
55
- - test/macros/class_wrapper/validations.rb
56
- - test/macros/instance_wrapper/destroy_macro.rb
57
- - test/macros/instance_wrapper/new_record_macro.rb
58
- - test/macros/instance_wrapper/save_macro.rb
59
- - test/macros/veneer_constants_interface.rb
60
- - test/support/before_save_mixin.rb
60
+ - lib/veneer/version.rb
61
61
  - test/support/helpers.rb
62
- - test/support/valiations_method_method.rb
63
62
  - test/test_helper.rb
64
- - test/veneer/adapters/active_record/active_record_setup.rb
65
- - test/veneer/adapters/active_record/class_wrapper_test.rb
66
- - test/veneer/adapters/active_record/instance_wrapper_test.rb
67
- - test/veneer/adapters/datamapper/class_wrapper_test.rb
68
- - test/veneer/adapters/datamapper/datamapper_setup.rb
69
- - test/veneer/adapters/datamapper/instance_wrapper_test.rb
70
- - test/veneer/adapters/mongomapper/class_wrapper_test.rb
71
- - test/veneer/adapters/mongomapper/instance_wrapper_test.rb
72
- - test/veneer/adapters/mongomapper/mongomapper_setup.rb
73
- - test/veneer/base/conditonal_test.rb
63
+ - test/veneer/adapters/test_active_record.rb
64
+ - test/veneer/adapters/test_datamapper.rb
65
+ - test/veneer/adapters/test_mongomapper.rb
74
66
  - test/veneer/proxy_test.rb
75
67
  - veneer.gemspec
76
68
  has_rdoc: true
77
- homepage: http://github.com/hassox/veneer
69
+ homepage: ""
78
70
  licenses: []
79
71
 
80
72
  post_install_message:
81
- rdoc_options:
82
- - --charset=UTF-8
73
+ rdoc_options: []
74
+
83
75
  require_paths:
84
76
  - lib
85
77
  required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
86
79
  requirements:
87
80
  - - ">="
88
81
  - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
89
85
  version: "0"
90
- version:
91
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
92
88
  requirements:
93
89
  - - ">="
94
90
  - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
95
94
  version: "0"
96
- version:
97
95
  requirements: []
98
96
 
99
97
  rubyforge_project: veneer
100
- rubygems_version: 1.3.5
98
+ rubygems_version: 1.3.7
101
99
  signing_key:
102
100
  specification_version: 3
103
- summary: A thin veneer over data stores
101
+ summary: Basic query interface for persistant data stores
104
102
  test_files:
105
- - test/macros/class_wrapper/create_macro.rb
106
- - test/macros/class_wrapper/delete_macro.rb
107
- - test/macros/class_wrapper/find_macro.rb
108
- - test/macros/class_wrapper/hooks.rb
109
- - test/macros/class_wrapper/validations.rb
110
- - test/macros/instance_wrapper/destroy_macro.rb
111
- - test/macros/instance_wrapper/new_record_macro.rb
112
- - test/macros/instance_wrapper/save_macro.rb
113
- - test/macros/veneer_constants_interface.rb
114
- - test/support/before_save_mixin.rb
115
103
  - test/support/helpers.rb
116
- - test/support/valiations_method_method.rb
117
104
  - test/test_helper.rb
118
- - test/veneer/adapters/active_record/active_record_setup.rb
119
- - test/veneer/adapters/active_record/class_wrapper_test.rb
120
- - test/veneer/adapters/active_record/instance_wrapper_test.rb
121
- - test/veneer/adapters/datamapper/class_wrapper_test.rb
122
- - test/veneer/adapters/datamapper/datamapper_setup.rb
123
- - test/veneer/adapters/datamapper/instance_wrapper_test.rb
124
- - test/veneer/adapters/mongomapper/class_wrapper_test.rb
125
- - test/veneer/adapters/mongomapper/instance_wrapper_test.rb
126
- - test/veneer/adapters/mongomapper/mongomapper_setup.rb
127
- - test/veneer/base/conditonal_test.rb
105
+ - test/veneer/adapters/test_active_record.rb
106
+ - test/veneer/adapters/test_datamapper.rb
107
+ - test/veneer/adapters/test_mongomapper.rb
128
108
  - test/veneer/proxy_test.rb
data/README.textile DELETED
@@ -1,142 +0,0 @@
1
- h1. veneer
2
-
3
- Veneer is an interface that sits above Data Sources. A data source may be an ORM like ActiveRecord or DataMapper, or it could be a document store like MongoMapper or even just an storage like Moneta.
4
-
5
- Veneer aims to provide plugin authors with a consistant interface to any of these libraries so that plugins, engines, stacks and gems may be used across data store types. Reusable code FTW!
6
-
7
- It differs from ActiveModel in that it doesn't provide any validation support, serialization, callbacks, state machine or anything like that. Veneer is intended to work with ActiveModel to provide a data store independant interface to create reusable code.
8
-
9
- Veneer instead aims to provide a simple interface for
10
- * querying
11
- * creating
12
- * saving
13
- * deleting
14
-
15
- h2. Creating and Saving an instance
16
-
17
- To create an instance of an object wrap the class in a vaneer call and create or get a new instance.
18
-
19
- <pre><code>obj = Veneer(MyModel).new(:some => "attribute")
20
- obj.save
21
-
22
- # OR
23
-
24
- obj = Veneer(MyModel).create(:some => "attribute")
25
- </code></pre>
26
-
27
- There are also version that will raise an exception if it could not save
28
-
29
- <pre><code>obj = Veneer(MyModel).new(:some => "attribute").save!
30
-
31
- # OR
32
-
33
- obj = Veneer(MyModel).create!(:some => "attribute")
34
- </code></pre>
35
-
36
- h2. Deleting
37
-
38
- You can delete all the instances of a model or a single instance.
39
-
40
- <pre><code>Veneer(MyModel).destroy_all # delete all instances
41
-
42
- @some_veneer_model.destroy
43
- </code></pre>
44
-
45
- h2. Queries
46
-
47
- Veneer lets you query models with a simple interface. Only simple queries are supported.
48
-
49
- You can query a single object, or multiple objects.
50
-
51
- <pre><code>Veneer(MyModel).first(:conditions => {:name => "foo"})
52
-
53
- Veneer(MyModel).all(:conditions => {"age gte" => 18}, :limit => 5)
54
- </code></pre>
55
-
56
- The supported options are:
57
-
58
- * :limit
59
- * :offset
60
- * :order
61
- * :conditions
62
-
63
- h3. Limit & Offset
64
-
65
- The :limit option will limit the number of returned results.
66
-
67
- The :offset option, when set to an integer x will begin the results at the xth result.
68
-
69
- h3. Order
70
-
71
- Ordering should be set as a string. By default, the order is decending.
72
-
73
- The format of the string is:
74
-
75
- <pre><code>"<field> (<directon>), <field> (direction), ..."
76
-
77
- # eg
78
- Veneer(MyModel).all(:order => "name, age desc")
79
- </code></pre>
80
-
81
- h3. Conditions
82
-
83
- Conditions are a very simple set of conditions on the fields of the model. The for of the conditions are:
84
-
85
- <pre><code>:conditions => {"field operator" => value}</code></pre>
86
-
87
- The supported operators are
88
-
89
- * eql
90
- * not
91
- * lt (less than)
92
- * lte (less than or equal to)
93
- * gt (greater than)
94
- * gte (greater than or equal to)
95
- * in (in an array)
96
-
97
- By default, the operator is set to eql
98
-
99
- <pre><code>
100
- Veneer(MyModel).all(:conditions => {"name in" => ["fred", "barney"], "age gte" => 18})
101
- Veneer(MyModel).first(:conditions => {:name => "fred"})
102
- </code></pre>
103
-
104
- The results of a query are all wrapped as Veneer instances.
105
-
106
- h3. All Together
107
-
108
- <pre><code>Veneer(MyModel).all(:order => "name, age asc", :limit => 5, :offset => 15, :conditions => {"name not" => "betty", "age lt" => 18})
109
- </code></pre>
110
-
111
- h2. Object methods
112
-
113
- All methods that aren't found on the adapter, are passed through to the instance. So to access any attributes on the actual model instance, just call the method on it.
114
-
115
- h2. Current Support
116
-
117
- Veneer currently has built in support for ActiveRecord and DataMapper.
118
-
119
- Veneer works on a VeneerInterface inner module though so you can easily impelment your adapter without requiring it to be in the veneer repo (although pull requests are welcome)
120
-
121
- To use DataMapper or ActiveRecord
122
-
123
- <pre><code>
124
- require 'veneer/adapters/activerecord'
125
- require 'veneer/adapters/datamapper'
126
- </code></pre>
127
-
128
-
129
- == Note on Patches/Pull Requests
130
-
131
- * Fork the project.
132
- * Make your feature addition or bug fix.
133
- * Add tests for it. This is important so I don't break it in a
134
- future version unintentionally.
135
- * Commit, do not mess with rakefile, version, or history.
136
- (if you want to have your own version, that is fine but
137
- bump version in a commit by itself I can ignore when I pull)
138
- * Send me a pull request. Bonus points for topic branches.
139
-
140
- == Copyright
141
-
142
- Copyright (c) 2009 Daniel Neighman. See LICENSE for details.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.3
data/datamapper_setup.rb DELETED
@@ -1,2 +0,0 @@
1
- require 'dm-core'
2
-
@@ -1,77 +0,0 @@
1
- module Veneer
2
- class Conditional
3
-
4
- def self.from_hash(hash)
5
- new(hash)
6
- end
7
-
8
- attr_reader :options
9
- def initialize(opts)
10
- @options = Hashie::Mash.new(opts || {})
11
- odr = [@options.delete("order")].flatten.compact
12
- @ordering = odr.nil? || odr.empty? ? [] : begin
13
- odr.map do |order|
14
- field, direction = order.split(" ")
15
- Order.new(field, (direction || :desc))
16
- end
17
- end
18
-
19
- conds = opts.fetch(:conditions, {})
20
- @conditions = conds.map do |k,v|
21
- field, operator = k.to_s.split(" ")
22
- args = [field, v]
23
- args << operator.to_sym if operator
24
- Veneer::Conditional::Condition.new(*args)
25
- end
26
- end
27
-
28
- def limit
29
- @options[:limit]
30
- end
31
-
32
- def offset
33
- @options[:offset]
34
- end
35
-
36
- def order
37
- @ordering
38
- end
39
-
40
- def conditions
41
- @conditions
42
- end
43
-
44
- class Order
45
- attr_reader :field, :direction
46
- def initialize(field, direction = :desc)
47
- @field = field.to_sym
48
- @direction = direction.to_sym
49
- end
50
-
51
- def ascending?
52
- direction == :asc
53
- end
54
-
55
- def decending?
56
- !ascending?
57
- end
58
-
59
- def ==(other)
60
- self.class == other.class &&
61
- field == other.field &&
62
- direction == other.direction
63
- end
64
- end
65
-
66
- class Condition
67
- attr_accessor :field, :operator, :value
68
-
69
- VALID_OPERATORS = [:eql, :gt, :gte, :lt, :lte, :in, :not]
70
-
71
- def initialize(field, value, operator = :eql)
72
- @field, @value, @operator = field.to_sym, value, operator.to_sym
73
- raise Veneer::Errors::ConditionalOperatorNotSupported, "#{operator.inspect} not a valid operator" unless VALID_OPERATORS.include?(operator)
74
- end
75
- end
76
- end
77
- end
@@ -1,54 +0,0 @@
1
- class Test::Unit::TestCase
2
- def self.veneer_should_implement_create_with_valid_attributes
3
- context "implements create with valid attributes" do
4
- should "setup the spec correctly" do
5
- assert_not_nil @klass
6
- assert_kind_of Class, @klass
7
- assert_not_nil @valid_attributes
8
- assert_kind_of Hash, @valid_attributes
9
- end
10
-
11
- teardown do
12
- Veneer(@klass).destroy_all
13
- end
14
-
15
- should "create the object from the hash" do
16
- r = Veneer(@klass).create(@valid_attributes)
17
- assert_instance_of @klass::VeneerInterface::InstanceWrapper, r
18
- end
19
-
20
- should "create the object from the hash with create!" do
21
- r = Veneer(@klass).create!(@valid_attributes)
22
- assert_instance_of @klass::VeneerInterface::InstanceWrapper, r
23
- end
24
-
25
- should "create a new instance of the object" do
26
- r = Veneer(@klass).new(@valid_attributes)
27
- assert_instance_of @klass::VeneerInterface::InstanceWrapper, r
28
- end
29
- end
30
-
31
- def self.veneer_should_implement_create_with_invalid_attributes
32
- context "implements create! with invalid attributes" do
33
- should "setup the spec correctly" do
34
- assert_not_nil @klass
35
- assert_kind_of Class, @klass
36
- assert_not_nil @invalid_attributes
37
- assert_kind_of Hash, @invalid_attributes
38
- end
39
-
40
- should "raise when creating could not save" do
41
- assert_raise Veneer::Errors::NotSaved do
42
- Veneer(@klass).create!(@invalid_attributes)
43
- end
44
- end
45
-
46
- should "not raise when create can not save" do
47
- assert_nothing_raised do
48
- Veneer(@klass).create(@invalid_attributes)
49
- end
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,31 +0,0 @@
1
- class Test::Unit::TestCase
2
- def self.veneer_should_impelement_destroy_all
3
- context "implements destroy_all" do
4
- should "setup the test correctly" do
5
- assert_not_nil @klass
6
- assert_kind_of Class, @klass
7
- assert_not_nil @valid_attributes
8
- assert_kind_of Hash, @valid_attributes
9
- end
10
-
11
- context "destroy_all" do
12
- setup do
13
- Veneer(@klass).destroy_all
14
- assert_equal 0, Veneer(@klass).all.size
15
- (0..5).each do |i|
16
- Veneer(@klass).new(:name => "foo#{i}", :order_field1 => i).save
17
- end
18
- end
19
-
20
- should "setup the spec correctly" do
21
- assert_equal 6, Veneer(@klass).all.size
22
- end
23
-
24
- should "destroy all records" do
25
- Veneer(@klass).destroy_all
26
- assert_equal 0, Veneer(@klass).all.size
27
- end
28
- end
29
- end
30
- end
31
- end