cajun-ludicrous_speed 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 cajun
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,7 @@
1
+ = ludicrous_speed
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2009 cajun. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "ludicrous_speed"
8
+ gem.summary = %Q{TODO}
9
+ gem.email = "zac@kleinpeter.org"
10
+ gem.homepage = "http://github.com/cajun/ludicrous_speed"
11
+ gem.authors = ["cajun"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:spec) do |spec|
21
+ spec.libs << 'lib' << 'spec'
22
+ spec.pattern = 'spec/**/*_spec.rb'
23
+ spec.verbose = true
24
+ end
25
+
26
+ begin
27
+ require 'rcov/rcovtask'
28
+ Rcov::RcovTask.new do |spec|
29
+ spec.libs << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.verbose = true
32
+ end
33
+ rescue LoadError
34
+ task :rcov do
35
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
36
+ end
37
+ end
38
+
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ if File.exist?('VERSION.yml')
45
+ config = YAML.load(File.read('VERSION.yml'))
46
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
47
+ else
48
+ version = ""
49
+ end
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "ludicrous_speed #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,4 @@
1
+ require 'activerecord'
2
+ require 'ludicrous_speed/named_yield_or'
3
+
4
+ ActiveRecord::Base.extend( LudicrousSpeed::NamedYieldOr )
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe "LudicrousSpeed" do
4
+ it 'has a really cool finder' do
5
+ Foo.should.respond_to :name_yield_or
6
+ end
7
+
8
+ it 'has a really cool named finder' do
9
+ Foo.should.respond_to :bar
10
+ end
11
+
12
+ it 'has a really cool finder definitions' do
13
+ Foo.should.respond_to :definitions
14
+ end
15
+
16
+ it 'will have bar and it will find _why\'s bacon' do
17
+ Foo.definitions[:bar].call.should == {:conditions => "_why = 'bacon'"}
18
+ end
19
+
20
+ it 'has conditions that get scoped' do
21
+ Foo.send( :scoped_methods ).should.be.empty?
22
+
23
+ Foo.bar do
24
+ Foo.send( :scoped_methods ).should == [ { :find => {:conditions => "_why = 'bacon'"} } ]
25
+ Foo.send( :current_scoped_methods ).should == { :find => {:conditions => "_why = 'bacon'"} }
26
+ end
27
+
28
+ Foo.send( :scoped_methods ).should.be.empty?
29
+ end
30
+
31
+ it 'like params in the name yield or scopes as well' do
32
+ should.not.raise { Foo.omg( '_why', 1 ) }
33
+ end
34
+
35
+
36
+ it 'can do nesting with ease' do
37
+ Foo.send( :scoped_methods ).should.be.empty?
38
+
39
+ Foo.omg( 'name', 6 ) do
40
+ Foo.send( :scoped_methods ).should == [ { :find => {:conditions => "name != 6"} } ]
41
+ Foo.send( :current_scoped_methods ).should == { :find => {:conditions => "name != 6"} }
42
+
43
+ Foo.bar do
44
+ Foo.send( :scoped_methods ).should == [{:find=>{:conditions=>"name != 6"}}, {:find=>{:conditions=>"(name != 6) AND (_why = 'bacon')"}}]
45
+ Foo.send( :current_scoped_methods ).should == {:find=>{:conditions=>"(name != 6) AND (_why = 'bacon')"}}
46
+ end
47
+
48
+ Foo.send( :scoped_methods ).should == [ { :find => {:conditions => "name != 6"} } ]
49
+ Foo.send( :current_scoped_methods ).should == { :find => {:conditions => "name != 6"} }
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'bacon'
3
+ require 'ruby-debug'
4
+
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ require 'ludicrous_speed'
8
+
9
+ File.delete( 'dbfile' )
10
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "dbfile")
11
+
12
+ Bacon.summary_on_exit
13
+
14
+ ActiveRecord::Migration.create_table :foos do |t|
15
+ t.string :name
16
+ t.string :bacon
17
+ t.text :_why
18
+ end
19
+
20
+ class Foo < ActiveRecord::Base
21
+ name_yield_or( :bar, { :conditions => "_why = 'bacon'" } )
22
+ name_yield_or( :omg, lambda{ |x,y| { :conditions => "#{x} != #{y}" } } )
23
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cajun-ludicrous_speed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - cajun
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-21 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: zac@kleinpeter.org
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - lib/ludicrous_speed.rb
33
+ - spec/ludicrous_speed_spec.rb
34
+ - spec/spec_helper.rb
35
+ has_rdoc: false
36
+ homepage: http://github.com/cajun/ludicrous_speed
37
+ licenses:
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --charset=UTF-8
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.3.5
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: TODO
62
+ test_files:
63
+ - spec/ludicrous_speed_spec.rb
64
+ - spec/spec_helper.rb