scopy 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de96cef11e8765d24e4c521e7db2d8611db53165
4
- data.tar.gz: eb9c002ee4993c66ecd377acb1ee57a0ee21aff6
3
+ metadata.gz: f4ede8244e2248535c20fc15d5669551186f8f88
4
+ data.tar.gz: 8bbd7483d0fa9c75ed28d6c14d7299d7e7a2db48
5
5
  SHA512:
6
- metadata.gz: 55d4ef90a0c7d4f33223d6dddeca0c42c31d70e7d9610415c5b9ad0b8de1168bad5570fd7988609410dff44365c4319d32fbb873a63798dd4844425b11c745b3
7
- data.tar.gz: 3487c2e5880668db3de01a17ef1a0d03a7cd8fca03327a1562b32a50055db6df97fc5a7bff01466f0f5637bed818d5ed4243fca49363e36dbd53f41c2cde93a5
6
+ metadata.gz: 056782b0d1a89a1f3f573c6482a95a605b209903a0ca445722a59e3b906b1e762f72a9b7aa55c4f9e4ba8230ac5d6086ab411714120dfce3d292c27b8afba413
7
+ data.tar.gz: 5c6225a571a37db8077ba0e00df990304b100e01da477a15b3f2d7d6117b40787eebb8e97ecbdbeb3900757c54228c0ca6c75149d5e57c98d0a62ec67c1a8b2c
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Scopy
2
2
 
3
3
  [![Build Status](https://api.travis-ci.org/neighborland/scopy.png)](https://travis-ci.org/neighborland/scopy)
4
+ [![Gem Version](https://badge.fury.io/rb/scopy.png)](http://badge.fury.io/rb/scopy)
4
5
 
5
- Scopy provides common ActiveRecord utility scopes as ActiveSupport concerns.
6
+ Scopy provides common ActiveRecord utility scopes as ActiveSupport model concerns.
6
7
 
7
8
  Common scopes for the following attributes are provided:
8
9
 
@@ -28,6 +29,7 @@ Include the concern modules you would like to use in your models:
28
29
  class Dog < ActiveRecord::Base
29
30
  include Scopy::CreatedAtScopes
30
31
  include Scopy::IdScopes
32
+ include Scopy::NameScopes
31
33
  ```
32
34
 
33
35
  The following examples assume you have a model named `Dog`:
@@ -76,16 +78,16 @@ Dog.excluding(dog)
76
78
  ##### Scopy::NameScopes
77
79
 
78
80
  ```ruby
79
- Dog.name_like('snoop')
81
+ Dog.name_like('snOOp')
80
82
  # => dogs with names containing 'snoop' (case insensitive)
81
83
 
82
- Dog.name_like('snoop', case_sensitive: true)
83
- # => dogs with names containing 'snoop' (case sensitive)
84
+ Dog.name_like('Snoop', case_sensitive: true)
85
+ # => dogs with names containing 'Snoop' (case sensitive)
84
86
 
85
- Dog.name_starts_with('snoop')
87
+ Dog.name_starts_with('snOOp')
86
88
  # => dogs with names starting with 'snoop' (case insensitive)
87
89
 
88
- Dog.name_starts_with('snoop', case_sensitive: true)
89
- # => dogs with names starting with 'snoop' (case sensitive)
90
+ Dog.name_starts_with('Snoop', case_sensitive: true)
91
+ # => dogs with names starting with 'Snoop' (case sensitive)
90
92
  ```
91
93
 
@@ -3,7 +3,7 @@ module Scopy
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- scope :newest, ->{ order("#{self.table_name}.created_at desc") }
6
+ scope :newest, ->{ order("#{self.table_name}.created_at DESC") }
7
7
  scope :oldest, ->{ order("#{self.table_name}.created_at") }
8
8
 
9
9
  scope :created_since, ->(since) do
@@ -9,12 +9,12 @@ module Scopy
9
9
  included do
10
10
  scope :name_like, ->(text, options={}) do
11
11
  cs = options[:case_sensitive]
12
- where("#{_lhs_name_column(cs)} LIKE '%#{_rhs_name_value(text, cs)}%'")
12
+ where("#{_lhs_name_column(cs)} LIKE ?", "%#{_rhs_name_value(text, cs)}%")
13
13
  end
14
14
 
15
15
  scope :name_starts_with, ->(text, options={}) do
16
16
  cs = options[:case_sensitive]
17
- where("#{_lhs_name_column(cs)} LIKE '#{_rhs_name_value(text, cs)}%'")
17
+ where("#{_lhs_name_column(cs)} LIKE ?", "#{_rhs_name_value(text, cs)}%")
18
18
  end
19
19
  end
20
20
 
data/lib/scopy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Scopy
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -19,6 +19,11 @@ class NameScopesTest < Test::Unit::TestCase
19
19
  assert_empty Dog.name_like("cat", case_sensitive: true)
20
20
  end
21
21
 
22
+ should "find with quotes" do
23
+ o_dogg = Dog.create(name: "Snoop O'Doggly")
24
+ assert Dog.name_like("O'Dogg").include?(o_dogg)
25
+ end
26
+
22
27
  should "find case insensitive" do
23
28
  assert Dog.name_like("doG").include?(@dog)
24
29
  assert_empty Dog.name_like("cat")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scopy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tee Parham