scopy 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjdlZTgyYmI2MzAxZTllZjlhMmIzZGVjMmRiOWI4NGY1NmM1YjYxMw==
5
- data.tar.gz: !binary |-
6
- NDAwY2Q0NWZlNTViYjYwYmE1MmU1YzU5ZTBjNTJiZDM2YmMxMTBmNw==
2
+ SHA1:
3
+ metadata.gz: f7237b94db429dadd316c822f5c98be784fecaf7
4
+ data.tar.gz: e8ce3e65904a3e13c51b98363bc013bd7fc051d2
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- OTBmYTJhNzQwY2U2M2RhOWEzOWI1YTZlZDhiYzk1NWFhY2Y1ZmZiNTAyMWE1
10
- M2IxYTE0ZmM2YzIxY2U3M2NjYTg2M2E4YjlkYzE4ZWFmMDFhOTNlMWYzMTJk
11
- ZWFkNjFiZTZjZTUxODQ5NjhmNTM2NjFhMjNkZjU3ZDU1ZmY1ZjQ=
12
- data.tar.gz: !binary |-
13
- NjQ2MzJjZGY5NGFlNmRiODM1NGZhYTc3ODhkNDA0NTliYTI5NTQwYjk4ZDRl
14
- ZjUwNTliYmYxNDUwMDJlYTkzNGU1ZTM2OGJhMTRlYjQwYjRiYzRlNmEzZmUw
15
- MmQwOTU5NDFjNTVlZmFkYzJiYjE5ZmFkZGVjMmZkZjM2MTMzMTU=
6
+ metadata.gz: 711f182898137d8cf4c47d88575e9470b51c85728e36c9c61765b5bd42e62eeec92857f628bc571782826a1ab46a6875c1c85ee8b9eadc4a03c031b9ad59b726
7
+ data.tar.gz: 00495b5d688712565448182f1c34973a396eff66fd1d7b2b6cc04c6133a849204e2bd3460591b3e82849be6d02c7d39455441896925b28c3ca5bf355f1a4eff3
data/lib/scopy.rb CHANGED
@@ -2,4 +2,3 @@ require "scopy/version"
2
2
  require "scopy/created_at_scopes"
3
3
  require "scopy/id_scopes"
4
4
  require "scopy/name_scopes"
5
-
@@ -3,15 +3,15 @@ module Scopy
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- scope :newest, ->{ order("#{ self.table_name }.created_at DESC") }
7
- scope :oldest, ->{ order("#{ self.table_name }.created_at") }
6
+ scope :newest, -> { order("#{table_name}.created_at DESC") }
7
+ scope :oldest, -> { order("#{table_name}.created_at") }
8
8
 
9
9
  scope :created_since, ->(since) do
10
- where("#{ self.table_name }.created_at >= ?", since)
10
+ where("#{table_name}.created_at >= ?", since) if since
11
11
  end
12
12
 
13
13
  scope :created_before, ->(before) do
14
- where("#{ self.table_name }.created_at <= ?", before)
14
+ where("#{table_name}.created_at <= ?", before) if before
15
15
  end
16
16
 
17
17
  scope :created_between, ->(from, to) do
@@ -34,6 +34,5 @@ module Scopy
34
34
  created_between date.beginning_of_year, date.end_of_year
35
35
  end
36
36
  end
37
-
38
37
  end
39
38
  end
@@ -3,10 +3,9 @@ module Scopy
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- scope :excluding_id, ->(id){ where("#{self.table_name}.id <> ?", id) if id }
7
- scope :excluding_ids, ->(ids){ where("#{self.table_name}.id NOT IN (?)", ids) if ids.any? }
8
- scope :excluding, ->(object){ excluding_id(object.id) if object }
6
+ scope :excluding_id, ->(id) { where("#{table_name}.id <> ?", id) if id }
7
+ scope :excluding_ids, ->(ids) { where("#{table_name}.id NOT IN (?)", ids) if ids.any? }
8
+ scope :excluding, ->(object) { excluding_id(object.id) if object }
9
9
  end
10
-
11
10
  end
12
- end
11
+ end
@@ -1,34 +1,31 @@
1
1
  module Scopy
2
2
  module NameScopes
3
3
  extend ActiveSupport::Concern
4
-
4
+
5
5
  # note: case-sensitive like operations do not work as expected in Sqlite,
6
6
  # which we are using as the test database.
7
7
  # see http://goo.gl/Lxxc4m
8
-
8
+
9
9
  included do
10
- scope :name_like, ->(text, options={}) do
10
+ scope :name_like, ->(text, options = {}) do
11
11
  cs = options[:case_sensitive]
12
12
  where("#{_lhs_name_column(cs)} LIKE ?", "%#{_rhs_name_value(text, cs)}%")
13
13
  end
14
-
15
- scope :name_starts_with, ->(text, options={}) do
14
+
15
+ scope :name_starts_with, ->(text, options = {}) do
16
16
  cs = options[:case_sensitive]
17
17
  where("#{_lhs_name_column(cs)} LIKE ?", "#{_rhs_name_value(text, cs)}%")
18
- end
18
+ end
19
19
  end
20
-
21
- private
22
-
23
- module ClassMethods
20
+
21
+ module ClassMethods
24
22
  def _lhs_name_column(case_sensitive)
25
- case_sensitive ? "#{self.table_name}.name" : "LOWER(#{self.table_name}.name)"
23
+ case_sensitive ? "#{table_name}.name" : "LOWER(#{table_name}.name)"
26
24
  end
27
-
25
+
28
26
  def _rhs_name_value(text, case_sensitive)
29
27
  case_sensitive ? text : text.try(:downcase)
30
28
  end
31
- end
32
-
29
+ end
33
30
  end
34
- end
31
+ end
data/lib/scopy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Scopy
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scopy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tee Parham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-26 00:00:00.000000000 Z
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.1'
47
+ version: '11.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.1'
54
+ version: '11.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mocha
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.3'
83
83
  description: Rails ActiveRecord scopes for id, created_at, and name
@@ -104,19 +104,18 @@ require_paths:
104
104
  - lib
105
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - ! '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: 1.9.3
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - ! '>='
112
+ - - ">="
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 2.4.5
117
+ rubygems_version: 2.6.6
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Rails ActiveRecord scopes for id, created_at, and name
121
121
  test_files: []
122
- has_rdoc: