baza_models 0.0.4 → 0.0.5

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: 4edadeab01c210ce4d6eb26989945d496aa66075
4
- data.tar.gz: 00229063065ccfcfdb6189b926e5f3c81a33b1e4
3
+ metadata.gz: 6dbce57502f93c9b90c5d5dba534b57b4db38d2a
4
+ data.tar.gz: 2b6dc34ac4dbfcfeb36b38ad8e49f07ea80c41ae
5
5
  SHA512:
6
- metadata.gz: 8b3e220cb2c0467ce53fdb66b754eef986069cb5d8c208558dc1f94ec71106539ffc9552aa13600133fe0adc8824614d389308fb5cd8e4a67cf7c6a351e02f98
7
- data.tar.gz: b9b8691f657f2febae4613e57c079d8f23bd9878a184d0ff174fb8c30bbd326fcf4d92dfa89e3b84052180a3ed7f68b980c8bd9a5b886df6c6fd6c38db811685
6
+ metadata.gz: 90cdb2022ec8e2b869777e34cf83752f6074f045c1fff4c1489e013f3956b2f192410d56847401e9f954a6f92f44794e849ad809243ea274bd5e6aee5c7d5bdb
7
+ data.tar.gz: 3b6c290cc503f5314a8bcf3769ab003ea27d39b297bbf11fcd407f9bc05d903adabd722b37455c1e37cce72924cc538512e4dfb8f105ed95d09dd4c63a0208f6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/baza_models.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: baza_models 0.0.4 ruby lib
5
+ # stub: baza_models 0.0.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "baza_models"
9
- s.version = "0.0.4"
9
+ s.version = "0.0.5"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["kaspernj"]
14
- s.date = "2016-04-07"
14
+ s.date = "2016-04-09"
15
15
  s.description = "ActiveRecord like models for the Baza database framework"
16
16
  s.email = "k@spernj.org"
17
17
  s.extra_rdoc_files = [
@@ -44,7 +44,7 @@ class BazaModels::Model
44
44
  end
45
45
 
46
46
  QUERY_METHODS = [
47
- :all, :any?, :each, :empty?, :none?, :count, :find, :first, :find_first, :last, :length, :select, :includes,
47
+ :all, :any?, :each, :empty?, :none?, :count, :find, :first, :find_first, :last, :length, :size, :select, :includes,
48
48
  :joins, :group, :where, :order, :limit, :to_a, :accessible_by, :ransack
49
49
  ].freeze
50
50
  QUERY_METHODS.each do |query_method|
@@ -64,6 +64,11 @@ class BazaModels::Query
64
64
  end
65
65
  end
66
66
 
67
+ def size
68
+ # TODO: This should also take counter caching into account
69
+ length
70
+ end
71
+
67
72
  def new(attributes)
68
73
  raise "No previous model" unless @_previous_model
69
74
  raise "No relation" unless @_relation
@@ -31,8 +31,6 @@ private
31
31
  match = value.to_s.match(/\A([A-z_\d]+)\s+(asc|desc)\Z/)
32
32
  raise "Couldn't sort-match: #{value}" unless match
33
33
  sort_by(column_name: match[1], sort_mode: match[2])
34
- else
35
- raise "Unknown modifier: #{key}"
36
34
  end
37
35
  end
38
36
  end
@@ -91,18 +91,20 @@ describe BazaModels::Query do
91
91
  end
92
92
  end
93
93
 
94
- it "#any? #empty? #none? #count #length" do
94
+ it "#any? #empty? #none? #count #length #size" do
95
95
  expect(User.any?).to eq false
96
96
  expect(User.empty?).to eq true
97
97
  expect(User.none?).to eq true
98
98
  expect(User.count).to eq 0
99
99
  expect(User.length).to eq 0
100
+ expect(User.size).to eq 0
100
101
  user.save!
101
102
  expect(User.any?).to eq true
102
103
  expect(User.empty?).to eq false
103
104
  expect(User.none?).to eq false
104
105
  expect(User.count).to eq 1
105
106
  expect(User.length).to eq 1
107
+ expect(User.size).to eq 1
106
108
  end
107
109
 
108
110
  it "#find" do
@@ -40,4 +40,8 @@ describe BazaModels::Query do
40
40
  query = Person.ransack(user_organization_name_cont: "Test")
41
41
  expect(query.result.to_a).to eq [person]
42
42
  end
43
+
44
+ it "ignores unknown parameters and doesn't raise exceptions" do
45
+ Person.ransack(custom_something: "Test").result
46
+ end
43
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baza_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-07 00:00:00.000000000 Z
11
+ date: 2016-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_enumerator