duck_chain 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c00277c8f44c8126393e5cc3e5116cd942877d86
4
+ data.tar.gz: 885c76fd153520ac4606b8429598656a78a42551
5
+ SHA512:
6
+ metadata.gz: f3d0673ae48ef702c377cbb7900af3791cf5a97e1691a812e23aa5664bcbcfae4493838fa8265274d110e92ec4ea09b5a296067d76c91406d6f53b9b4b4dfbf7
7
+ data.tar.gz: 65d89ccabc5a5ffef387f57102e3847209797ee2670170701efb061552030f3a7f88f7bd09978231743aef07dc92054e8fbc72a8c4863de8cad7fcd8f5d76f12
@@ -1,2 +1,5 @@
1
+ Version 1.1.0
2
+ * Added duck_chain_all (cromulus)
3
+
1
4
  Version 1.0.0
2
5
  * First release
@@ -8,7 +8,7 @@ is a fine replacement, it doesn't provide the dynamic named scopes (ie Post.titl
8
8
  transition, duck_chain extends ActiveRecord and creates extra chainable model methods for attributes you specifiy which act similar to the basic
9
9
  searchlogic named scopes. The methods simply return Arel where cluases so you can chain them with other methods.
10
10
 
11
- Only the basic single table methods are supported (eq, not_equal, gte, like, etc.). Meaning you can't do Post.post_comments_title_eq("This blog sux").
11
+ Only the basic single table methods are supported (eq, not_equal, gte, like, etc.). Meaning you can't do Post.post_comments_title_eq("This blog sux").
12
12
  Legacy code like that should be converted into an Arel where method, metasearch search method, or whatever you decide to go with for Rails 3. Again,
13
13
  the gem was built to help with the transition and provide some of the basic search methods people using searchlogic are used to in Rails 3. Plus, I personally like typing out
14
14
  Post.created_at_gte(Time.now).content_like("I like shorts. They're comfortable and easy to wear.") more than Post.where(['created_at >= ?', Time.now]).where("content LIKE '%I like shorts. They're comfortable and easy to wear.%'").
@@ -37,7 +37,14 @@ To have duck_chain bind to the title, content, and url attributes of the model..
37
37
  # Note you can use symbols or strings in your list of attributes
38
38
  end
39
39
 
40
- Calling duck_chain creates a bunch of chainable methods for the Post model for the content, title, and url attributes...
40
+ Calling duck_chain creates a bunch of chainable methods for the Post model for the content, title, and url attributes
41
+
42
+ Or, instead of specifying exactly which attributes to chain, you can call
43
+ class Post < ActiveRecord::Base
44
+ duck_chain_all
45
+ end
46
+ which will add duck_chain to all of the attributes of the model
47
+ ...
41
48
 
42
49
  Example new methods related to the title attribute:
43
50
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
- require 'rake/rdoctask'
3
+ require 'rdoc/task'
4
4
  desc 'Generate RDoc documentation for the will_paginate plugin.'
5
5
  Rake::RDocTask.new(:rdoc) do |rdoc|
6
6
  rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG.rdoc').include('lib/**/*.rb').exclude('lib/duck_chain/version.rb')
@@ -1,7 +1,12 @@
1
1
  module DuckChain
2
2
 
3
3
  # Methods that extend ActiveRecord and allows duck_chain to work
4
- module ActiveRecordExtensions
4
+ module ActiveRecordExtensions
5
+ # creates a duck chain extensions for all model attributes.
6
+ def duck_chain_all
7
+ cols = self.column_names.map(&:to_sym)
8
+ self.send(:duck_chain,*cols)
9
+ end
5
10
 
6
11
  # The generic call which will generate all methods for the model
7
12
  def duck_chain(*model_attributes)
@@ -11,22 +16,22 @@ module DuckChain
11
16
  end
12
17
 
13
18
  # Takes the list of model attributes calls the create method from DuckChain::Toolset
14
- # to generate the 'eq' methods
19
+ # to generate the 'eq' methods
15
20
  def duck_chain_eq(*model_attributes)
16
21
  Toolset.create_eq_methods(model_attributes)
17
22
  end
18
23
 
19
24
  # Takes the list of model attributes calls the create method from DuckChain::Toolset
20
- # to generate the 'list' methods
25
+ # to generate the 'list' methods
21
26
  def duck_chain_like(*model_attributes)
22
27
  Toolset.create_like_methods(model_attributes)
23
28
  end
24
29
 
25
30
  # Takes the list of model attributes calls the create method from DuckChain::Toolset
26
- # to generate the 'range' methods
31
+ # to generate the 'range' methods
27
32
  def duck_chain_range(*model_attributes)
28
33
  Toolset.create_range_methods(model_attributes)
29
34
  end
30
-
35
+
31
36
  end
32
37
  end
@@ -1,3 +1,3 @@
1
1
  module DuckChain
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,49 +1,39 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: duck_chain
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Tony Drake
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-06-14 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2013-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: activerecord
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- - 0
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
34
19
  version: 3.0.0
35
20
  type: :runtime
36
- version_requirements: *id001
37
- description: A simple Rails 3 Gem that extends ActiveRecord. Let's you specify model attributes to dynamically create search methods similar to searchlogic's dynamic named scopes. It can be used to help Rails 2 projects with searchlogic migrate to Rails 3 with metasearch a little easier.
38
- email:
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ description: A simple Rails 3 Gem that extends ActiveRecord. Let's you specify model
28
+ attributes to dynamically create search methods similar to searchlogic's dynamic
29
+ named scopes. It can be used to help Rails 2 projects with searchlogic migrate to
30
+ Rails 3 with metasearch a little easier.
31
+ email:
39
32
  - t27duck@gmail.com
40
33
  executables: []
41
-
42
34
  extensions: []
43
-
44
35
  extra_rdoc_files: []
45
-
46
- files:
36
+ files:
47
37
  - .gitignore
48
38
  - CHANGELOG.rdoc
49
39
  - Gemfile
@@ -55,41 +45,27 @@ files:
55
45
  - lib/duck_chain/active_record_extensions.rb
56
46
  - lib/duck_chain/toolset.rb
57
47
  - lib/duck_chain/version.rb
58
- has_rdoc: true
59
48
  homepage:
60
49
  licenses: []
61
-
50
+ metadata: {}
62
51
  post_install_message:
63
52
  rdoc_options: []
64
-
65
- require_paths:
53
+ require_paths:
66
54
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
- requirements:
79
- - - ">"
80
- - !ruby/object:Gem::Version
81
- hash: 25
82
- segments:
83
- - 1
84
- - 3
85
- - 1
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - '>'
63
+ - !ruby/object:Gem::Version
86
64
  version: 1.3.1
87
65
  requirements: []
88
-
89
66
  rubyforge_project: duck_chain
90
- rubygems_version: 1.6.2
67
+ rubygems_version: 2.0.3
91
68
  signing_key:
92
- specification_version: 3
69
+ specification_version: 4
93
70
  summary: Because I like chaining easy to read search methods with ActiveRecord thankyouverymuch
94
71
  test_files: []
95
-