gyroscope 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf459b04ef38e80fc048d485337c197519ff6950
4
- data.tar.gz: b4628759f58aa82af0033d578281efa2f5651b16
3
+ metadata.gz: 921456f0511457b6ac95020900184bbd72dda476
4
+ data.tar.gz: 58b80e30d3121376dc532814056305217c8fa6c9
5
5
  SHA512:
6
- metadata.gz: a987c3ccf09daae87b46cc9ca50ba28d1b79580f4c8a35c8df663632d084df2efaffcba6b978459e1a6ff7861272b2b91eb45c0f1d97a527ee4b0600e37aa661
7
- data.tar.gz: 24c25a95db77984b69b01f900902a251f013e2c2fd2703fbaeab0fd99f81de32a3722d6077e26151af664d682ecfa908aa8f9e61fc04c045bae601227c74899d
6
+ metadata.gz: 15335b433d70c5b3c3854269f7e3ad4f449d7b92164684572ac064478bde20812432b678b43847225fce13ce2d6127620868197b26939d605ae307d5c6bbd90f
7
+ data.tar.gz: 4e63ef51e2f8e1f302190215b71cb85f008ff7713cac02ffab9a19b016677baa8f4d6f5bea987e96312af5eba7d63a8cfb38c966cfdb28eb748f25046f27a763
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+ CHANGELOG inspiration from http://keepachangelog.com/.
5
+
6
+ ## Unreleased
7
+
8
+ ## [0.1.1] - April 18, 2016
9
+ * Raise an error that has the errors object so we can render it nicely.
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Donald Plummer
3
+ Copyright (c) 2016 Avvo and Friends
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -22,7 +22,22 @@ Or install it yourself as:
22
22
  ```ruby
23
23
  module Search
24
24
  class User < Gyroscope::SearchBase
25
+ attribute :ids, Gyroscope::IntegerList
25
26
  attribute :name, String
27
+
28
+ def build_search_scope
29
+ scope = super
30
+
31
+ if ids.present?
32
+ scope = scope.where(id: ids)
33
+ end
34
+
35
+ if name.present?
36
+ scope = scope.where(name: name)
37
+ end
38
+
39
+ scope
40
+ end
26
41
  end
27
42
  end
28
43
 
@@ -21,12 +21,28 @@ module Gyroscope
21
21
  "::#{self.class.name.demodulize}".constantize
22
22
  end
23
23
 
24
+ class ValidationError < StandardError
25
+ attr_reader :searcher
26
+
27
+ def initialize(searcher)
28
+ @searcher = searcher
29
+ end
30
+
31
+ def message
32
+ "Check your default values for correctness"
33
+ end
34
+
35
+ def as_json(*)
36
+ { errors: searcher.errors }
37
+ end
38
+ end
39
+
24
40
  def search
25
41
  # is there a more generic ActiveModel validation error?
26
42
  unless valid?
27
43
  Rails.logger.debug("the errors: #{errors.inspect}")
28
44
  end
29
- fail ActiveModel::ForbiddenAttributesError, "Check your default values for correctness" unless valid?
45
+ fail ValidationError.new(self) unless valid?
30
46
 
31
47
  build_search_scope
32
48
  end
@@ -1,3 +1,3 @@
1
1
  module Gyroscope
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gyroscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wilhelm
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-02-23 00:00:00.000000000 Z
12
+ date: 2016-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -120,6 +120,7 @@ files:
120
120
  - ".gitignore"
121
121
  - ".rspec"
122
122
  - ".travis.yml"
123
+ - CHANGELOG.md
123
124
  - Gemfile
124
125
  - LICENSE.txt
125
126
  - README.md