ambition 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -1,10 +1,10 @@
1
1
  app_generators/ambition_adapter/ambition_adapter_generator.rb
2
- app_generators/ambition_adapter/templates/lib/base.rb.erb
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
3
7
  app_generators/ambition_adapter/templates/lib/init.rb.erb
4
- app_generators/ambition_adapter/templates/lib/query.rb.erb
5
- app_generators/ambition_adapter/templates/lib/select.rb.erb
6
- app_generators/ambition_adapter/templates/lib/slice.rb.erb
7
- app_generators/ambition_adapter/templates/lib/sort.rb.erb
8
8
  app_generators/ambition_adapter/templates/LICENSE
9
9
  app_generators/ambition_adapter/templates/Rakefile
10
10
  app_generators/ambition_adapter/templates/README
@@ -23,6 +23,7 @@ lib/ambition/processors/ruby.rb
23
23
  lib/ambition/processors/select.rb
24
24
  lib/ambition/processors/slice.rb
25
25
  lib/ambition/processors/sort.rb
26
+ lib/ambition/sexp_translator.rb
26
27
  lib/ambition.rb
27
28
  LICENSE
28
29
  Manifest
data/ambition.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
 
2
- # Gem::Specification for Ambition-0.5.0
2
+ # Gem::Specification for Ambition-0.5.1
3
3
  # Originally generated by Echoe
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{ambition}
7
- s.version = "0.5.0"
8
- s.date = %q{2008-01-29}
7
+ s.version = "0.5.1"
8
+ s.date = %q{2008-02-16}
9
9
  s.summary = %q{Ambition builds yer API calls from plain jane Ruby.}
10
10
  s.email = %q{chris@ozmm.org}
11
11
  s.homepage = %q{http://errtheblog.com/}
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.has_rdoc = true
16
16
  s.required_ruby_version = Gem::Version::Requirement.new(">= 1.8.6")
17
17
  s.authors = ["Chris Wanstrath"]
18
- s.files = ["app_generators/ambition_adapter/ambition_adapter_generator.rb", "app_generators/ambition_adapter/templates/lib/base.rb.erb", "app_generators/ambition_adapter/templates/lib/init.rb.erb", "app_generators/ambition_adapter/templates/lib/query.rb.erb", "app_generators/ambition_adapter/templates/lib/select.rb.erb", "app_generators/ambition_adapter/templates/lib/slice.rb.erb", "app_generators/ambition_adapter/templates/lib/sort.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.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"]
18
+ 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"]
19
19
  s.executables = ["ambition_adapter"]
20
20
  s.add_dependency(%q<ParseTree>, ["= 2.0.1"])
21
21
  s.add_dependency(%q<ruby2ruby>, ["= 1.1.7"])
@@ -29,7 +29,7 @@ end
29
29
  # require 'rake/testtask'
30
30
  # require 'rake/rdoctask'
31
31
  #
32
- # Version = '0.5.0'
32
+ # Version = '0.5.1'
33
33
  #
34
34
  # module Rake::TaskManager
35
35
  # def delete_task(task_class, *args, &block)
@@ -29,7 +29,7 @@ class AmbitionAdapterGenerator < RubiGen::Base
29
29
  adapter_path = "lib/ambition/adapters/#{adapter_name}"
30
30
 
31
31
  %w( base query select slice sort ).each do |file|
32
- m.template "lib/#{file}.rb.erb", "#{adapter_path}/#{file}.rb"
32
+ m.template "lib/adapter/#{file}.rb.erb", "#{adapter_path}/#{file}.rb"
33
33
  end
34
34
 
35
35
  m.template 'lib/init.rb.erb', "#{adapter_path}.rb"
@@ -52,7 +52,7 @@ class AmbitionAdapterGenerator < RubiGen::Base
52
52
 
53
53
  protected
54
54
  def banner
55
- "Coming soon"
55
+ "Usage: ambition_adapter adapter_name"
56
56
  end
57
57
 
58
58
  def add_options!(opts)
data/lib/ambition/api.rb CHANGED
@@ -37,7 +37,7 @@ module Ambition
37
37
 
38
38
  def first(count = 1)
39
39
  sliced = slice(0, count)
40
- count == 1 ? sliced.kick : sliced
40
+ count == 1 ? Array(sliced.kick).first : sliced
41
41
  end
42
42
 
43
43
  def each(&block)
@@ -1,38 +1,6 @@
1
- ##
2
- # Taken from ruby2ruby, Copyright (c) 2006 Ryan Davis under the MIT License
3
- require 'parse_tree'
4
- require 'ruby2ruby'
5
-
6
1
  class Object
7
- def to_sexp
8
- instance_eval <<-end_eval
9
- return proc { #{inspect} }.to_sexp.last
10
- end_eval
11
- end
12
-
13
2
  def metaclass; (class << self; self end) end
14
3
  def meta_eval(&blk) metaclass.instance_eval(&blk) end
15
4
  def meta_def(name, &blk) meta_eval { define_method name, &blk } end
16
5
  def class_def(name, &blk) class_eval { define_method name, &blk } end
17
6
  end
18
-
19
- class ProcHolder
20
- end
21
-
22
- class Method
23
- def to_sexp
24
- ParseTree.translate(ProcHolder, :proc_to_method)
25
- end
26
- end
27
-
28
- class Proc
29
- def to_method
30
- ProcHolder.send(:define_method, :proc_to_method, self)
31
- ProcHolder.new.method(:proc_to_method)
32
- end
33
-
34
- def to_sexp
35
- body = to_method.to_sexp[2][1..-1]
36
- [:proc, *body]
37
- end
38
- end
@@ -82,7 +82,7 @@ module Ambition
82
82
  ##
83
83
  # Helper methods
84
84
  def to_s
85
- process @block.to_sexp
85
+ process SexpTranslator.translate(@block)
86
86
  end
87
87
 
88
88
  def key
@@ -104,10 +104,11 @@ module Ambition
104
104
 
105
105
  unless instance.respond_to? :context
106
106
  klass.class_eval do
107
- attr_accessor :context
107
+ attr_accessor :context, :negated
108
108
  def owner; @context.owner end
109
109
  def clauses; @context.clauses end
110
110
  def stash; @context.stash end
111
+ def negated?; @negated end
111
112
  end
112
113
  end
113
114
 
@@ -1,3 +1,5 @@
1
+ require 'ruby2ruby'
2
+
1
3
  module Ambition
2
4
  module Processors
3
5
  class Ruby < RubyToRuby
@@ -95,10 +95,10 @@ module Ambition
95
95
  end
96
96
 
97
97
  def negate
98
- @negated = true
98
+ @negated = translator.negated = true
99
99
  yield
100
100
  ensure
101
- @negated = false
101
+ @negated = translator.negated = false
102
102
  end
103
103
  end
104
104
  end
@@ -0,0 +1,15 @@
1
+ require 'parse_tree'
2
+
3
+ module Ambition
4
+ class SexpTranslator
5
+ @@block_cache = {}
6
+
7
+ def self.translate(block)
8
+ @@block_cache[block.to_s] ||= begin
9
+ klass = Class.new { define_method(:proc_to_method, block) }
10
+ body = ParseTree.translate(klass, :proc_to_method)[2][1..-1]
11
+ [:proc, *body]
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/ambition.rb CHANGED
@@ -2,6 +2,7 @@ require 'ambition/enumerable'
2
2
  require 'ambition/api'
3
3
  require 'ambition/context'
4
4
  require 'ambition/core_ext'
5
+ require 'ambition/sexp_translator'
5
6
 
6
7
  require 'ambition/processors/base'
7
8
  require 'ambition/processors/select'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ambition
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.0
7
- date: 2008-01-29 00:00:00 -08:00
6
+ version: 0.5.1
7
+ date: 2008-02-16 00:00:00 -08:00
8
8
  summary: Ambition builds yer API calls from plain jane Ruby.
9
9
  require_paths:
10
10
  - lib
@@ -30,12 +30,12 @@ authors:
30
30
  - Chris Wanstrath
31
31
  files:
32
32
  - app_generators/ambition_adapter/ambition_adapter_generator.rb
33
- - app_generators/ambition_adapter/templates/lib/base.rb.erb
33
+ - app_generators/ambition_adapter/templates/lib/adapter/base.rb.erb
34
+ - app_generators/ambition_adapter/templates/lib/adapter/query.rb.erb
35
+ - app_generators/ambition_adapter/templates/lib/adapter/select.rb.erb
36
+ - app_generators/ambition_adapter/templates/lib/adapter/slice.rb.erb
37
+ - app_generators/ambition_adapter/templates/lib/adapter/sort.rb.erb
34
38
  - app_generators/ambition_adapter/templates/lib/init.rb.erb
35
- - app_generators/ambition_adapter/templates/lib/query.rb.erb
36
- - app_generators/ambition_adapter/templates/lib/select.rb.erb
37
- - app_generators/ambition_adapter/templates/lib/slice.rb.erb
38
- - app_generators/ambition_adapter/templates/lib/sort.rb.erb
39
39
  - app_generators/ambition_adapter/templates/LICENSE
40
40
  - app_generators/ambition_adapter/templates/Rakefile
41
41
  - app_generators/ambition_adapter/templates/README
@@ -54,6 +54,7 @@ files:
54
54
  - lib/ambition/processors/select.rb
55
55
  - lib/ambition/processors/slice.rb
56
56
  - lib/ambition/processors/sort.rb
57
+ - lib/ambition/sexp_translator.rb
57
58
  - lib/ambition.rb
58
59
  - LICENSE
59
60
  - Manifest