defunkt-ambition 0.5.3

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.
Files changed (44) hide show
  1. data/LICENSE +18 -0
  2. data/Manifest +42 -0
  3. data/README +24 -0
  4. data/ambition.gemspec +120 -0
  5. data/app_generators/ambition_adapter/USAGE +1 -0
  6. data/app_generators/ambition_adapter/ambition_adapter_generator.rb +66 -0
  7. data/app_generators/ambition_adapter/templates/LICENSE +18 -0
  8. data/app_generators/ambition_adapter/templates/README +6 -0
  9. data/app_generators/ambition_adapter/templates/Rakefile +31 -0
  10. data/app_generators/ambition_adapter/templates/lib/adapter/base.rb.erb +12 -0
  11. data/app_generators/ambition_adapter/templates/lib/adapter/query.rb.erb +52 -0
  12. data/app_generators/ambition_adapter/templates/lib/adapter/select.rb.erb +100 -0
  13. data/app_generators/ambition_adapter/templates/lib/adapter/slice.rb.erb +19 -0
  14. data/app_generators/ambition_adapter/templates/lib/adapter/sort.rb.erb +43 -0
  15. data/app_generators/ambition_adapter/templates/lib/init.rb.erb +22 -0
  16. data/app_generators/ambition_adapter/templates/test/helper.rb.erb +9 -0
  17. data/app_generators/ambition_adapter/templates/test/select_test.rb.erb +157 -0
  18. data/app_generators/ambition_adapter/templates/test/slice_test.rb.erb +36 -0
  19. data/app_generators/ambition_adapter/templates/test/sort_test.rb.erb +53 -0
  20. data/bin/ambition_adapter +13 -0
  21. data/lib/ambition/api.rb +98 -0
  22. data/lib/ambition/context.rb +62 -0
  23. data/lib/ambition/core_ext.rb +7 -0
  24. data/lib/ambition/enumerable.rb +6 -0
  25. data/lib/ambition/processors/base.rb +134 -0
  26. data/lib/ambition/processors/ruby.rb +26 -0
  27. data/lib/ambition/processors/select.rb +105 -0
  28. data/lib/ambition/processors/slice.rb +15 -0
  29. data/lib/ambition/processors/sort.rb +51 -0
  30. data/lib/ambition/sexp_translator.rb +16 -0
  31. data/lib/ambition.rb +11 -0
  32. data/test/adapters/exemplar/association_test.rb +34 -0
  33. data/test/adapters/exemplar/count_test.rb +0 -0
  34. data/test/adapters/exemplar/detect_test.rb +9 -0
  35. data/test/adapters/exemplar/enumerable_test.rb +0 -0
  36. data/test/adapters/exemplar/helper.rb +3 -0
  37. data/test/adapters/exemplar/index_operator.rb +6 -0
  38. data/test/adapters/exemplar/reject_test.rb +0 -0
  39. data/test/adapters/exemplar/select_test.rb +151 -0
  40. data/test/adapters/exemplar/slice_test.rb +0 -0
  41. data/test/adapters/exemplar/sort_test.rb +0 -0
  42. data/test/debug +9 -0
  43. data/test/helper.rb +4 -0
  44. metadata +139 -0
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2007 Chris Wanstrath
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,42 @@
1
+ app_generators/ambition_adapter/ambition_adapter_generator.rb
2
+ app_generators/ambition_adapter/templates/lib/adapter/base.rb.erb
3
+ app_generators/ambition_adapter/templates/lib/adapter/query.rb.erb
4
+ app_generators/ambition_adapter/templates/lib/adapter/select.rb.erb
5
+ app_generators/ambition_adapter/templates/lib/adapter/slice.rb.erb
6
+ app_generators/ambition_adapter/templates/lib/adapter/sort.rb.erb
7
+ app_generators/ambition_adapter/templates/lib/init.rb.erb
8
+ app_generators/ambition_adapter/templates/LICENSE
9
+ app_generators/ambition_adapter/templates/Rakefile
10
+ app_generators/ambition_adapter/templates/README
11
+ app_generators/ambition_adapter/templates/test/helper.rb.erb
12
+ app_generators/ambition_adapter/templates/test/select_test.rb.erb
13
+ app_generators/ambition_adapter/templates/test/slice_test.rb.erb
14
+ app_generators/ambition_adapter/templates/test/sort_test.rb.erb
15
+ app_generators/ambition_adapter/USAGE
16
+ bin/ambition_adapter
17
+ lib/ambition/api.rb
18
+ lib/ambition/context.rb
19
+ lib/ambition/core_ext.rb
20
+ lib/ambition/enumerable.rb
21
+ lib/ambition/processors/base.rb
22
+ lib/ambition/processors/ruby.rb
23
+ lib/ambition/processors/select.rb
24
+ lib/ambition/processors/slice.rb
25
+ lib/ambition/processors/sort.rb
26
+ lib/ambition/sexp_translator.rb
27
+ lib/ambition.rb
28
+ LICENSE
29
+ Manifest
30
+ README
31
+ test/adapters/exemplar/association_test.rb
32
+ test/adapters/exemplar/count_test.rb
33
+ test/adapters/exemplar/detect_test.rb
34
+ test/adapters/exemplar/enumerable_test.rb
35
+ test/adapters/exemplar/helper.rb
36
+ test/adapters/exemplar/index_operator.rb
37
+ test/adapters/exemplar/reject_test.rb
38
+ test/adapters/exemplar/select_test.rb
39
+ test/adapters/exemplar/slice_test.rb
40
+ test/adapters/exemplar/sort_test.rb
41
+ test/debug
42
+ test/helper.rb
data/README ADDED
@@ -0,0 +1,24 @@
1
+ = Ambition
2
+
3
+
4
+ == Get it
5
+
6
+
7
+
8
+ $ git clone git://github.com/defunkt/ambition.git
9
+
10
+ == Resources
11
+
12
+ * http://ambition.rubyforge.org/
13
+ * http://groups.google.com/group/ambition-rb/
14
+ * http://errtheblog.com/posts/63-full-of-ambition
15
+ * http://errtheblog.com/posts/82-adapting-ambitiously
16
+ * http://errtheblog.com/posts/86-sugary-adapters
17
+ * http://errtheblog.com/posts/64-even-more-ambitious
18
+
19
+
20
+
21
+ == Author
22
+
23
+ Chris Wanstrath
24
+ chris@ozmm.org
data/ambition.gemspec ADDED
@@ -0,0 +1,120 @@
1
+
2
+ # Gem::Specification for Ambition-0.5.3
3
+ # Originally generated by Echoe
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{ambition}
7
+ s.version = "0.5.3"
8
+
9
+ s.specification_version = 2 if s.respond_to? :specification_version=
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["Chris Wanstrath"]
13
+ s.date = %q{2008-04-26}
14
+ s.default_executable = %q{ambition_adapter}
15
+ s.description = %q{Ambition builds yer API calls from plain jane Ruby.}
16
+ s.email = %q{chris@ozmm.org}
17
+ s.executables = ["ambition_adapter"]
18
+ s.extra_rdoc_files = ["bin/ambition_adapter", "lib/ambition/api.rb", "lib/ambition/context.rb", "lib/ambition/core_ext.rb", "lib/ambition/enumerable.rb", "lib/ambition/processors/base.rb", "lib/ambition/processors/ruby.rb", "lib/ambition/processors/select.rb", "lib/ambition/processors/slice.rb", "lib/ambition/processors/sort.rb", "lib/ambition/sexp_translator.rb", "lib/ambition.rb", "LICENSE", "README"]
19
+ s.files = ["app_generators/ambition_adapter/ambition_adapter_generator.rb", "app_generators/ambition_adapter/templates/lib/adapter/base.rb.erb", "app_generators/ambition_adapter/templates/lib/adapter/query.rb.erb", "app_generators/ambition_adapter/templates/lib/adapter/select.rb.erb", "app_generators/ambition_adapter/templates/lib/adapter/slice.rb.erb", "app_generators/ambition_adapter/templates/lib/adapter/sort.rb.erb", "app_generators/ambition_adapter/templates/lib/init.rb.erb", "app_generators/ambition_adapter/templates/LICENSE", "app_generators/ambition_adapter/templates/Rakefile", "app_generators/ambition_adapter/templates/README", "app_generators/ambition_adapter/templates/test/helper.rb.erb", "app_generators/ambition_adapter/templates/test/select_test.rb.erb", "app_generators/ambition_adapter/templates/test/slice_test.rb.erb", "app_generators/ambition_adapter/templates/test/sort_test.rb.erb", "app_generators/ambition_adapter/USAGE", "bin/ambition_adapter", "lib/ambition/api.rb", "lib/ambition/context.rb", "lib/ambition/core_ext.rb", "lib/ambition/enumerable.rb", "lib/ambition/processors/base.rb", "lib/ambition/processors/ruby.rb", "lib/ambition/processors/select.rb", "lib/ambition/processors/slice.rb", "lib/ambition/processors/sort.rb", "lib/ambition/sexp_translator.rb", "lib/ambition.rb", "LICENSE", "Manifest", "README", "test/adapters/exemplar/association_test.rb", "test/adapters/exemplar/count_test.rb", "test/adapters/exemplar/detect_test.rb", "test/adapters/exemplar/enumerable_test.rb", "test/adapters/exemplar/helper.rb", "test/adapters/exemplar/index_operator.rb", "test/adapters/exemplar/reject_test.rb", "test/adapters/exemplar/select_test.rb", "test/adapters/exemplar/slice_test.rb", "test/adapters/exemplar/sort_test.rb", "test/debug", "test/helper.rb", "ambition.gemspec"]
20
+ s.has_rdoc = true
21
+ s.homepage = %q{http://errtheblog.com/}
22
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ambition", "--main", "README"]
23
+ s.require_paths = ["lib"]
24
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8.6")
25
+ s.rubyforge_project = %q{err}
26
+ s.rubygems_version = %q{1.0.1}
27
+ s.summary = %q{Ambition builds yer API calls from plain jane Ruby.}
28
+
29
+ s.add_dependency(%q<ParseTree>, ["= 2.0.1"])
30
+ s.add_dependency(%q<ruby2ruby>, ["= 1.1.7"])
31
+ s.add_dependency(%q<rubigen>, ["= 1.1.1"])
32
+ end
33
+
34
+
35
+ # # Original Rakefile source (requires the Echoe gem):
36
+ #
37
+ # require 'rake'
38
+ # require 'rake/testtask'
39
+ # require 'rake/rdoctask'
40
+ #
41
+ # Version = '0.5.3'
42
+ #
43
+ # module Rake::TaskManager
44
+ # def delete_task(task_class, *args, &block)
45
+ # task_name, deps = resolve_args(args)
46
+ # @tasks.delete(task_class.scope_name(@scope, task_name).to_s)
47
+ # end
48
+ # end
49
+ # class Rake::Task
50
+ # def self.delete_task(args, &block) Rake.application.delete_task(self, args, &block) end
51
+ # end
52
+ # def delete_task(args, &block) Rake::Task.delete_task(args, &block) end
53
+ #
54
+ # begin
55
+ # require 'rubygems'
56
+ # gem 'echoe', '>=2.7'
57
+ # ENV['RUBY_FLAGS'] = ""
58
+ # require 'echoe'
59
+ #
60
+ # Echoe.new('ambition', Version) do |p|
61
+ # p.project = 'err'
62
+ # p.summary = "Ambition builds yer API calls from plain jane Ruby."
63
+ # p.description = "Ambition builds yer API calls from plain jane Ruby."
64
+ # p.url = "http://errtheblog.com/"
65
+ # p.author = 'Chris Wanstrath'
66
+ # p.email = "chris@ozmm.org"
67
+ # p.ruby_version = '>= 1.8.6'
68
+ # p.ignore_pattern = /^(\.git|site|adapters).+/
69
+ # p.test_pattern = 'test/*_test.rb'
70
+ # p.dependencies << 'ParseTree =2.0.1'
71
+ # p.dependencies << 'ruby2ruby =1.1.7'
72
+ # p.dependencies << 'rubigen =1.1.1'
73
+ # end
74
+ #
75
+ # rescue LoadError
76
+ # puts "Not doing any of the Echoe gemmy stuff, because you don't have the specified gem versions"
77
+ # end
78
+ #
79
+ # delete_task :test
80
+ # delete_task :install_gem
81
+ #
82
+ # Rake::TestTask.new('test') do |t|
83
+ # t.pattern = 'test/*_test.rb'
84
+ # end
85
+ #
86
+ # Rake::TestTask.new('test:adapters') do |t|
87
+ # t.pattern = 'adapters/*/test/*_test.rb'
88
+ # end
89
+ #
90
+ # Dir['adapters/*'].each do |adapter|
91
+ # adapter = adapter.split('/').last
92
+ # Rake::TestTask.new("test:adapters:#{adapter.sub('ambitious_','')}") do |t|
93
+ # t.pattern = "adapters/#{adapter}/test/*_test.rb"
94
+ # end
95
+ # end
96
+ #
97
+ # desc 'Default: run unit tests.'
98
+ # task :default => :test
99
+ #
100
+ # desc 'Generate RDoc documentation'
101
+ # Rake::RDocTask.new(:rdoc) do |rdoc|
102
+ # files = ['README', 'LICENSE', 'lib/**/*.rb']
103
+ # rdoc.rdoc_files.add(files)
104
+ # rdoc.main = "README"
105
+ # rdoc.title = "ambition"
106
+ # # rdoc.template = File.exists?(t="/Users/chris/ruby/projects/err/rock/template.rb") ? t : "/var/www/rock/template.rb"
107
+ # rdoc.rdoc_dir = 'doc'
108
+ # rdoc.options << '--inline-source'
109
+ # end
110
+ #
111
+ # desc 'Generate coverage reports'
112
+ # task :rcov do
113
+ # `rcov -e gems test/*_test.rb`
114
+ # puts 'Generated coverage reports.'
115
+ # end
116
+ #
117
+ # desc 'Install as a gem'
118
+ # task :install_gem do
119
+ # puts `rake manifest package && gem install pkg/ambition-#{Version}.gem`
120
+ # end
@@ -0,0 +1 @@
1
+ o.
@@ -0,0 +1,66 @@
1
+ class AmbitionAdapterGenerator < RubiGen::Base
2
+ # DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
3
+ # default_options :author => nil
4
+
5
+ attr_reader :adapter_name, :adapter_module
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ super
9
+ usage if args.empty?
10
+ @destination_root = File.expand_path(args.shift)
11
+ base_name = self.base_name.sub(/ambitious(-|_)/,'')
12
+ @adapter_name = base_name
13
+ @adapter_module = base_name.split('_').map { |part| part[0] = part[0...1].upcase; part }.join
14
+ extract_options
15
+ end
16
+
17
+ def manifest
18
+ record do |m|
19
+ # Ensure appropriate folder(s) exists
20
+ m.directory ''
21
+ dirs = %W(
22
+ lib/ambition/adapters/#{adapter_name}
23
+ test
24
+ )
25
+ dirs.each { |path| m.directory path }
26
+
27
+ ##
28
+ # Translator / Query stubs
29
+ adapter_path = "lib/ambition/adapters/#{adapter_name}"
30
+
31
+ %w( base query select slice sort ).each do |file|
32
+ m.template "lib/adapter/#{file}.rb.erb", "#{adapter_path}/#{file}.rb"
33
+ end
34
+
35
+ m.template 'lib/init.rb.erb', "#{adapter_path}.rb"
36
+
37
+ ##
38
+ # Test stubs
39
+ Dir[File.dirname(__FILE__) + '/templates/test/*.rb.erb'].each do |file|
40
+ file = File.basename(file, '.*')
41
+ m.template "test/#{file}.erb", "test/#{file}"
42
+ end
43
+
44
+ ##
45
+ # Normal files
46
+ files = %w( LICENSE README Rakefile )
47
+ files.each do |file|
48
+ m.template file, file
49
+ end
50
+ end
51
+ end
52
+
53
+ protected
54
+ def banner
55
+ "Usage: ambition_adapter adapter_name"
56
+ end
57
+
58
+ def add_options!(opts)
59
+ opts.separator ''
60
+ opts.separator 'Options:'
61
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
62
+ opts.separator ''
63
+ end
64
+
65
+ def extract_options; end
66
+ end
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2007 Your Name
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ <%= string = "An Ambitious #{adapter_module} Adapter" %>
2
+ <%= '=' * string.size %>
3
+
4
+ More information on Ambition:
5
+ -> http://ambition.rubyforge.org
6
+ -> http://groups.google.com/group/ambition-rb/
@@ -0,0 +1,31 @@
1
+ require 'rake'
2
+
3
+ Version = '0.1.0'
4
+
5
+ begin
6
+ require 'rubygems'
7
+ gem 'echoe', '>=2.7'
8
+ ENV['RUBY_FLAGS'] = ""
9
+ require 'echoe'
10
+
11
+ Echoe.new('ambitious-<%= adapter_name %>') do |p|
12
+ p.dependencies << '<%= adapter_name %> >=1.0'
13
+ p.summary = "An ambitious adapter for <%= adapter_module %>"
14
+ p.author = 'Your Name'
15
+ p.email = "your@email.com"
16
+
17
+ p.project = 'ambition'
18
+ p.url = "http://ambition.rubyforge.org/"
19
+ p.test_pattern = 'test/*_test.rb'
20
+ p.version = Version
21
+ p.dependencies << 'ambition >=0.5.0'
22
+ end
23
+
24
+ rescue LoadError
25
+ puts "Not doing any of the Echoe gemmy stuff, because you don't have the specified gem versions"
26
+ end
27
+
28
+ desc 'Install as a gem'
29
+ task :install_gem do
30
+ puts `rake manifest package && gem install pkg/ambitious-<%= adapter_name %>-#{Version}.gem`
31
+ end
@@ -0,0 +1,12 @@
1
+ module Ambition
2
+ module Adapters
3
+ module <%= adapter_module %>
4
+ class Base
5
+ ##
6
+ # Extract common functionality into this class.
7
+ # All your classes, by default, inherit from this
8
+ # one -- Query and the Translators.
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,52 @@
1
+ =begin
2
+
3
+ These methods are king:
4
+
5
+ - owner
6
+ - clauses
7
+ - stash
8
+
9
+ +owner+ is the class from which the request was generated.
10
+
11
+ User.select { |u| u.name == 'Pork' }
12
+ # => owner == User
13
+
14
+ +clauses+ is the hash of translated arrays, keyed by processors
15
+
16
+ User.select { |u| u.name == 'Pork' }
17
+ # => clauses == { :select => [ "users.name = 'Pork'" ] }
18
+
19
+ +stash+ is your personal private stash. A hash you can use for
20
+ keeping stuff around.
21
+
22
+ User.select { |u| u.profile.name == 'Pork' }
23
+ # => stash == { :include => [ :profile ] }
24
+
25
+ The above is totally arbitrary. It's basically a way for your
26
+ translators to talk to each other and, more importantly, to the Query
27
+ object.
28
+
29
+ =end
30
+ module Ambition
31
+ module Adapters
32
+ module <%= adapter_module %>
33
+ class Query < Base
34
+ def kick
35
+ raise "Example: owner.find(:all, to_hash)"
36
+ end
37
+
38
+ def size
39
+ raise "Example: owner.count(to_hash)"
40
+ end
41
+
42
+ def to_hash
43
+ raise "Not implemented"
44
+ end
45
+
46
+ def to_s
47
+ raise "Not implemented"
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,100 @@
1
+ ##
2
+ # The format of the documentation herein is:
3
+ #
4
+ # >> method with block
5
+ # => methods on this class called by Ambition (with arguments)
6
+ #
7
+ module Ambition
8
+ module Adapters
9
+ module <%= adapter_module %>
10
+ class Select < Base
11
+ # >> select { |u| u.name == 'chris' }
12
+ # => #call(:name)
13
+ def call(method)
14
+ raise "Not implemented."
15
+ end
16
+
17
+ # >> select { |u| u.name.downcase == 'chris' }
18
+ # => #call(:name, :downcase)
19
+ def chained_call(*methods)
20
+ # An idiom here is to call the chained method and pass it
21
+ # the first method.
22
+ #
23
+ # if respond_to? methods[1]
24
+ # send(methods[1], methods[0])
25
+ # end
26
+ #
27
+ # In the above example, this translates to calling:
28
+ #
29
+ # #downcase(:name)
30
+ #
31
+ raise "Not implemented."
32
+ end
33
+
34
+ # &&
35
+ # >> select { |u| u.name == 'chris' && u.age == 22 }
36
+ # => #both( processed left side, processed right side )
37
+ def both(left, right)
38
+ raise "Not implemented."
39
+ end
40
+
41
+ # ||
42
+ # >> select { |u| u.name == 'chris' || u.age == 22 }
43
+ # => #either( processed left side, processed right side )
44
+ def either(left, right)
45
+ raise "Not implemented."
46
+ end
47
+
48
+ # >> select { |u| u.name == 'chris' }
49
+ # => #==( call(:name), 'chris' )
50
+ def ==(left, right)
51
+ raise "Not implemented."
52
+ end
53
+
54
+ # !=
55
+ # >> select { |u| u.name != 'chris' }
56
+ # => #not_equal( call(:name), 'chris' )
57
+ def not_equal(left, right)
58
+ raise "Not implemented."
59
+ end
60
+
61
+ # >> select { |u| u.name =~ 'chris' }
62
+ # => #=~( call(:name), 'chris' )
63
+ def =~(left, right)
64
+ raise "Not implemented."
65
+ end
66
+
67
+ # !~
68
+ # >> select { |u| u.name !~ 'chris' }
69
+ # => #not_regexp( call(:name), 'chris' )
70
+ def not_regexp(left, right)
71
+ raise "Not implemented."
72
+ end
73
+
74
+ ##
75
+ # Etc.
76
+ def <(left, right)
77
+ raise "Not implemented."
78
+ end
79
+
80
+ def >(left, right)
81
+ raise "Not implemented."
82
+ end
83
+
84
+ def >=(left, right)
85
+ raise "Not implemented."
86
+ end
87
+
88
+ def <=(left, right)
89
+ raise "Not implemented."
90
+ end
91
+
92
+ # >> select { |u| [1, 2, 3].include? u.id }
93
+ # => #include?( [1, 2, 3], call(:id) )
94
+ def include?(left, right)
95
+ raise "Not implemented."
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,19 @@
1
+ module Ambition
2
+ module Adapters
3
+ module <%= adapter_module %>
4
+ class Slice < Base
5
+ # >> User.first(5)
6
+ # => #slice(0, 5)
7
+ #
8
+ # >> User.first
9
+ # => #slice(0, 1)
10
+ #
11
+ # >> User[10, 20]
12
+ # => #slice(10, 20)
13
+ def slice(start, length)
14
+ raise "Not implemented."
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,43 @@
1
+ module Ambition
2
+ module Adapters
3
+ module <%= adapter_module %>
4
+ class Sort < Base
5
+ # >> sort_by { |u| u.age }
6
+ # => #sort_by(:age)
7
+ def sort_by(method)
8
+ raise "Not implemented."
9
+ end
10
+
11
+ # >> sort_by { |u| -u.age }
12
+ # => #reverse_sort_by(:age)
13
+ def reverse_sort_by(method)
14
+ raise "Not implemented."
15
+ end
16
+
17
+ # >> sort_by { |u| u.profile.name }
18
+ # => #chained_sort_by(:profile, :name)
19
+ def chained_sort_by(receiver, method)
20
+ raise "Not implemented."
21
+ end
22
+
23
+ # >> sort_by { |u| -u.profile.name }
24
+ # => #chained_reverse_sort_by(:profile, :name)
25
+ def chained_reverse_sort_by(receiver, method)
26
+ raise "Not implemented."
27
+ end
28
+
29
+ # >> sort_by(&:name)
30
+ # => #to_proc(:name)
31
+ def to_proc(symbol)
32
+ raise "Not implemented."
33
+ end
34
+
35
+ # >> sort_by { rand }
36
+ # => #rand
37
+ def rand
38
+ raise "Not implemented."
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ require 'ambition'
2
+ require '<%= adapter_name %>'
3
+ require 'ambition/adapters/<%= adapter_name %>/base'
4
+ require 'ambition/adapters/<%= adapter_name %>/query'
5
+ require 'ambition/adapters/<%= adapter_name %>/select'
6
+ require 'ambition/adapters/<%= adapter_name %>/sort'
7
+ require 'ambition/adapters/<%= adapter_name %>/slice'
8
+
9
+ ##
10
+ # This is where you inject Ambition into your target.
11
+ #
12
+ # Use `extend' if you are injecting a class, `include' if you are
13
+ # injecting instances of that class.
14
+ #
15
+ # You must also set the `ambition_adapter' class variable on your target
16
+ # class, regardless of whether you are injecting instances or the class itself.
17
+ #
18
+ # You probably want something like this:
19
+ #
20
+ # <%= adapter_module %>::Base.extend Ambition::API
21
+ # <%= adapter_module %>::Base.ambition_adapter = Ambition::Adapters::<%= adapter_module %>
22
+ #
@@ -0,0 +1,9 @@
1
+ %w( rubygems test/spec mocha English ).each { |f| require f }
2
+
3
+ begin
4
+ require 'redgreen'
5
+ rescue LoadError
6
+ end
7
+
8
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
9
+ require 'ambition/adapters/<%= adapter_name %>'